summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEduardo M. Fleury <eduardo.fleury@openbossa.org>2009-07-09 18:12:29 (GMT)
committerEduardo M. Fleury <eduardo.fleury@openbossa.org>2009-07-22 18:04:54 (GMT)
commit22a6ce9b329a081d07296533980d374b0c7ad88b (patch)
treedf9fd2c5d3ea409f715eee60ae38e6a07f457c29
parent4419654149be34e646fdff4c4f2897292a129d33 (diff)
downloadQt-22a6ce9b329a081d07296533980d374b0c7ad88b.zip
Qt-22a6ce9b329a081d07296533980d374b0c7ad88b.tar.gz
Qt-22a6ce9b329a081d07296533980d374b0c7ad88b.tar.bz2
QGraphicsAnchorLayout: Do not create center anchors by default
Previously we would create two half anchors internally to each item added to the layout. These anchors are meant to enforce the central anchorage point remains on its position. It is not effecient however, to create these anchors for all items if not all of them will have anchors linked to their center. This commit removes the creation of center anchors, the idea is to postpone this to the moment their are really needed, therefore reducing the number of variables and constraints sent to the simplex solver on the average case. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org>
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.cpp36
1 files changed, 8 insertions, 28 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
index 9d145a2..1564163 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -487,42 +487,22 @@ void QGraphicsAnchorLayoutPrivate::createItemEdges(QGraphicsLayoutItem *item)
items.append(item);
// Horizontal
- int minimumSize = item->minimumWidth() / 2;
- int preferredSize = item->preferredWidth() / 2;
- int maximumSize = item->maximumWidth() / 2;
-
- QSimplexConstraint *c = new QSimplexConstraint;
+ int minimumSize = item->minimumWidth();
+ int preferredSize = item->preferredWidth();
+ int maximumSize = item->maximumWidth();
AnchorData *data = new AnchorData(minimumSize, preferredSize, maximumSize);
addAnchor(item, QGraphicsAnchorLayout::Left, item,
- QGraphicsAnchorLayout::HCenter, data);
- c->variables.insert(data, 1.0);
-
- data = new AnchorData(minimumSize, preferredSize, maximumSize);
- addAnchor(item, QGraphicsAnchorLayout::HCenter,
- item, QGraphicsAnchorLayout::Right, data);
- c->variables.insert(data, -1.0);
-
- itemCenterConstraints[Horizontal].append(c);
+ QGraphicsAnchorLayout::Right, data);
// Vertical
- minimumSize = item->minimumHeight() / 2;
- preferredSize = item->preferredHeight() / 2;
- maximumSize = item->maximumHeight() / 2;
-
- c = new QSimplexConstraint;
+ minimumSize = item->minimumHeight();
+ preferredSize = item->preferredHeight();
+ maximumSize = item->maximumHeight();
data = new AnchorData(minimumSize, preferredSize, maximumSize);
addAnchor(item, QGraphicsAnchorLayout::Top, item,
- QGraphicsAnchorLayout::VCenter, data);
- c->variables.insert(data, 1.0);
-
- data = new AnchorData(minimumSize, preferredSize, maximumSize);
- addAnchor(item, QGraphicsAnchorLayout::VCenter,
- item, QGraphicsAnchorLayout::Bottom, data);
- c->variables.insert(data, -1.0);
-
- itemCenterConstraints[Vertical].append(c);
+ QGraphicsAnchorLayout::Bottom, data);
}
void QGraphicsAnchorLayoutPrivate::removeCenterConstraints(QGraphicsLayoutItem *item,