summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicsanchorlayout.h
diff options
context:
space:
mode:
authorJan-Arve Sæther <jan-arve.saether@nokia.com>2009-08-19 09:46:06 (GMT)
committerJan-Arve Sæther <jan-arve.saether@nokia.com>2009-08-19 09:46:06 (GMT)
commit14c6433781fb946aab6e7f77fd190469e5fcfb94 (patch)
tree4e42d59995885b6067c6e77dad6d6cad092ee048 /src/gui/graphicsview/qgraphicsanchorlayout.h
parent9da9e6f9bcead138297765b2782f73b68799827a (diff)
downloadQt-14c6433781fb946aab6e7f77fd190469e5fcfb94.zip
Qt-14c6433781fb946aab6e7f77fd190469e5fcfb94.tar.gz
Qt-14c6433781fb946aab6e7f77fd190469e5fcfb94.tar.bz2
update API to what was agreed on the API review meeting yesterday:
The changes are: * Move enums in QGraphicsAnchorLayout::Edge to Qt::AnchorPoint. Prefix them with Anchor since they are not edges in general. * Rename anchor() to addAnchor() * Rename anchorCorner() -> addCornerAnchors() * Rename anchorWidth() -> addLeftAndRightAnchors() * Rename anchorHeight() -> addTopAndBottomAnchors() * Rename anchorGeometry() -> addAllAnchors() * remove the overloads that take a spacing argument, and add setAnchorSpacing() to accommodate for that. * Added anchorSpacing() (implementation missing) * Added unsetAnchorSpacing(). (implementation missing) * made sizeHint() protected. Updated all examples and autotest to reflect this API change.
Diffstat (limited to 'src/gui/graphicsview/qgraphicsanchorlayout.h')
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout.h109
1 files changed, 32 insertions, 77 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.h b/src/gui/graphicsview/qgraphicsanchorlayout.h
index f0ffcbd..f2335a8 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout.h
+++ b/src/gui/graphicsview/qgraphicsanchorlayout.h
@@ -59,49 +59,35 @@ class QGraphicsAnchorLayoutPrivate;
class Q_GUI_EXPORT QGraphicsAnchorLayout : public QGraphicsLayout
{
public:
- enum Edge {
- Left = 0,
- HCenter,
- Right,
- Top,
- VCenter,
- Bottom
- };
-
QGraphicsAnchorLayout(QGraphicsLayoutItem *parent = 0);
virtual ~QGraphicsAnchorLayout();
- void anchor(QGraphicsLayoutItem *firstItem, Edge firstEdge,
- QGraphicsLayoutItem *secondItem, Edge secondEdge);
+ void addAnchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
+ QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge);
- void anchor(QGraphicsLayoutItem *firstItem, Edge firstEdge,
- QGraphicsLayoutItem *secondItem, Edge secondEdge,
- qreal spacing);
+ void setAnchorSpacing(const QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
+ const QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge,
+ qreal spacing);
- void anchorCorner(QGraphicsLayoutItem *firstItem, Qt::Corner firstCorner,
- QGraphicsLayoutItem *secondItem, Qt::Corner secondCorner);
+ void addCornerAnchors(QGraphicsLayoutItem *firstItem, Qt::Corner firstCorner,
+ QGraphicsLayoutItem *secondItem, Qt::Corner secondCorner);
- void anchorCorner(QGraphicsLayoutItem *firstItem, Qt::Corner firstCorner,
- QGraphicsLayoutItem *secondItem, Qt::Corner secondCorner,
- qreal spacing);
+ inline void addLeftAndRightAnchors(QGraphicsLayoutItem *firstItem,
+ QGraphicsLayoutItem *secondItem);
- void removeAnchor(QGraphicsLayoutItem *firstItem, Edge firstEdge,
- QGraphicsLayoutItem *secondItem, Edge secondEdge);
+ inline void addTopAndBottomAnchors(QGraphicsLayoutItem *firstItem,
+ QGraphicsLayoutItem *secondItem);
- inline void anchorWidth(QGraphicsLayoutItem *item,
- QGraphicsLayoutItem *relativeTo = 0);
- inline void anchorWidth(QGraphicsLayoutItem *item,
- QGraphicsLayoutItem *relativeTo, qreal spacing);
+ inline void addAllAnchors(QGraphicsLayoutItem *firstItem,
+ QGraphicsLayoutItem *secondItem);
- inline void anchorHeight(QGraphicsLayoutItem *item,
- QGraphicsLayoutItem *relativeTo = 0);
- inline void anchorHeight(QGraphicsLayoutItem *item,
- QGraphicsLayoutItem *relativeTo, 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);
- inline void anchorGeometry(QGraphicsLayoutItem *item,
- QGraphicsLayoutItem *relativeTo = 0);
- inline void anchorGeometry(QGraphicsLayoutItem *item,
- QGraphicsLayoutItem *relativeTo, qreal spacing);
+ void removeAnchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
+ QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge);
void setHorizontalSpacing(qreal spacing);
void setVerticalSpacing(qreal spacing);
@@ -115,6 +101,7 @@ public:
QGraphicsLayoutItem *itemAt(int index) const;
void invalidate();
+protected:
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
private:
@@ -122,58 +109,26 @@ private:
Q_DECLARE_PRIVATE(QGraphicsAnchorLayout)
};
-void QGraphicsAnchorLayout::anchorWidth(QGraphicsLayoutItem *item,
- QGraphicsLayoutItem *relativeTo)
-{
- if (!relativeTo)
- relativeTo = this;
-
- anchor(relativeTo, Left, item, Left);
- anchor(item, Right, relativeTo, Right);
-}
-
-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;
-
- anchor(relativeTo, Top, item, Top);
- anchor(item, Bottom, relativeTo, Bottom);
-}
-void QGraphicsAnchorLayout::anchorHeight(QGraphicsLayoutItem *item,
- QGraphicsLayoutItem *relativeTo,
- qreal spacing)
+void QGraphicsAnchorLayout::addLeftAndRightAnchors(QGraphicsLayoutItem *firstItem,
+ QGraphicsLayoutItem *secondItem)
{
- anchor(relativeTo, Top, item, Top, spacing);
- anchor(item, Bottom, relativeTo, Bottom, spacing);
+ addAnchor(secondItem, Qt::AnchorLeft, firstItem, Qt::AnchorLeft);
+ addAnchor(firstItem, Qt::AnchorRight, secondItem, Qt::AnchorRight);
}
-void QGraphicsAnchorLayout::anchorGeometry(QGraphicsLayoutItem *item,
- QGraphicsLayoutItem *relativeTo)
+void QGraphicsAnchorLayout::addTopAndBottomAnchors(QGraphicsLayoutItem *firstItem,
+ QGraphicsLayoutItem *secondItem)
{
- if (!relativeTo)
- relativeTo = this;
-
- anchorWidth(item, relativeTo);
- anchorHeight(item, relativeTo);
+ addAnchor(secondItem, Qt::AnchorTop, firstItem, Qt::AnchorTop);
+ addAnchor(firstItem, Qt::AnchorBottom, secondItem, Qt::AnchorBottom);
}
-void QGraphicsAnchorLayout::anchorGeometry(QGraphicsLayoutItem *item,
- QGraphicsLayoutItem *relativeTo,
- qreal spacing)
+void QGraphicsAnchorLayout::addAllAnchors(QGraphicsLayoutItem *firstItem,
+ QGraphicsLayoutItem *secondItem)
{
- anchorWidth(item, relativeTo, spacing);
- anchorHeight(item, relativeTo, spacing);
+ addLeftAndRightAnchors(firstItem, secondItem);
+ addTopAndBottomAnchors(firstItem, secondItem);
}
#endif