summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEduardo M. Fleury <eduardo.fleury@openbossa.org>2009-06-23 13:45:49 (GMT)
committerEduardo M. Fleury <eduardo.fleury@openbossa.org>2009-07-22 18:04:33 (GMT)
commitd3d455e6d019a381b338c24b3c2593b2e12215cb (patch)
tree11d061893646b7bce599d08bbb90a9304846123f /src
parent92bca69c15898dd504f96e18227a22566038154a (diff)
downloadQt-d3d455e6d019a381b338c24b3c2593b2e12215cb.zip
Qt-d3d455e6d019a381b338c24b3c2593b2e12215cb.tar.gz
Qt-d3d455e6d019a381b338c24b3c2593b2e12215cb.tar.bz2
QGraphicsAnchorLayout: Add convencience "fill" methods
Adding "fillWidth()", "fillHeight()" and "fill()". These convenience methods simplify the creation of anchor setups where some items are meant to use the full width and/or height of the layout. For instance, instead of creating four anchors (bottom, top, left, right) between an item and the layout, to make it use the full layout area, the user can call layout->fill(item). It is also possible to make an item assume the same width or height of another item, calling layout->fill(firstItem, secondItem). Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
Diffstat (limited to 'src')
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.h b/src/gui/graphicsview/qgraphicsanchorlayout.h
index cd1c080..74075ff 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout.h
+++ b/src/gui/graphicsview/qgraphicsanchorlayout.h
@@ -78,6 +78,13 @@ public:
void removeAnchor(QGraphicsLayoutItem *firstItem, Edge firstEdge,
QGraphicsLayoutItem *secondItem, Edge secondEdge);
+ inline void fillWidth(QGraphicsLayoutItem *item,
+ QGraphicsLayoutItem *relativeTo = 0);
+ inline void fillHeight(QGraphicsLayoutItem *item,
+ QGraphicsLayoutItem *relativeTo = 0);
+ inline void fill(QGraphicsLayoutItem *item,
+ QGraphicsLayoutItem *relativeTo = 0);
+
void setSpacing(qreal spacing, Qt::Orientations orientations = Qt::Horizontal|Qt::Vertical);
qreal spacing(Qt::Orientation) const;
@@ -98,6 +105,35 @@ private:
Q_DECLARE_PRIVATE(QGraphicsAnchorLayout)
};
+void QGraphicsAnchorLayout::fillWidth(QGraphicsLayoutItem *item,
+ QGraphicsLayoutItem *relativeTo)
+{
+ if (!relativeTo)
+ relativeTo = this;
+
+ anchor(relativeTo, Left, item, Left);
+ anchor(item, Right, relativeTo, Right);
+}
+
+void QGraphicsAnchorLayout::fillHeight(QGraphicsLayoutItem *item,
+ QGraphicsLayoutItem *relativeTo)
+{
+ if (!relativeTo)
+ relativeTo = this;
+
+ anchor(relativeTo, Top, item, Top);
+ anchor(item, Bottom, relativeTo, Bottom);
+}
+
+void QGraphicsAnchorLayout::fill(QGraphicsLayoutItem *item,
+ QGraphicsLayoutItem *relativeTo)
+{
+ if (!relativeTo)
+ relativeTo = this;
+
+ fillWidth(item, relativeTo);
+ fillHeight(item, relativeTo);
+}
#endif