summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.cpp51
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.h3
2 files changed, 53 insertions, 1 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
index 8139b2b..e760642 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -1841,6 +1841,11 @@ void QGraphicsAnchorLayoutPrivate::findPaths(Orientation orientation)
queue.enqueue(qMakePair(pair.second, v));
}
}
+
+ // We will walk through every reachable items (non-float) and mark them
+ // by keeping their references on m_nonFloatItems. With this we can easily
+ // identify non-float and float items.
+ identifyNonFloatItems(visited, orientation);
}
/*!
@@ -1999,6 +2004,46 @@ QGraphicsAnchorLayoutPrivate::getGraphParts(Orientation orientation)
}
/*!
+ \internal
+
+ Use all visited Anchors on findPaths() so we can identify non-float Items.
+*/
+void QGraphicsAnchorLayoutPrivate::identifyNonFloatItems(QSet<AnchorData *> visited, Orientation orientation)
+{
+ m_nonFloatItems[orientation].clear();
+
+ foreach (const AnchorData *ad, visited)
+ identifyNonFloatItems_helper(ad, orientation);
+}
+
+/*!
+ \internal
+
+ Given an anchor, if it is an internal anchor and Normal we must mark it's item as non-float.
+ If the anchor is Sequential or Parallel, we must iterate on its children recursively until we reach
+ internal anchors (items).
+*/
+void QGraphicsAnchorLayoutPrivate::identifyNonFloatItems_helper(const AnchorData *ad, Orientation orientation)
+{
+ Q_Q(QGraphicsAnchorLayout);
+
+ switch(ad->type) {
+ case AnchorData::Normal:
+ if (ad->from->m_item == ad->to->m_item && ad->to->m_item != q)
+ m_nonFloatItems[orientation].insert(ad->to->m_item);
+ break;
+ case AnchorData::Sequential:
+ foreach (const AnchorData *d, static_cast<const SequentialAnchorData *>(ad)->m_edges)
+ identifyNonFloatItems_helper(d, orientation);
+ break;
+ case AnchorData::Parallel:
+ identifyNonFloatItems_helper(static_cast<const ParallelAnchorData *>(ad)->firstEdge, orientation);
+ identifyNonFloatItems_helper(static_cast<const ParallelAnchorData *>(ad)->secondEdge, orientation);
+ break;
+ }
+}
+
+/*!
\internal
Use the current vertices distance to calculate and set the geometry of
@@ -2491,7 +2536,11 @@ bool QGraphicsAnchorLayoutPrivate::hasConflicts() const
{
QGraphicsAnchorLayoutPrivate *that = const_cast<QGraphicsAnchorLayoutPrivate*>(this);
that->calculateGraphs();
- return graphHasConflicts[0] || graphHasConflicts[1];
+
+ bool floatConflict = (m_nonFloatItems[0].size() < items.size())
+ || (m_nonFloatItems[1].size() < items.size());
+
+ return graphHasConflicts[0] || graphHasConflicts[1] || floatConflict;
}
#ifdef QT_DEBUG
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
index aac4f96..1a74d85 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
@@ -445,6 +445,8 @@ public:
void constraintsFromPaths(Orientation orientation);
QList<QSimplexConstraint *> constraintsFromSizeHints(const QList<AnchorData *> &anchors);
QList<QList<QSimplexConstraint *> > getGraphParts(Orientation orientation);
+ void identifyNonFloatItems(QSet<AnchorData *> visited, Orientation orientation);
+ void identifyNonFloatItems_helper(const AnchorData *ad, Orientation orientation);
inline AnchorVertex *internalVertex(const QPair<QGraphicsLayoutItem*, Qt::AnchorPoint> &itemEdge) const
{
@@ -511,6 +513,7 @@ public:
// ###
bool graphSimplified[2];
bool graphHasConflicts[2];
+ QSet<QGraphicsLayoutItem *> m_nonFloatItems[2];
uint calculateGraphCacheDirty : 1;
};