diff options
author | Artur Duque de Souza <artur.souza@openbossa.org> | 2009-08-12 14:33:14 (GMT) |
---|---|---|
committer | Artur Duque de Souza <artur.souza@openbossa.org> | 2009-08-12 14:33:46 (GMT) |
commit | ae67fcb0538c0f47c77eef0ed39955e33671343e (patch) | |
tree | ebf3f0cb430a0222425b9f36a0e97df7fe3d4442 | |
parent | 489685ef0724c852d964504853b86be39bddc7de (diff) | |
download | Qt-ae67fcb0538c0f47c77eef0ed39955e33671343e.zip Qt-ae67fcb0538c0f47c77eef0ed39955e33671343e.tar.gz Qt-ae67fcb0538c0f47c77eef0ed39955e33671343e.tar.bz2 |
Update Anchor Layout API
More user friendly API for anchor layouts. Changed method names
and also provided more methods to receive spacing.
Signed-off-by: Artur Duque de Souza <artur.souza@openbossa.org>
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
-rw-r--r-- | src/gui/graphicsview/qgraphicsanchorlayout.cpp | 16 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsanchorlayout.h | 70 |
2 files changed, 59 insertions, 27 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.cpp b/src/gui/graphicsview/qgraphicsanchorlayout.cpp index 6360e75..902f0b2 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout.cpp @@ -131,10 +131,10 @@ void QGraphicsAnchorLayout::anchor(QGraphicsLayoutItem *firstItem, * \a firstItem and \a secondItem are automatically added to the layout if they are not part * of the layout. This means that count() can increase with up to 2. */ -void QGraphicsAnchorLayout::anchor(QGraphicsLayoutItem *firstItem, - Qt::Corner firstCorner, - QGraphicsLayoutItem *secondItem, - Qt::Corner secondCorner) +void QGraphicsAnchorLayout::anchorCorner(QGraphicsLayoutItem *firstItem, + Qt::Corner firstCorner, + QGraphicsLayoutItem *secondItem, + Qt::Corner secondCorner) { Q_D(QGraphicsAnchorLayout); @@ -157,10 +157,10 @@ void QGraphicsAnchorLayout::anchor(QGraphicsLayoutItem *firstItem, * By calling this function the caller can specify the magnitude of the anchor with \a spacing. * */ -void QGraphicsAnchorLayout::anchor(QGraphicsLayoutItem *firstItem, - Qt::Corner firstCorner, - QGraphicsLayoutItem *secondItem, - Qt::Corner secondCorner, qreal spacing) +void QGraphicsAnchorLayout::anchorCorner(QGraphicsLayoutItem *firstItem, + Qt::Corner firstCorner, + QGraphicsLayoutItem *secondItem, + Qt::Corner secondCorner, qreal spacing) { Q_D(QGraphicsAnchorLayout); diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.h b/src/gui/graphicsview/qgraphicsanchorlayout.h index 1f622eb..249996e 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout.h @@ -78,22 +78,30 @@ public: QGraphicsLayoutItem *secondItem, Edge secondEdge, qreal spacing); - void anchor(QGraphicsLayoutItem *firstItem, Qt::Corner firstCorner, - QGraphicsLayoutItem *secondItem, Qt::Corner secondCorner); + void anchorCorner(QGraphicsLayoutItem *firstItem, Qt::Corner firstCorner, + QGraphicsLayoutItem *secondItem, Qt::Corner secondCorner); - void anchor(QGraphicsLayoutItem *firstItem, Qt::Corner firstCorner, - QGraphicsLayoutItem *secondItem, Qt::Corner secondCorner, - qreal spacing); + void anchorCorner(QGraphicsLayoutItem *firstItem, Qt::Corner firstCorner, + QGraphicsLayoutItem *secondItem, Qt::Corner secondCorner, + qreal spacing); 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); + inline void anchorWidth(QGraphicsLayoutItem *item, + QGraphicsLayoutItem *relativeTo = 0); + inline void anchorWidth(QGraphicsLayoutItem *item, + QGraphicsLayoutItem *relativeTo, qreal spacing); + + inline void anchorHeight(QGraphicsLayoutItem *item, + QGraphicsLayoutItem *relativeTo = 0); + inline void anchorHeight(QGraphicsLayoutItem *item, + QGraphicsLayoutItem *relativeTo, qreal spacing); + + inline void anchorGeometry(QGraphicsLayoutItem *item, + QGraphicsLayoutItem *relativeTo = 0); + inline void anchorGeometry(QGraphicsLayoutItem *item, + QGraphicsLayoutItem *relativeTo, qreal spacing); void setSpacing(qreal spacing, Qt::Orientations orientations = Qt::Horizontal|Qt::Vertical); qreal spacing(Qt::Orientation) const; @@ -115,8 +123,8 @@ private: Q_DECLARE_PRIVATE(QGraphicsAnchorLayout) }; -void QGraphicsAnchorLayout::fillWidth(QGraphicsLayoutItem *item, - QGraphicsLayoutItem *relativeTo) +void QGraphicsAnchorLayout::anchorWidth(QGraphicsLayoutItem *item, + QGraphicsLayoutItem *relativeTo) { if (!relativeTo) relativeTo = this; @@ -125,8 +133,16 @@ void QGraphicsAnchorLayout::fillWidth(QGraphicsLayoutItem *item, anchor(item, Right, relativeTo, Right); } -void QGraphicsAnchorLayout::fillHeight(QGraphicsLayoutItem *item, - QGraphicsLayoutItem *relativeTo) +void QGraphicsAnchorLayout::anchorWidth(QGraphicsLayoutItem *item, + QGraphicsLayoutItem *relativeTo, + qreal spacing) +{ + anchor(relativeTo, Left, item, Left, spacing); + anchor(item, Right, relativeTo, Right, spacing); +} + +void QGraphicsAnchorLayout::anchorHeight(QGraphicsLayoutItem *item, + QGraphicsLayoutItem *relativeTo) { if (!relativeTo) relativeTo = this; @@ -135,14 +151,30 @@ void QGraphicsAnchorLayout::fillHeight(QGraphicsLayoutItem *item, anchor(item, Bottom, relativeTo, Bottom); } -void QGraphicsAnchorLayout::fill(QGraphicsLayoutItem *item, - QGraphicsLayoutItem *relativeTo) +void QGraphicsAnchorLayout::anchorHeight(QGraphicsLayoutItem *item, + QGraphicsLayoutItem *relativeTo, + qreal spacing) +{ + anchor(relativeTo, Top, item, Top, spacing); + anchor(item, Bottom, relativeTo, Bottom, spacing); +} + +void QGraphicsAnchorLayout::anchorGeometry(QGraphicsLayoutItem *item, + QGraphicsLayoutItem *relativeTo) { if (!relativeTo) relativeTo = this; - fillWidth(item, relativeTo); - fillHeight(item, relativeTo); + anchorWidth(item, relativeTo); + anchorHeight(item, relativeTo); +} + +void QGraphicsAnchorLayout::anchorGeometry(QGraphicsLayoutItem *item, + QGraphicsLayoutItem *relativeTo, + qreal spacing) +{ + anchorWidth(item, relativeTo, spacing); + anchorHeight(item, relativeTo, spacing); } #endif |