summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicsanchorlayout_p.h
diff options
context:
space:
mode:
authorEduardo M. Fleury <eduardo.fleury@openbossa.org>2009-11-10 19:55:43 (GMT)
committerEduardo M. Fleury <eduardo.fleury@openbossa.org>2009-11-12 21:35:27 (GMT)
commit6cc1703af1f403168b7251616a7685aa83de8caa (patch)
tree81d2c9fc31eb809e0095dc40d94ba21ceb85c374 /src/gui/graphicsview/qgraphicsanchorlayout_p.h
parentbf0e30ce2987a9e93369fe01ab0f01eeb1d3afdb (diff)
downloadQt-6cc1703af1f403168b7251616a7685aa83de8caa.zip
Qt-6cc1703af1f403168b7251616a7685aa83de8caa.tar.gz
Qt-6cc1703af1f403168b7251616a7685aa83de8caa.tar.bz2
QGAL: Move size information from AnchorData to QGraphicsAnchorPrivate
To solve the spacing persistency bug, this commit saves the preferredSize (spacing) information inside QGraphicsAnchorPrivate. The problem started when we could not rely on "AnchorData->prefSize" to keep the spacing information for user-defined anchors. This happens because that member can be overriden if the spacing is negative (anchor is inverted) or its sizePolicy is of type "Ignored" (it is overriden by minSize). Then, to decide where to store it, we aimed to make something similar to what happens with item-internal anchors. Those can rely on their items to get fresh information regarding their size, so we decided that user-anchors (that don't have items, but do have QGraphicsAnchors) could read such information from there. This refactory also reduced the deep indirection that existed in the "QGraphicsAnchor->setSpacing" call. Previously it would call internal layout methods to do some black magic, that's now gone. As the spacing information is now stored in the anchor itself, it can do pretty much all the work and, after that, just invalidate the layout. Also, moved information like "AnchorData->hasSize" to QGAnchor as its pretty much related to the preferredSize information itself. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
Diffstat (limited to 'src/gui/graphicsview/qgraphicsanchorlayout_p.h')
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.h25
1 files changed, 7 insertions, 18 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
index 26df109..cb8c4dd 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
@@ -126,7 +126,7 @@ struct AnchorData : public QSimplexVariable {
sizeAtMinimum(0), sizeAtPreferred(0),
sizeAtMaximum(0), item(0),
graphicsAnchor(0), skipInPreferred(0),
- type(Normal), hasSize(true), isLayoutAnchor(false),
+ type(Normal), isLayoutAnchor(false),
isCenterAnchor(false), orientation(0),
dependency(Independent) {}
@@ -141,17 +141,6 @@ struct AnchorData : public QSimplexVariable {
QString name;
#endif
- inline void setPreferredSize(qreal size)
- {
- prefSize = size;
- hasSize = true;
- }
-
- inline void unsetSize()
- {
- hasSize = false;
- }
-
// Anchor is semantically directed
AnchorVertex *from;
AnchorVertex *to;
@@ -182,7 +171,6 @@ struct AnchorData : public QSimplexVariable {
uint skipInPreferred : 1;
uint type : 2; // either Normal, Sequential or Parallel
- uint hasSize : 1; // if false, get size from style.
uint isLayoutAnchor : 1; // if this anchor is an internal layout anchor
uint isCenterAnchor : 1;
uint orientation : 1;
@@ -355,7 +343,13 @@ public:
QGraphicsAnchorLayoutPrivate *layoutPrivate;
AnchorData *data;
+
+ // Size information for user controlled anchor
QSizePolicy::Policy sizePolicy;
+ qreal preferredSize;
+
+ uint hasSize : 1; // if false, get size from style.
+ uint reversed : 1; // if true, the anchor was inverted to keep its value positive
};
@@ -450,11 +444,6 @@ public:
void removeAnchor(AnchorVertex *firstVertex, AnchorVertex *secondVertex);
void removeAnchor_helper(AnchorVertex *v1, AnchorVertex *v2);
- void setAnchorSize(AnchorData *data, const qreal *anchorSize);
- void anchorSize(const AnchorData *data,
- qreal *minSize = 0,
- qreal *prefSize = 0,
- qreal *maxSize = 0) const;
void removeAnchors(QGraphicsLayoutItem *item);