diff options
author | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2009-09-11 10:34:08 (GMT) |
---|---|---|
committer | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2009-09-14 12:22:01 (GMT) |
commit | 89620720e9969360254f950fc63d131d82dd3471 (patch) | |
tree | 1117641c58ac7810549647e01ac26d5ab4845029 /src/gui/graphicsview/qgraphicsanchorlayout.h | |
parent | 41dbc4406791f82b7e3c1385acc594e22b5b0799 (diff) | |
download | Qt-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.h')
-rw-r--r-- | src/gui/graphicsview/qgraphicsanchorlayout.h | 73 |
1 files changed, 28 insertions, 45 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.h b/src/gui/graphicsview/qgraphicsanchorlayout.h index 70b73ef..d9a87ba 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout.h @@ -54,41 +54,44 @@ QT_MODULE(Gui) #if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW +class QGraphicsAnchorPrivate; +class QGraphicsAnchorLayout; class QGraphicsAnchorLayoutPrivate; +class Q_GUI_EXPORT QGraphicsAnchor : public QObject +{ + Q_OBJECT + Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing) +public: + void setSpacing(qreal spacing); + void unsetSpacing(); + qreal spacing() const; + ~QGraphicsAnchor(); +private: + QGraphicsAnchor(QGraphicsAnchorLayout *parent); + + Q_DECLARE_PRIVATE(QGraphicsAnchor) + + friend class QGraphicsAnchorLayoutPrivate; +}; + class Q_GUI_EXPORT QGraphicsAnchorLayout : public QGraphicsLayout { public: QGraphicsAnchorLayout(QGraphicsLayoutItem *parent = 0); virtual ~QGraphicsAnchorLayout(); - void addAnchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge, - QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge); + QGraphicsAnchor *addAnchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge, + QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge); + QGraphicsAnchor *anchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge, + QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge); void addCornerAnchors(QGraphicsLayoutItem *firstItem, Qt::Corner firstCorner, QGraphicsLayoutItem *secondItem, Qt::Corner secondCorner); - inline void addLeftAndRightAnchors(QGraphicsLayoutItem *firstItem, - QGraphicsLayoutItem *secondItem); - - inline void addTopAndBottomAnchors(QGraphicsLayoutItem *firstItem, - QGraphicsLayoutItem *secondItem); - - inline void addAllAnchors(QGraphicsLayoutItem *firstItem, - QGraphicsLayoutItem *secondItem); - - void setAnchorSpacing(const QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge, - const QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge, - qreal spacing); - - qreal anchorSpacing(const QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge, - const QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge) const; - - void unsetAnchorSpacing(const QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge, - const QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge); - - void removeAnchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge, - QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge); + void addAnchors(QGraphicsLayoutItem *firstItem, + QGraphicsLayoutItem *secondItem, + Qt::Orientations orientations = Qt::Horizontal | Qt::Vertical); void setHorizontalSpacing(qreal spacing); void setVerticalSpacing(qreal spacing); @@ -108,29 +111,9 @@ protected: private: Q_DISABLE_COPY(QGraphicsAnchorLayout) Q_DECLARE_PRIVATE(QGraphicsAnchorLayout) -}; - -void QGraphicsAnchorLayout::addLeftAndRightAnchors(QGraphicsLayoutItem *firstItem, - QGraphicsLayoutItem *secondItem) -{ - addAnchor(secondItem, Qt::AnchorLeft, firstItem, Qt::AnchorLeft); - addAnchor(firstItem, Qt::AnchorRight, secondItem, Qt::AnchorRight); -} - -void QGraphicsAnchorLayout::addTopAndBottomAnchors(QGraphicsLayoutItem *firstItem, - QGraphicsLayoutItem *secondItem) -{ - addAnchor(secondItem, Qt::AnchorTop, firstItem, Qt::AnchorTop); - addAnchor(firstItem, Qt::AnchorBottom, secondItem, Qt::AnchorBottom); -} - -void QGraphicsAnchorLayout::addAllAnchors(QGraphicsLayoutItem *firstItem, - QGraphicsLayoutItem *secondItem) -{ - addLeftAndRightAnchors(firstItem, secondItem); - addTopAndBottomAnchors(firstItem, secondItem); -} + friend class QGraphicsAnchor; +}; #endif |