Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/graphicsview/qgraphicsgridlayout.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6565    destroying it.
    6666
     67    \section1 Size Hints and Size Policies in QGraphicsGridLayout
     68
     69    QGraphicsGridLayout respects each item's size hints and size policies,
     70    and when a cell in the grid has more space than the items can fill, each item
     71    is arranged according to the layout's alignment for that item. You can set
     72    an alignment for each item by calling setAlignment(), and check the
     73    alignment for any item by calling alignment(). You can also set the alignment
     74    for an entire row or column by calling setRowAlignment() and setColumnAlignment()
     75    respectively.  By default, items are aligned to the top left.
     76
     77
    6778    \sa QGraphicsLinearLayout, QGraphicsWidget
    6879*/
     
    95106};
    96107
     108Q_GLOBAL_STATIC(QWidget, globalStyleInfoWidget);
     109
    97110QLayoutStyleInfo QGraphicsGridLayoutPrivate::styleInfo() const
    98111{
    99     static QWidget *wid = 0;
    100     if (!wid)
    101         wid = new QWidget;
    102112    QGraphicsItem *item = parentItem();
    103113    QStyle *style = (item && item->isWidget()) ? static_cast<QGraphicsWidget*>(item)->style() : QApplication::style();
    104     return QLayoutStyleInfo(style, wid);
     114    return QLayoutStyleInfo(style, globalStyleInfoWidget());
    105115}
    106116
     
    573583            layoutItem->setParentLayoutItem(0);
    574584        d->engine.removeItem(gridItem);
     585
     586        // recalculate rowInfo.count if we remove an item that is on the right/bottommost row
     587        for (int j = 0; j < NOrientations; ++j) {
     588            // 0: Hor, 1: Ver
     589            const Qt::Orientation orient = (j == 0 ? Qt::Horizontal : Qt::Vertical);
     590            const int oldCount = d->engine.rowCount(orient);
     591            if (gridItem->lastRow(orient) == oldCount - 1) {
     592                const int newCount = d->engine.effectiveLastRow(orient) + 1;
     593                d->engine.removeRows(newCount, oldCount - newCount, orient);
     594            }
     595        }
     596
    575597        delete gridItem;
    576598        invalidate();
     
    631653    qreal left, top, right, bottom;
    632654    getContentsMargins(&left, &top, &right, &bottom);
    633     return d->engine.sizeHint(d->styleInfo(), which , constraint) + QSizeF(left + right, top + bottom);
     655    const QSizeF extraMargins(left + right, top + bottom);
     656    return d->engine.sizeHint(d->styleInfo(), which , constraint - extraMargins) + extraMargins;
    634657}
    635658
Note: See TracChangeset for help on using the changeset viewer.