summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
diff options
context:
space:
mode:
authorJan-Arve Sæther <jan-arve.saether@nokia.com>2009-08-19 13:47:18 (GMT)
committerJan-Arve Sæther <jan-arve.saether@nokia.com>2009-08-19 13:47:18 (GMT)
commit784bef39ca505e1e4a6f2ec6742183b7750b4f47 (patch)
treee1902a60a7732ffdf8d265a1320d7bf7d6e93251 /src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
parent14c6433781fb946aab6e7f77fd190469e5fcfb94 (diff)
downloadQt-784bef39ca505e1e4a6f2ec6742183b7750b4f47.zip
Qt-784bef39ca505e1e4a6f2ec6742183b7750b4f47.tar.gz
Qt-784bef39ca505e1e4a6f2ec6742183b7750b4f47.tar.bz2
Implement the functions we added in the API review:
Those are: * setAnchorSpacing() * anchorSpacing() * unsetAnchorSpacing() Autotests for the two last ones are missing though..
Diffstat (limited to 'src/gui/graphicsview/qgraphicsanchorlayout_p.cpp')
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.cpp40
1 files changed, 36 insertions, 4 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
index 436ce2c..ffece0d 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -1125,17 +1125,49 @@ bool QGraphicsAnchorLayoutPrivate::setAnchorSize(const QGraphicsLayoutItem *firs
Qt::AnchorPoint firstEdge,
const QGraphicsLayoutItem *secondItem,
Qt::AnchorPoint secondEdge,
- qreal anchorSize)
+ const qreal *anchorSize)
{
- // ### we can avoid restoration if we really want to
+ // ### we can avoid restoration if we really want to, but we would have to
+ // search recursively through all composite anchors
restoreSimplifiedGraph(edgeOrientation(firstEdge));
AnchorVertex *v1 = internalVertex(firstItem, firstEdge);
AnchorVertex *v2 = internalVertex(secondItem, secondEdge);
AnchorData *data = graph[edgeOrientation(firstEdge)].edgeData(v1, v2);
- if (data)
- data->setFixedSize(anchorSize);
+ if (data) {
+ if (anchorSize) {
+ data->setFixedSize(*anchorSize);
+ } else {
+ data->unsetSize();
+ }
+ }
+
+ return data;
+}
+bool QGraphicsAnchorLayoutPrivate::anchorSize(const QGraphicsLayoutItem *firstItem,
+ Qt::AnchorPoint firstEdge,
+ const QGraphicsLayoutItem *secondItem,
+ Qt::AnchorPoint secondEdge,
+ qreal *minSize,
+ qreal *prefSize,
+ qreal *maxSize) const
+{
+ Q_ASSERT(minSize || prefSize || maxSize);
+ QGraphicsAnchorLayoutPrivate *that = const_cast<QGraphicsAnchorLayoutPrivate *>(this);
+ that->restoreSimplifiedGraph(edgeOrientation(firstEdge));
+ AnchorVertex *v1 = internalVertex(firstItem, firstEdge);
+ AnchorVertex *v2 = internalVertex(secondItem, secondEdge);
+
+ AnchorData *data = that->graph[edgeOrientation(firstEdge)].edgeData(v1, v2);
+ if (data) {
+ if (minSize)
+ *minSize = data->minSize;
+ if (prefSize)
+ *prefSize = data->prefSize;
+ if (maxSize)
+ *maxSize = data->maxSize;
+ }
return data;
}