Changeset 846 for trunk/src/gui/graphicsview/qgraphicsgridlayout.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/graphicsview/qgraphicsgridlayout.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 65 65 destroying it. 66 66 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 67 78 \sa QGraphicsLinearLayout, QGraphicsWidget 68 79 */ … … 95 106 }; 96 107 108 Q_GLOBAL_STATIC(QWidget, globalStyleInfoWidget); 109 97 110 QLayoutStyleInfo QGraphicsGridLayoutPrivate::styleInfo() const 98 111 { 99 static QWidget *wid = 0;100 if (!wid)101 wid = new QWidget;102 112 QGraphicsItem *item = parentItem(); 103 113 QStyle *style = (item && item->isWidget()) ? static_cast<QGraphicsWidget*>(item)->style() : QApplication::style(); 104 return QLayoutStyleInfo(style, wid);114 return QLayoutStyleInfo(style, globalStyleInfoWidget()); 105 115 } 106 116 … … 573 583 layoutItem->setParentLayoutItem(0); 574 584 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 575 597 delete gridItem; 576 598 invalidate(); … … 631 653 qreal left, top, right, bottom; 632 654 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; 634 657 } 635 658
Note:
See TracChangeset
for help on using the changeset viewer.