示例#1
0
/******************************************************************************
*  Delete a specified item from the list.
*/
void EventListViewBase::deleteEntry(EventListViewItemBase* item, bool setSize)
{
    if (item)
    {
        delete item;
        if (setSize)
            resizeLastColumn();
        emit itemDeleted();
    }
}
示例#2
0
EventListViewItemBase* EventListViewBase::addEntry(EventListViewItemBase* item, bool setSize, bool reselect)
{
    if (setSize)
        resizeLastColumn();
    if (reselect)
    {
        clearSelection();
        setSelected(item, true);
    }
    return item;
}
示例#3
0
/******************************************************************************
*  Set which time columns are to be displayed.
*/
void AlarmListView::selectTimeColumns(bool time, bool timeTo)
{
    if(!time  &&  !timeTo)
        return;       // always show at least one time column
    bool changed = false;
    int w = columnWidth(mColumn[TIME_COLUMN]);
    if(time  &&  !w)
    {
        // Unhide the time column
        int colWidth = mTimeColumnHeaderWidth;
        QFontMetrics fm = fontMetrics();
        for(AlarmListViewItem *item = firstChild();  item;  item = item->nextSibling())
        {
            int w = item->width(fm, this, mColumn[TIME_COLUMN]);
            if(w > colWidth)
                colWidth = w;
        }
        setColumnWidth(mColumn[TIME_COLUMN], colWidth);
        setColumnWidthMode(mColumn[TIME_COLUMN], QListView::Maximum);
        changed = true;
    }
    else if(!time  &&  w)
    {
        // Hide the time column
        setColumnWidthMode(mColumn[TIME_COLUMN], QListView::Manual);
        setColumnWidth(mColumn[TIME_COLUMN], 0);
        changed = true;
    }
    w = columnWidth(mColumn[TIME_TO_COLUMN]);
    if(timeTo  &&  !w)
    {
        // Unhide the time-to-alarm column
        setColumnWidthMode(mColumn[TIME_TO_COLUMN], QListView::Maximum);
        updateTimeToAlarms(true);
        if(columnWidth(mColumn[TIME_TO_COLUMN]) < mTimeToColumnHeaderWidth)
            setColumnWidth(mColumn[TIME_TO_COLUMN], mTimeToColumnHeaderWidth);
        changed = true;
    }
    else if(!timeTo  &&  w)
    {
        // Hide the time-to-alarm column
        setColumnWidthMode(mColumn[TIME_TO_COLUMN], QListView::Manual);
        setColumnWidth(mColumn[TIME_TO_COLUMN], 0);
        changed = true;
    }
    if(changed)
    {
        resizeLastColumn();
        triggerUpdate();   // ensure scroll bar appears if needed
    }
}
示例#4
0
/******************************************************************************
*  Refresh the list by clearing it and redisplaying all the current alarms.
*/
void EventListViewBase::refresh()
{
    QString currentID;
    if (currentItem())
        currentID = currentItem()->event().id();    // save current item for restoration afterwards
    clear();
    populate();
    resizeLastColumn();
    EventListViewItemBase* current = getEntry(currentID);
    if (current)
    {
        setCurrentItem(current);
        ensureItemVisible(current);
    }
}
示例#5
0
/******************************************************************************
*  Called when the widget is first displayed.
*  Sets the last column in the list view to extend at least to the right hand
*  edge of the list view.
*/
void EventListViewBase::showEvent(QShowEvent* se)
{
    KListView::showEvent(se);
    resizeLastColumn();
}
示例#6
0
/******************************************************************************
*  Called when the widget's size has changed (before it is painted).
*  Sets the last column in the list view to extend at least to the right hand
*  edge of the list view.
*/
void EventListViewBase::resizeEvent(QResizeEvent* re)
{
    KListView::resizeEvent(re);
    resizeLastColumn();
}