diff options
author | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2009-08-19 09:46:06 (GMT) |
---|---|---|
committer | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2009-08-19 09:46:06 (GMT) |
commit | 14c6433781fb946aab6e7f77fd190469e5fcfb94 (patch) | |
tree | 4e42d59995885b6067c6e77dad6d6cad092ee048 /src/gui/graphicsview/qgraphicsanchorlayout_p.h | |
parent | 9da9e6f9bcead138297765b2782f73b68799827a (diff) | |
download | Qt-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_p.h')
-rw-r--r-- | src/gui/graphicsview/qgraphicsanchorlayout_p.h | 83 |
1 files changed, 50 insertions, 33 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h index 7e7cee8..742108d 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h @@ -48,7 +48,7 @@ /* The public QGraphicsAnchorLayout interface represents an anchorage point - as a pair of a <QGraphicsLayoutItem *> and a <QGraphicsAnchorLayout::Edge>. + as a pair of a <QGraphicsLayoutItem *> and a <Qt::AnchorPoint>. Internally though, it has a graph of anchorage points (vertices) and anchors (edges), represented by the AnchorVertex and AnchorData structs @@ -61,17 +61,17 @@ Represents a vertex (anchorage point) in the internal graph */ struct AnchorVertex { - AnchorVertex(QGraphicsLayoutItem *item, QGraphicsAnchorLayout::Edge edge) + AnchorVertex(QGraphicsLayoutItem *item, Qt::AnchorPoint edge) : m_item(item), m_edge(edge) {} AnchorVertex() - : m_item(0), m_edge(QGraphicsAnchorLayout::Edge(0)) {} + : m_item(0), m_edge(Qt::AnchorPoint(0)) {} #ifdef QT_DEBUG inline QString toString() const; #endif QGraphicsLayoutItem *m_item; - QGraphicsAnchorLayout::Edge m_edge; + Qt::AnchorPoint m_edge; // Current distance from this vertex to the layout edge (Left or Top) // Value is calculated from the current anchors sizes. @@ -86,22 +86,22 @@ inline QString AnchorVertex::toString() const } QString edge; switch (m_edge) { - case QGraphicsAnchorLayout::Left: + case Qt::AnchorLeft: edge = QLatin1String("Left"); break; - case QGraphicsAnchorLayout::HCenter: + case Qt::AnchorHorizontalCenter: edge = QLatin1String("HorizontalCenter"); break; - case QGraphicsAnchorLayout::Right: + case Qt::AnchorRight: edge = QLatin1String("Right"); break; - case QGraphicsAnchorLayout::Top: + case Qt::AnchorTop: edge = QLatin1String("Top"); break; - case QGraphicsAnchorLayout::VCenter: + case Qt::AnchorVerticalCenter: edge = QLatin1String("VerticalCenter"); break; - case QGraphicsAnchorLayout::Bottom: + case Qt::AnchorBottom: edge = QLatin1String("Bottom"); break; default: @@ -165,6 +165,17 @@ struct AnchorData : public QSimplexVariable { QString name; #endif + inline void setFixedSize(qreal size) + { + minSize = size; + prefSize = size; + maxSize = size; + sizeAtMinimum = size; + sizeAtPreferred = size; + sizeAtMaximum = size; + hasSize = true; + } + // Anchor is semantically directed AnchorVertex *from; AnchorVertex *to; @@ -310,17 +321,17 @@ public: QGraphicsAnchorLayoutPrivate(); - static QGraphicsAnchorLayout::Edge oppositeEdge( - QGraphicsAnchorLayout::Edge edge); + static Qt::AnchorPoint oppositeEdge( + Qt::AnchorPoint edge); - static Orientation edgeOrientation(QGraphicsAnchorLayout::Edge edge); + static Orientation edgeOrientation(Qt::AnchorPoint edge); - static QGraphicsAnchorLayout::Edge pickEdge(QGraphicsAnchorLayout::Edge edge, Orientation orientation) + static Qt::AnchorPoint pickEdge(Qt::AnchorPoint edge, Orientation orientation) { if (orientation == Vertical && int(edge) <= 2) - return (QGraphicsAnchorLayout::Edge)(edge + 3); + return (Qt::AnchorPoint)(edge + 3); else if (orientation == Horizontal && int(edge) >= 3) { - return (QGraphicsAnchorLayout::Edge)(edge - 3); + return (Qt::AnchorPoint)(edge - 3); } return edge; } @@ -329,37 +340,43 @@ public: void createLayoutEdges(); void deleteLayoutEdges(); void createItemEdges(QGraphicsLayoutItem *item); - void createCenterAnchors(QGraphicsLayoutItem *item, QGraphicsAnchorLayout::Edge centerEdge); - void removeCenterAnchors(QGraphicsLayoutItem *item, QGraphicsAnchorLayout::Edge centerEdge, bool substitute = true); + void createCenterAnchors(QGraphicsLayoutItem *item, Qt::AnchorPoint centerEdge); + void removeCenterAnchors(QGraphicsLayoutItem *item, Qt::AnchorPoint centerEdge, bool substitute = true); void removeCenterConstraints(QGraphicsLayoutItem *item, Orientation orientation); // helper function used by the 4 API functions void anchor(QGraphicsLayoutItem *firstItem, - QGraphicsAnchorLayout::Edge firstEdge, + Qt::AnchorPoint firstEdge, QGraphicsLayoutItem *secondItem, - QGraphicsAnchorLayout::Edge secondEdge, + Qt::AnchorPoint secondEdge, qreal *spacing = 0); // Anchor Manipulation methods void addAnchor(QGraphicsLayoutItem *firstItem, - QGraphicsAnchorLayout::Edge firstEdge, + Qt::AnchorPoint firstEdge, QGraphicsLayoutItem *secondItem, - QGraphicsAnchorLayout::Edge secondEdge, + Qt::AnchorPoint secondEdge, AnchorData *data); void removeAnchor(QGraphicsLayoutItem *firstItem, - QGraphicsAnchorLayout::Edge firstEdge, + Qt::AnchorPoint firstEdge, QGraphicsLayoutItem *secondItem, - QGraphicsAnchorLayout::Edge secondEdge); + Qt::AnchorPoint secondEdge); + + bool setAnchorSize(const QGraphicsLayoutItem *firstItem, + Qt::AnchorPoint firstEdge, + const QGraphicsLayoutItem *secondItem, + Qt::AnchorPoint secondEdge, + qreal anchorSize); void removeAnchors(QGraphicsLayoutItem *item); - void removeVertex(QGraphicsLayoutItem *item, QGraphicsAnchorLayout::Edge edge); + void removeVertex(QGraphicsLayoutItem *item, Qt::AnchorPoint edge); void correctEdgeDirection(QGraphicsLayoutItem *&firstItem, - QGraphicsAnchorLayout::Edge &firstEdge, + Qt::AnchorPoint &firstEdge, QGraphicsLayoutItem *&secondItem, - QGraphicsAnchorLayout::Edge &secondEdge); + Qt::AnchorPoint &secondEdge); // for getting the actual spacing (will query the style if the // spacing is not explicitly set). qreal effectiveSpacing(Orientation orientation) const; @@ -377,18 +394,18 @@ public: QList<QSimplexConstraint *> constraintsFromSizeHints(const QList<AnchorData *> &anchors); QList<QList<QSimplexConstraint *> > getGraphParts(Orientation orientation); - inline AnchorVertex *internalVertex(const QPair<QGraphicsLayoutItem*, QGraphicsAnchorLayout::Edge> &itemEdge) + inline AnchorVertex *internalVertex(const QPair<QGraphicsLayoutItem*, Qt::AnchorPoint> &itemEdge) { return m_vertexList.value(itemEdge).first; } - inline AnchorVertex *internalVertex(QGraphicsLayoutItem *item, QGraphicsAnchorLayout::Edge edge) + inline AnchorVertex *internalVertex(const QGraphicsLayoutItem *item, Qt::AnchorPoint edge) { - return internalVertex(qMakePair(item, edge)); + return internalVertex(qMakePair(const_cast<QGraphicsLayoutItem *>(item), edge)); } - AnchorVertex *addInternalVertex(QGraphicsLayoutItem *item, QGraphicsAnchorLayout::Edge edge); - void removeInternalVertex(QGraphicsLayoutItem *item, QGraphicsAnchorLayout::Edge edge); + AnchorVertex *addInternalVertex(QGraphicsLayoutItem *item, Qt::AnchorPoint edge); + void removeInternalVertex(QGraphicsLayoutItem *item, Qt::AnchorPoint edge); // Geometry interpolation methods void setItemsGeometries(); @@ -421,7 +438,7 @@ public: // Mapping between high level anchorage points (Item, Edge) to low level // ones (Graph Vertices) - QHash<QPair<QGraphicsLayoutItem*, QGraphicsAnchorLayout::Edge>, QPair<AnchorVertex *, int> > m_vertexList; + QHash<QPair<QGraphicsLayoutItem*, Qt::AnchorPoint>, QPair<AnchorVertex *, int> > m_vertexList; // Internal graph of anchorage points and anchors, for both orientations Graph<AnchorVertex, AnchorData> graph[2]; |