Exemple #1
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());
}