예제 #1
0
/******************************************************************************
*  Return the column order.
*/
QValueList<int> AlarmListView::columnOrder() const
{
    QHeader *hdr = header();
    int order[COLUMN_COUNT];
    order[TIME_COLUMN]    = hdr->mapToIndex(mColumn[TIME_COLUMN]);
    order[TIME_TO_COLUMN] = hdr->mapToIndex(mColumn[TIME_TO_COLUMN]);
    order[REPEAT_COLUMN]  = hdr->mapToIndex(mColumn[REPEAT_COLUMN]);
    order[COLOUR_COLUMN]  = hdr->mapToIndex(mColumn[COLOUR_COLUMN]);
    order[TYPE_COLUMN]    = hdr->mapToIndex(mColumn[TYPE_COLUMN]);
    order[MESSAGE_COLUMN] = hdr->mapToIndex(mColumn[MESSAGE_COLUMN]);
    QValueList<int> orderList;
    for(int i = 0;  i < COLUMN_COUNT;  ++i)
        orderList += order[i];
    return orderList;
}
예제 #2
0
/******************************************************************************
*  Sets the last column in the list view to extend at least to the right hand
*  edge of the list view.
*/
void EventListViewBase::resizeLastColumn()
{
    int lastColumnWidth = mLastColumnHeaderWidth;
    for (EventListViewItemBase* item = firstChild();  item;  item = item->nextSibling())
    {
        int mw = item->lastColumnWidth();
        if (mw > lastColumnWidth)
            lastColumnWidth = mw;
    }
    QHeader* head = header();
    int x = head->sectionPos(mLastColumn);
    int availableWidth = visibleWidth() - x;
    int rightColWidth = 0;
    int index = head->mapToIndex(mLastColumn);
    if (index < mLastColumn)
    {
        // The last column has been dragged by the user to a different position.
        // Ensure that the columns now to the right of it are still shown.
        for (int i = index + 1;  i <= mLastColumn;  ++i)
            rightColWidth += columnWidth(head->mapToSection(i));
        availableWidth -= rightColWidth;
    }
    if (availableWidth < lastColumnWidth)
        availableWidth = lastColumnWidth;
    setColumnWidth(mLastColumn, availableWidth);
    if (contentsWidth() > x + availableWidth + rightColWidth)
        resizeContents(x + availableWidth + rightColWidth, contentsHeight());
}