summaryrefslogtreecommitdiff
path: root/src/gui/graphicsview/qgraphicsgridlayout.cpp
diff options
context:
space:
mode:
authorJan-Arve Sæther <jan-arve.saether@nokia.com>2010-06-16 10:05:44 +0200
committerJan-Arve Sæther <jan-arve.saether@nokia.com>2010-06-16 10:50:23 +0200
commit183abff6ffcb020b8f0c4041cc82bba0d3b03863 (patch)
tree7492fe295fdc966b72ba27f3c68ef5d7716e2801 /src/gui/graphicsview/qgraphicsgridlayout.cpp
parent17fbbdd3a081a66e1d2b26db7935111c49cea75e (diff)
downloadqt4-tools-183abff6ffcb020b8f0c4041cc82bba0d3b03863.tar.gz
Fixed problem with wrong size hints when items were removed.
The reason was that the row/column count was not updated after an item was removed. (Note that qgraphicslinearlayout already did this, so we just follow the same pattern, except that the code for QGraphicsGridLayout is a bit more complex... Task-number: QTBUG-10314 Reviewed-by: Alexis Menard
Diffstat (limited to 'src/gui/graphicsview/qgraphicsgridlayout.cpp')
-rw-r--r--src/gui/graphicsview/qgraphicsgridlayout.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/gui/graphicsview/qgraphicsgridlayout.cpp b/src/gui/graphicsview/qgraphicsgridlayout.cpp
index 6ca799dc9c..83db3ec124 100644
--- a/src/gui/graphicsview/qgraphicsgridlayout.cpp
+++ b/src/gui/graphicsview/qgraphicsgridlayout.cpp
@@ -572,6 +572,18 @@ void QGraphicsGridLayout::removeAt(int index)
if (QGraphicsLayoutItem *layoutItem = gridItem->layoutItem())
layoutItem->setParentLayoutItem(0);
d->engine.removeItem(gridItem);
+
+ // recalculate rowInfo.count if we remove an item that is on the right/bottommost row
+ for (int j = 0; j < NOrientations; ++j) {
+ // 0: Hor, 1: Ver
+ const Qt::Orientation orient = (j == 0 ? Qt::Horizontal : Qt::Vertical);
+ const int oldCount = d->engine.rowCount(orient);
+ if (gridItem->lastRow(orient) == oldCount - 1) {
+ const int newCount = d->engine.effectiveLastRow(orient) + 1;
+ d->engine.removeRows(newCount, oldCount - newCount, orient);
+ }
+ }
+
delete gridItem;
invalidate();
}