summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicsanchorlayout_p.h
diff options
context:
space:
mode:
authorJan-Arve Sæther <jan-arve.saether@nokia.com>2009-09-11 10:34:08 (GMT)
committerJan-Arve Sæther <jan-arve.saether@nokia.com>2009-09-14 12:22:01 (GMT)
commit89620720e9969360254f950fc63d131d82dd3471 (patch)
tree1117641c58ac7810549647e01ac26d5ab4845029 /src/gui/graphicsview/qgraphicsanchorlayout_p.h
parent41dbc4406791f82b7e3c1385acc594e22b5b0799 (diff)
downloadQt-89620720e9969360254f950fc63d131d82dd3471.zip
Qt-89620720e9969360254f950fc63d131d82dd3471.tar.gz
Qt-89620720e9969360254f950fc63d131d82dd3471.tar.bz2
API change. This will get rid of the ugly setAnchorSpacing() method.
Say hello to QGraphicsAnchor, move the spacing (and removeAnchor) functionality over to that class. This also opens up for a cleaner API when we add support for size policies or min/pref/max sizes for anchors. Also remove - addLeftAndRightAnchors() - addTopAndBottomAnchors() - addAllAnchors() in favor of - addAnchors(itemA, itemB, Qt::Orientations) API change discussed with Caio and Andreas. Reviewed-by: Alexis
Diffstat (limited to 'src/gui/graphicsview/qgraphicsanchorlayout_p.h')
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.h66
1 files changed, 50 insertions, 16 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
index 31da1a1..f701c3f 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
@@ -54,6 +54,7 @@
//
#include <QGraphicsWidget>
+#include <private/qobject_p.h>
#include "qgraphicslayout_p.h"
#include "qgraphicsanchorlayout.h"
@@ -153,6 +154,7 @@ struct AnchorData : public QSimplexVariable {
minSize(minimumSize), prefSize(preferredSize),
maxSize(maximumSize), sizeAtMinimum(preferredSize),
sizeAtPreferred(preferredSize), sizeAtMaximum(preferredSize),
+ graphicsAnchor(0),
skipInPreferred(0), type(Normal), hasSize(true),
isLayoutAnchor(false) {}
@@ -160,6 +162,7 @@ struct AnchorData : public QSimplexVariable {
: QSimplexVariable(), from(0), to(0),
minSize(size), prefSize(size), maxSize(size),
sizeAtMinimum(size), sizeAtPreferred(size), sizeAtMaximum(size),
+ graphicsAnchor(0),
skipInPreferred(0), type(Normal), hasSize(true),
isLayoutAnchor(false) {}
@@ -167,6 +170,7 @@ struct AnchorData : public QSimplexVariable {
: QSimplexVariable(), from(0), to(0),
minSize(0), prefSize(0), maxSize(0),
sizeAtMinimum(0), sizeAtPreferred(0), sizeAtMaximum(0),
+ graphicsAnchor(0),
skipInPreferred(0), type(Normal), hasSize(false),
isLayoutAnchor(false) {}
@@ -215,6 +219,7 @@ struct AnchorData : public QSimplexVariable {
qreal sizeAtMinimum;
qreal sizeAtPreferred;
qreal sizeAtMaximum;
+ QGraphicsAnchor *graphicsAnchor;
uint skipInPreferred : 1;
uint type : 2; // either Normal, Sequential or Parallel
@@ -226,6 +231,7 @@ protected:
minSize(size), prefSize(size),
maxSize(size), sizeAtMinimum(size),
sizeAtPreferred(size), sizeAtMaximum(size),
+ graphicsAnchor(0),
skipInPreferred(0), type(type), hasSize(true),
isLayoutAnchor(false) {}
};
@@ -309,6 +315,28 @@ public:
QSet<AnchorData *> negatives;
};
+class QGraphicsAnchorLayoutPrivate;
+/*!
+ \internal
+*/
+class QGraphicsAnchorPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QGraphicsAnchor)
+
+public:
+ explicit QGraphicsAnchorPrivate(int version = QObjectPrivateVersion);
+ ~QGraphicsAnchorPrivate();
+
+ void setSpacing(qreal value);
+ void unsetSpacing();
+ qreal spacing() const;
+
+ QGraphicsAnchorLayoutPrivate *layoutPrivate;
+ AnchorData *data;
+};
+
+
+
/*!
\internal
@@ -365,12 +393,22 @@ public:
void removeCenterAnchors(QGraphicsLayoutItem *item, Qt::AnchorPoint centerEdge, bool substitute = true);
void removeCenterConstraints(QGraphicsLayoutItem *item, Orientation orientation);
+ QGraphicsAnchor *acquireGraphicsAnchor(AnchorData *data)
+ {
+ Q_Q(QGraphicsAnchorLayout);
+ if (!data->graphicsAnchor) {
+ data->graphicsAnchor = new QGraphicsAnchor(q);
+ data->graphicsAnchor->d_func()->data = data;
+ }
+ return data->graphicsAnchor;
+ }
+
// helper function used by the 4 API functions
- void anchor(QGraphicsLayoutItem *firstItem,
- Qt::AnchorPoint firstEdge,
- QGraphicsLayoutItem *secondItem,
- Qt::AnchorPoint secondEdge,
- qreal *spacing = 0);
+ QGraphicsAnchor *anchor(QGraphicsLayoutItem *firstItem,
+ Qt::AnchorPoint firstEdge,
+ QGraphicsLayoutItem *secondItem,
+ Qt::AnchorPoint secondEdge,
+ qreal *spacing = 0);
// Anchor Manipulation methods
void addAnchor(QGraphicsLayoutItem *firstItem,
@@ -379,21 +417,17 @@ public:
Qt::AnchorPoint secondEdge,
AnchorData *data);
+ QGraphicsAnchor *getAnchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
+ QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge);
+
void removeAnchor(QGraphicsLayoutItem *firstItem,
Qt::AnchorPoint firstEdge,
QGraphicsLayoutItem *secondItem,
Qt::AnchorPoint secondEdge);
-
- bool setAnchorSize(const QGraphicsLayoutItem *firstItem,
- Qt::AnchorPoint firstEdge,
- const QGraphicsLayoutItem *secondItem,
- Qt::AnchorPoint secondEdge,
- const qreal *anchorSize);
-
- bool anchorSize(const QGraphicsLayoutItem *firstItem,
- Qt::AnchorPoint firstEdge,
- const QGraphicsLayoutItem *secondItem,
- Qt::AnchorPoint secondEdge,
+ void removeAnchor_helper(AnchorVertex *v1, AnchorVertex *v2);
+ void deleteAnchorData(AnchorData *data);
+ void setAnchorSize(AnchorData *data, const qreal *anchorSize);
+ void anchorSize(const AnchorData *data,
qreal *minSize = 0,
qreal *prefSize = 0,
qreal *maxSize = 0) const;