![]() |
Qt 6.x
The Qt SDK
|
#include <qgraphicsanchorlayout_p.h>
Classes | |
struct | GraphParts |
Public Types | |
enum | Interval { MinimumToMinPreferred = 0 , MinPreferredToPreferred , PreferredToMaxPreferred , MaxPreferredToMaximum } |
typedef Qt::Orientation | Orientation |
![]() | |
enum | SizeComponent { Width , Height } |
Static Public Member Functions | |
static QGraphicsAnchorLayoutPrivate * | get (QGraphicsAnchorLayout *q) |
static Qt::AnchorPoint | oppositeEdge (Qt::AnchorPoint edge) |
static Qt::Orientation | edgeOrientation (Qt::AnchorPoint edge) noexcept |
static Qt::AnchorPoint | pickEdge (Qt::AnchorPoint edge, Qt::Orientation orientation) |
![]() | |
static QGraphicsLayoutItemPrivate * | get (QGraphicsLayoutItem *q) |
static const QGraphicsLayoutItemPrivate * | get (const QGraphicsLayoutItem *q) |
Static Public Attributes | |
static constexpr Qt::Orientation | Horizontal = Qt::Horizontal |
static constexpr Qt::Orientation | Vertical = Qt::Vertical |
Friends | |
class | QGraphicsAnchorPrivate |
QGraphicsAnchorLayout private methods and attributes.
Definition at line 345 of file qgraphicsanchorlayout_p.h.
Definition at line 362 of file qgraphicsanchorlayout_p.h.
Enumerator | |
---|---|
MinimumToMinPreferred | |
MinPreferredToPreferred | |
PreferredToMaxPreferred | |
MaxPreferredToMaximum |
Definition at line 355 of file qgraphicsanchorlayout_p.h.
QGraphicsAnchorLayoutPrivate::QGraphicsAnchorLayoutPrivate | ( | ) |
Definition at line 591 of file qgraphicsanchorlayout_p.cpp.
|
inline |
Definition at line 396 of file qgraphicsanchorlayout_p.h.
Referenced by addAnchor().
QGraphicsAnchor * QGraphicsAnchorLayoutPrivate::addAnchor | ( | QGraphicsLayoutItem * | firstItem, |
Qt::AnchorPoint | firstEdge, | ||
QGraphicsLayoutItem * | secondItem, | ||
Qt::AnchorPoint | secondEdge, | ||
qreal * | spacing = nullptr |
||
) |
Implements the high level "addAnchor" feature. Called by the public API addAnchor method.
The optional spacing argument defines the size of the anchor. If not provided, the anchor size is either 0 or not-set, depending on type of anchor created (see matrix below).
All anchors that remain with size not-set will assume the standard spacing, set either by the layout style or through the "setSpacing" layout API.
Definition at line 1587 of file qgraphicsanchorlayout_p.cpp.
References acquireGraphicsAnchor(), addAnchor_helper(), QGraphicsLayoutPrivate::addChildLayoutItem(), Qt::AnchorHorizontalCenter, QListSpecialMethodsBase< T >::contains(), correctEdgeDirection(), createCenterAnchors(), createItemEdges(), edgeOrientation(), Qt::Horizontal, items, oppositeEdge(), QGraphicsLayoutItem::parentLayoutItem(), pickEdge(), qWarning, QGraphicsAnchor::setSpacing(), spacing, and QGraphicsAnchor::unsetSpacing().
void QGraphicsAnchorLayoutPrivate::addAnchor_helper | ( | QGraphicsLayoutItem * | firstItem, |
Qt::AnchorPoint | firstEdge, | ||
QGraphicsLayoutItem * | secondItem, | ||
Qt::AnchorPoint | secondEdge, | ||
AnchorData * | data | ||
) |
Definition at line 1681 of file qgraphicsanchorlayout_p.cpp.
References addInternalVertex(), QString::arg(), edgeOrientation(), QString::fromLatin1(), graph, removeAnchor_helper(), v1, and Qt::Vertical.
Referenced by addAnchor(), createCenterAnchors(), createItemEdges(), createLayoutEdges(), and removeCenterAnchors().
AnchorData * QGraphicsAnchorLayoutPrivate::addAnchorMaybeParallel | ( | AnchorData * | newAnchor, |
bool * | feasible | ||
) |
Adds newAnchor to the graph.
Returns the newAnchor itself if it could be added without further changes to the graph. If a new parallel anchor had to be created, then returns the new parallel anchor. If a parallel anchor had to be created and it results in an unfeasible setup, feasible is set to false, otherwise true.
Note that in the case a new parallel anchor is created, it might also take over some constraints from its children anchors.
Definition at line 631 of file qgraphicsanchorlayout_p.cpp.
References QList< T >::append(), QtGraphicsAnchorLayout::ParallelAnchorData::calculateSizeHints(), child, constraints, QtGraphicsAnchorLayout::AnchorData::from, graph, Qt::Horizontal, i, QtGraphicsAnchorLayout::AnchorData::isCenterAnchor, QtGraphicsAnchorLayout::AnchorData::isVertical, itemCenterConstraints, j, QtGraphicsAnchorLayout::ParallelAnchorData::m_firstConstraints, QtGraphicsAnchorLayout::ParallelAnchorData::m_secondConstraints, QtGraphicsAnchorLayout::ParallelAnchorData::secondForward(), QtGraphicsAnchorLayout::AnchorData::to, and Qt::Vertical.
Referenced by replaceVertex(), and simplifyGraphIteration().
AnchorVertex * QGraphicsAnchorLayoutPrivate::addInternalVertex | ( | QGraphicsLayoutItem * | item, |
Qt::AnchorPoint | edge | ||
) |
Definition at line 1843 of file qgraphicsanchorlayout_p.cpp.
References QHash< Key, T >::insert(), item, m_vertexList, Q_ASSERT, and QHash< Key, T >::value().
Referenced by addAnchor_helper().
void QGraphicsAnchorLayoutPrivate::calculateGraphs | ( | ) |
Called on activation. Uses Linear Programming to define minimum, preferred and maximum sizes for the layout. Also calculates the sizes that each item should assume when the layout is in one of such situations.
Definition at line 2005 of file qgraphicsanchorlayout_p.cpp.
References calculateGraphCacheDirty, calculateGraphs(), Qt::Horizontal, and Qt::Vertical.
Referenced by calculateGraphs(), and hasConflicts().
void QGraphicsAnchorLayoutPrivate::calculateGraphs | ( | Qt::Orientation | orientation | ) |
Calculate graphs is the method that puts together all the helper routines so that the AnchorLayout can calculate the sizes of each item.
In a nutshell it should do:
1) Refresh anchor nominal sizes, that is, the size that each anchor would have if no other restrictions applied. This is done by querying the layout style and the sizeHints of the items belonging to the layout.
2) Simplify the graph by grouping together parallel and sequential anchors into "group anchors". These have equivalent minimum, preferred and maximum sizeHints as the anchors they replace.
3) Check if we got to a trivial case. In some cases, the whole graph can be simplified into a single anchor. If so, use this information. If not, then call the Simplex solver to calculate the anchors sizes.
4) Once the root anchors had its sizes calculated, propagate that to the anchors they represent.
Definition at line 2050 of file qgraphicsanchorlayout_p.cpp.
References calculateNonTrunk(), calculateTrunk(), constraints, constraintsFromPaths(), findPaths(), getGraphParts(), getVariables(), graphHasConflicts, graphPaths, QList< T >::isEmpty(), layoutLastVertex, Q_ASSERT, qDeleteAll(), qEnvironmentVariableIsEmpty(), qWarning, refreshAllSizeHints(), restoreSimplifiedGraph(), simplifyGraph(), and updateAnchorSizes().
bool QGraphicsAnchorLayoutPrivate::calculateNonTrunk | ( | const QList< QSimplexConstraint * > & | constraints, |
const QList< AnchorData * > & | variables | ||
) |
Definition at line 2215 of file qgraphicsanchorlayout_p.cpp.
References QList< T >::at(), constraints, g_offset, j, Q_ASSERT, shiftConstraints(), QList< T >::size(), QtGraphicsAnchorLayout::AnchorData::sizeAtMaximum, QtGraphicsAnchorLayout::AnchorData::sizeAtMinimum, QtGraphicsAnchorLayout::AnchorData::sizeAtPreferred, and solvePreferred().
Referenced by calculateGraphs().
bool QGraphicsAnchorLayoutPrivate::calculateTrunk | ( | Qt::Orientation | orientation, |
const GraphPath & | path, | ||
const QList< QSimplexConstraint * > & | constraints, | ||
const QList< AnchorData * > & | variables | ||
) |
Calculate the sizes for all anchors which are part of the trunk. This works on top of a (possibly) simplified graph.
Definition at line 2147 of file qgraphicsanchorlayout_p.cpp.
References constraints, constraintsFromSizeHints(), g_offset, Qt::Horizontal, Qt::MaximumSize, QtGraphicsAnchorLayout::AnchorData::maxSize, Qt::MinimumSize, QtGraphicsAnchorLayout::AnchorData::minSize, Qt::PreferredSize, QtGraphicsAnchorLayout::AnchorData::prefSize, Q_ASSERT, qDebug, qDeleteAll(), shiftConstraints(), QtGraphicsAnchorLayout::AnchorData::sizeAtMaximum, QtGraphicsAnchorLayout::AnchorData::sizeAtMinimum, QtGraphicsAnchorLayout::AnchorData::sizeAtPreferred, sizeHints, solveMinMax(), and solvePreferred().
Referenced by calculateGraphs().
void QGraphicsAnchorLayoutPrivate::calculateVertexPositions | ( | Qt::Orientation | orientation | ) |
Calculate the position of each vertex based on the paths to each of them as well as the current edges sizes.
Definition at line 2631 of file qgraphicsanchorlayout_p.cpp.
References QList< T >::at(), QSet< T >::contains(), QtGraphicsAnchorLayout::AnchorVertex::distance, graph, i, QSet< T >::insert(), interpolateEdge(), layoutFirstVertex, qMakePair(), queue, setupEdgesInterpolation(), and QList< T >::size().
|
inline |
Definition at line 487 of file qgraphicsanchorlayout_p.h.
Referenced by restoreVertices(), and simplifyVertices().
void QGraphicsAnchorLayoutPrivate::constraintsFromPaths | ( | Qt::Orientation | orientation | ) |
Each vertex on the graph that has more than one path to it represents a contra int to the sizes of the items in these paths.
This method walks the list of paths to each vertex, generate the constraints and store them in a list so they can be used later by the Simplex solver.
Definition at line 2316 of file qgraphicsanchorlayout_p.cpp.
References QList< T >::at(), constraints, graphPaths, and i.
Referenced by calculateGraphs().
QList< QSimplexConstraint * > QGraphicsAnchorLayoutPrivate::constraintsFromSizeHints | ( | const QList< AnchorData * > & | anchors | ) |
Create LP constraints for each anchor based on its minimum and maximum sizes, as specified in its size hints
Definition at line 2352 of file qgraphicsanchorlayout_p.cpp.
References anchors(), QtGraphicsAnchorLayout::AnchorData::dependency, QSimplexConstraint::Equal, QtGraphicsAnchorLayout::AnchorData::from, g_offset, graph, Qt::Horizontal, i, QHash< Key, T >::insert(), layoutCentralVertex, layoutFirstVertex, layoutLastVertex, QSimplexConstraint::LessOrEqual, QtGraphicsAnchorLayout::AnchorData::maxSize, QtGraphicsAnchorLayout::AnchorData::minSize, QSimplexConstraint::MoreOrEqual, qBound(), qFuzzyCompare(), QWIDGETSIZE_MAX, QtGraphicsAnchorLayout::AnchorData::Slave, QSimplexConstraint::variables, and Qt::Vertical.
Referenced by calculateTrunk().
void QGraphicsAnchorLayoutPrivate::correctEdgeDirection | ( | QGraphicsLayoutItem *& | firstItem, |
Qt::AnchorPoint & | firstEdge, | ||
QGraphicsLayoutItem *& | secondItem, | ||
Qt::AnchorPoint & | secondEdge | ||
) |
Use heuristics to determine the correct orientation of a given anchor.
After API discussions, we decided we would like expressions like anchor(A, Left, B, Right) to mean the same as anchor(B, Right, A, Left). The problem with this is that anchors could become ambiguous, for instance, what does the anchor A, B of size X mean?
"pos(B) = pos(A) + X" or "pos(A) = pos(B) + X" ?
To keep the API user friendly and at the same time, keep our algorithm deterministic, we use an heuristic to determine a direction for each added anchor and then keep it. The heuristic is based on the fact that people usually avoid overlapping items, therefore:
"A, RIGHT to B, LEFT" means that B is to the LEFT of A. "B, LEFT to A, RIGHT" is corrected to the above anchor.
Special correction is also applied when one of the items is the layout. We handle Layout Left as if it was another items's Right and Layout Right as another item's Left.
Definition at line 1941 of file qgraphicsanchorlayout_p.cpp.
References Qt::AnchorBottom, Qt::AnchorRight, and qSwap().
Referenced by addAnchor().
void QGraphicsAnchorLayoutPrivate::createCenterAnchors | ( | QGraphicsLayoutItem * | item, |
Qt::AnchorPoint | centerEdge | ||
) |
By default, each item in the layout is represented internally as a single anchor in each direction. For instance, from Left to Right.
However, to support anchorage of items to the center of items, we must split this internal anchor into two half-anchors. From Left to Center and then from Center to Right, with the restriction that these anchors must have the same time at all times.
Definition at line 1396 of file qgraphicsanchorlayout_p.cpp.
References addAnchor_helper(), Qt::AnchorBottom, Qt::AnchorHorizontalCenter, Qt::AnchorLeft, Qt::AnchorRight, Qt::AnchorTop, Qt::AnchorVerticalCenter, Qt::Horizontal, internalVertex(), item, itemCenterConstraints, layoutCentralVertex, QtGraphicsAnchorLayout::AnchorData::Master, Q_ASSERT, removeAnchor_helper(), QtGraphicsAnchorLayout::AnchorData::Slave, and Qt::Vertical.
Referenced by addAnchor().
void QGraphicsAnchorLayoutPrivate::createItemEdges | ( | QGraphicsLayoutItem * | item | ) |
Definition at line 1370 of file qgraphicsanchorlayout_p.cpp.
References addAnchor_helper(), Qt::AnchorBottom, Qt::AnchorLeft, Qt::AnchorRight, Qt::AnchorTop, QList< T >::append(), item, and items.
Referenced by addAnchor().
void QGraphicsAnchorLayoutPrivate::createLayoutEdges | ( | ) |
Create internal anchors to connect the layout edges (Left to Right and Top to Bottom).
These anchors doesn't have size restrictions, that will be enforced by other anchors and items in the layout.
Definition at line 1329 of file qgraphicsanchorlayout_p.cpp.
References addAnchor_helper(), Qt::AnchorBottom, Qt::AnchorLeft, Qt::AnchorRight, Qt::AnchorTop, Qt::Horizontal, internalVertex(), layout, layoutCentralVertex, layoutFirstVertex, layoutLastVertex, QWIDGETSIZE_MAX, and Qt::Vertical.
void QGraphicsAnchorLayoutPrivate::deleteLayoutEdges | ( | ) |
Definition at line 1357 of file qgraphicsanchorlayout_p.cpp.
References Qt::AnchorBottom, Qt::AnchorHorizontalCenter, Qt::AnchorLeft, Qt::AnchorRight, Qt::AnchorTop, Qt::AnchorVerticalCenter, internalVertex(), Q_ASSERT, and removeAnchor_helper().
|
staticnoexcept |
Definition at line 1315 of file qgraphicsanchorlayout_p.cpp.
References Qt::AnchorRight, Qt::Horizontal, and Qt::Vertical.
Referenced by addAnchor(), addAnchor_helper(), getAnchor(), QtGraphicsAnchorLayout::AnchorData::refreshSizeHints(), removeAnchor_helper(), and removeVertex().
void QGraphicsAnchorLayoutPrivate::findPaths | ( | Qt::Orientation | orientation | ) |
This method walks the graph using a breadth-first search to find paths between the root vertex and each vertex on the graph. The edges directions in each path are considered and they are stored as a positive edge (left-to-right) or negative edge (right-to-left).
The list of paths is used later to generate a list of constraints.
Definition at line 2264 of file qgraphicsanchorlayout_p.cpp.
References QSet< T >::contains(), QtGraphicsAnchorLayout::AnchorData::from, graph, graphPaths, identifyFloatItems(), QSet< T >::insert(), layoutFirstVertex, QtGraphicsAnchorLayout::GraphPath::negatives, QtGraphicsAnchorLayout::GraphPath::positives, qMakePair(), and queue.
Referenced by calculateGraphs().
|
inlinestatic |
Definition at line 368 of file qgraphicsanchorlayout_p.h.
QGraphicsAnchor * QGraphicsAnchorLayoutPrivate::getAnchor | ( | QGraphicsLayoutItem * | firstItem, |
Qt::AnchorPoint | firstEdge, | ||
QGraphicsLayoutItem * | secondItem, | ||
Qt::AnchorPoint | secondEdge | ||
) |
Definition at line 1721 of file qgraphicsanchorlayout_p.cpp.
References edgeOrientation(), graph, internalVertex(), and Q_ASSERT.
QGraphicsAnchorLayoutPrivate::GraphParts QGraphicsAnchorLayoutPrivate::getGraphParts | ( | Qt::Orientation | orientation | ) |
Definition at line 2447 of file qgraphicsanchorlayout_p.cpp.
References constraints, graph, QSet< T >::insert(), itemCenterConstraints, layoutCentralVertex, layoutFirstVertex, layoutLastVertex, match(), and Q_ASSERT.
Referenced by calculateGraphs().
bool QGraphicsAnchorLayoutPrivate::hasConflicts | ( | ) | const |
Returns true
if there are no arrangement that satisfies all constraints. Otherwise returns false
.
Definition at line 2904 of file qgraphicsanchorlayout_p.cpp.
References calculateGraphs(), graphHasConflicts, Qt::Horizontal, m_floatItems, and Qt::Vertical.
void QGraphicsAnchorLayoutPrivate::identifyFloatItems | ( | const QSet< AnchorData * > & | visited, |
Qt::Orientation | orientation | ||
) |
Use all visited Anchors on findPaths() so we can identify non-float Items.
Definition at line 2524 of file qgraphicsanchorlayout_p.cpp.
References QSet< T >::contains(), identifyNonFloatItems_helper(), QSet< T >::insert(), item, items, and m_floatItems.
Referenced by findPaths().
void QGraphicsAnchorLayoutPrivate::identifyNonFloatItems_helper | ( | const AnchorData * | ad, |
QSet< QGraphicsLayoutItem * > * | nonFloatingItemsIdentifiedSoFar | ||
) |
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).
Definition at line 2547 of file qgraphicsanchorlayout_p.cpp.
References d, identifyNonFloatItems_helper(), QSet< T >::insert(), QtGraphicsAnchorLayout::AnchorData::item, QtGraphicsAnchorLayout::AnchorData::Normal, QtGraphicsAnchorLayout::AnchorData::Parallel, QtGraphicsAnchorLayout::AnchorData::Sequential, and QtGraphicsAnchorLayout::AnchorData::type.
Referenced by identifyFloatItems(), and identifyNonFloatItems_helper().
|
inline |
Definition at line 482 of file qgraphicsanchorlayout_p.h.
References item, and qMakePair().
|
inline |
Definition at line 477 of file qgraphicsanchorlayout_p.h.
Referenced by createCenterAnchors(), createLayoutEdges(), deleteLayoutEdges(), getAnchor(), removeCenterAnchors(), removeCenterConstraints(), removeVertex(), and setItemsGeometries().
void QGraphicsAnchorLayoutPrivate::interpolateEdge | ( | AnchorVertex * | base, |
AnchorData * | edge | ||
) |
Calculate the current Edge size based on the current Layout size and the size the edge is supposed to have when the layout is at its:
These three key values are calculated in advance using linear programming (more expensive) or the simplification algorithm, then subsequential resizes of the parent layout require a simple interpolation.
Definition at line 2711 of file qgraphicsanchorlayout_p.cpp.
References base, QtGraphicsAnchorLayout::AnchorVertex::distance, QtGraphicsAnchorLayout::AnchorData::from, Qt::Horizontal, interpolate(), interpolationInterval, interpolationProgress, QtGraphicsAnchorLayout::AnchorData::isVertical, Q_ASSERT, QtGraphicsAnchorLayout::AnchorData::sizeAtMaximum, QtGraphicsAnchorLayout::AnchorData::sizeAtMinimum, QtGraphicsAnchorLayout::AnchorData::sizeAtPreferred, QtGraphicsAnchorLayout::AnchorData::to, and Qt::Vertical.
Referenced by calculateVertexPositions().
|
static |
Definition at line 596 of file qgraphicsanchorlayout_p.cpp.
References Qt::AnchorBottom, Qt::AnchorLeft, Qt::AnchorRight, and Qt::AnchorTop.
Referenced by addAnchor().
|
inlinestatic |
Definition at line 378 of file qgraphicsanchorlayout_p.h.
References Qt::Horizontal, and Qt::Vertical.
Referenced by addAnchor().
void QGraphicsAnchorLayoutPrivate::refreshAllSizeHints | ( | Qt::Orientation | orientation | ) |
Traverse the graph refreshing the size hints. Edges will query their associated item or graphicsAnchor for their size hints.
Definition at line 2242 of file qgraphicsanchorlayout_p.cpp.
References QList< T >::at(), graph, i, QtGraphicsAnchorLayout::AnchorData::refreshSizeHints(), QList< T >::size(), and styleInfo().
Referenced by calculateGraphs().
void QGraphicsAnchorLayoutPrivate::removeAnchor | ( | AnchorVertex * | firstVertex, |
AnchorVertex * | secondVertex | ||
) |
Implements the high level "removeAnchor" feature. Called by the QAnchorData destructor.
Definition at line 1756 of file qgraphicsanchorlayout_p.cpp.
References Qt::AnchorBottom, Qt::AnchorHorizontalCenter, Qt::AnchorLeft, Qt::AnchorVerticalCenter, i, QListSpecialMethodsBase< T >::indexOf(), items, QtGraphicsAnchorLayout::AnchorVertex::m_item, m_vertexList, qMakePair(), removeAnchor_helper(), and QHash< Key, T >::value().
Referenced by QGraphicsAnchorPrivate::~QGraphicsAnchorPrivate().
void QGraphicsAnchorLayoutPrivate::removeAnchor_helper | ( | AnchorVertex * | v1, |
AnchorVertex * | v2 | ||
) |
Definition at line 1830 of file qgraphicsanchorlayout_p.cpp.
References edgeOrientation(), graph, o, Q_ASSERT, and removeInternalVertex().
Referenced by addAnchor_helper(), createCenterAnchors(), deleteLayoutEdges(), removeAnchor(), and removeCenterAnchors().
void QGraphicsAnchorLayoutPrivate::removeAnchors | ( | QGraphicsLayoutItem * | item | ) |
Definition at line 1905 of file qgraphicsanchorlayout_p.cpp.
References Qt::AnchorBottom, Qt::AnchorHorizontalCenter, Qt::AnchorLeft, Qt::AnchorRight, Qt::AnchorTop, Qt::AnchorVerticalCenter, item, removeCenterAnchors(), and removeVertex().
void QGraphicsAnchorLayoutPrivate::removeCenterAnchors | ( | QGraphicsLayoutItem * | item, |
Qt::AnchorPoint | centerEdge, | ||
bool | substitute = true |
||
) |
Definition at line 1461 of file qgraphicsanchorlayout_p.cpp.
References addAnchor_helper(), Qt::AnchorBottom, Qt::AnchorHorizontalCenter, Qt::AnchorLeft, Qt::AnchorRight, Qt::AnchorTop, Qt::AnchorVerticalCenter, QList< T >::at(), at, graph, Qt::Horizontal, i, internalVertex(), item, itemCenterConstraints, layoutCentralVertex, Q_ASSERT, removeAnchor_helper(), QList< T >::size(), and Qt::Vertical.
Referenced by removeAnchors(), and removeInternalVertex().
void QGraphicsAnchorLayoutPrivate::removeCenterConstraints | ( | QGraphicsLayoutItem * | item, |
Qt::Orientation | orientation | ||
) |
Definition at line 1544 of file qgraphicsanchorlayout_p.cpp.
References Qt::AnchorHorizontalCenter, Qt::AnchorLeft, Qt::AnchorTop, Qt::AnchorVerticalCenter, at, graph, Qt::Horizontal, i, internalVertex(), item, itemCenterConstraints, and Q_ASSERT.
void QGraphicsAnchorLayoutPrivate::removeInternalVertex | ( | QGraphicsLayoutItem * | item, |
Qt::AnchorPoint | edge | ||
) |
returns the AnchorVertex that was dereferenced, also when it was removed. returns 0 if it did not exist.
Definition at line 1864 of file qgraphicsanchorlayout_p.cpp.
References Qt::AnchorHorizontalCenter, Qt::AnchorVerticalCenter, QHash< Key, T >::insert(), item, m_vertexList, qWarning, QHash< Key, T >::remove(), removeCenterAnchors(), and QHash< Key, T >::value().
Referenced by removeAnchor_helper(), and removeVertex().
void QGraphicsAnchorLayoutPrivate::removeVertex | ( | QGraphicsLayoutItem * | item, |
Qt::AnchorPoint | edge | ||
) |
Definition at line 1892 of file qgraphicsanchorlayout_p.cpp.
References edgeOrientation(), graph, internalVertex(), item, and removeInternalVertex().
Referenced by removeAnchors().
bool QGraphicsAnchorLayoutPrivate::replaceVertex | ( | Qt::Orientation | orientation, |
AnchorVertex * | oldV, | ||
AnchorVertex * | newV, | ||
const QList< AnchorData * > & | edges | ||
) |
Definition at line 837 of file qgraphicsanchorlayout_p.cpp.
References addAnchorMaybeParallel(), anchorsFromSimplifiedVertices, QString::arg(), QtGraphicsAnchorLayout::AnchorData::from, QString::fromLatin1(), graph, i, replaceVertex_helper(), QList< T >::size(), and QtGraphicsAnchorLayout::AnchorData::to.
Referenced by simplifyVertices().
void QGraphicsAnchorLayoutPrivate::restoreSimplifiedAnchor | ( | AnchorData * | edge | ) |
Definition at line 1140 of file qgraphicsanchorlayout_p.cpp.
References anchorsFromSimplifiedVertices, QList< T >::at(), contains(), QtGraphicsAnchorLayout::ParallelAnchorData::firstEdge, QtGraphicsAnchorLayout::AnchorData::from, graph, Qt::Horizontal, i, QtGraphicsAnchorLayout::AnchorData::isVertical, QtGraphicsAnchorLayout::SequentialAnchorData::m_edges, QtGraphicsAnchorLayout::AnchorData::Normal, QtGraphicsAnchorLayout::AnchorData::Parallel, Q_ASSERT, qDebug, restoreSimplifiedAnchor(), restoreSimplifiedConstraints(), QtGraphicsAnchorLayout::ParallelAnchorData::secondEdge, QtGraphicsAnchorLayout::AnchorData::Sequential, QList< T >::size(), QtGraphicsAnchorLayout::AnchorData::to, QtGraphicsAnchorLayout::AnchorData::type, and Qt::Vertical.
Referenced by restoreSimplifiedAnchor(), and restoreSimplifiedGraph().
void QGraphicsAnchorLayoutPrivate::restoreSimplifiedConstraints | ( | ParallelAnchorData * | parallel | ) |
Definition at line 1188 of file qgraphicsanchorlayout_p.cpp.
References QList< T >::at(), QtGraphicsAnchorLayout::ParallelAnchorData::firstEdge, i, QtGraphicsAnchorLayout::AnchorData::isCenterAnchor, QtGraphicsAnchorLayout::ParallelAnchorData::m_firstConstraints, QtGraphicsAnchorLayout::ParallelAnchorData::m_secondConstraints, QHash< Key, T >::remove(), QtGraphicsAnchorLayout::ParallelAnchorData::secondEdge, QtGraphicsAnchorLayout::ParallelAnchorData::secondForward(), QList< T >::size(), and QSimplexConstraint::variables.
Referenced by restoreSimplifiedAnchor(), and restoreVertices().
void QGraphicsAnchorLayoutPrivate::restoreSimplifiedGraph | ( | Qt::Orientation | orientation | ) |
Definition at line 1214 of file qgraphicsanchorlayout_p.cpp.
References anchorsFromSimplifiedVertices, QList< T >::at(), graph, Horizontal, i, QtGraphicsAnchorLayout::AnchorData::Parallel, qDebug, restoreSimplifiedAnchor(), restoreVertices(), QtGraphicsAnchorLayout::AnchorData::Sequential, QList< T >::size(), and QtGraphicsAnchorLayout::AnchorData::type.
Referenced by calculateGraphs(), and simplifyGraph().
void QGraphicsAnchorLayoutPrivate::restoreVertices | ( | Qt::Orientation | orientation | ) |
Definition at line 1243 of file qgraphicsanchorlayout_p.cpp.
References anchorsFromSimplifiedVertices, QList< T >::at(), changeLayoutVertex(), QList< T >::clear(), QtGraphicsAnchorLayout::AnchorData::from, graph, i, j, QtGraphicsAnchorLayout::AnchorVertexPair::m_first, QtGraphicsAnchorLayout::AnchorVertexPair::m_firstAnchors, QtGraphicsAnchorLayout::AnchorVertex::m_item, QtGraphicsAnchorLayout::AnchorVertexPair::m_removedAnchor, QtGraphicsAnchorLayout::AnchorVertexPair::m_second, QtGraphicsAnchorLayout::AnchorVertexPair::m_secondAnchors, Q_ASSERT, qDeleteAll(), replaceVertex_helper(), restoreSimplifiedConstraints(), simplifiedVertices, QList< T >::size(), and QtGraphicsAnchorLayout::AnchorData::to.
Referenced by restoreSimplifiedGraph(), and simplifyGraph().
Use the current vertices distance to calculate and set the geometry of each item.
Definition at line 2573 of file qgraphicsanchorlayout_p.cpp.
References Qt::AnchorBottom, Qt::AnchorLeft, Qt::AnchorRight, Qt::AnchorTop, contains(), QtGraphicsAnchorLayout::AnchorVertex::distance, QGraphicsLayoutItemPrivate::geom, QSizeF::height(), Qt::Horizontal, internalVertex(), item, items, QRectF::left(), QGraphicsLayoutPrivate::left, Qt::LeftToRight, m_floatItems, Qt::PreferredSize, qSwap(), QRectF::right(), QGraphicsLayoutPrivate::right, Qt::RightToLeft, QRectF::setBottom(), QRectF::setLeft(), QRectF::setRight(), QRectF::setTop(), QRectF::top(), QGraphicsLayoutPrivate::top, Qt::Vertical, QGraphicsLayoutPrivate::visualDirection(), and QSizeF::width().
void QGraphicsAnchorLayoutPrivate::setupEdgesInterpolation | ( | Qt::Orientation | orientation | ) |
Calculate interpolation parameters based on current Layout Size. Must be called once before calling "interpolateEdgeSize()" for the edges.
Definition at line 2676 of file qgraphicsanchorlayout_p.cpp.
References getFactor(), Qt::Horizontal, interpolationInterval, interpolationProgress, Qt::MaximumSize, Qt::MinimumSize, Qt::PreferredSize, and sizeHints.
Referenced by calculateVertexPositions().
bool QGraphicsAnchorLayoutPrivate::simplifyGraph | ( | Qt::Orientation | orientation | ) |
The purpose of this function is to simplify the graph. Simplification serves two purposes:
It is essential that it must be possible to restore simplified anchors back to their "original" form. This is done by restoreSimplifiedAnchor().
There are two types of simplification that can be done:
The process of simplification can be described as:
When creating the parallel anchors, the algorithm might identify unfeasible situations. In this case the simplification process stops and returns false
. Otherwise returns true
.
Definition at line 780 of file qgraphicsanchorlayout_p.cpp.
References arg, QString::fromLatin1(), Horizontal, QList< T >::isEmpty(), items, qDebug, restoreSimplifiedGraph(), restoreVertices(), simplifyGraphIteration(), and simplifyVertices().
Referenced by calculateGraphs().
bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration | ( | Qt::Orientation | orientation, |
bool * | feasible | ||
) |
One iteration of the simplification algorithm. Returns true
if another iteration is needed.
The algorithm walks the graph in depth-first order, and only collects vertices that has two edges connected to it. If the vertex does not have two edges or if it is a layout edge, it will take all the previously collected vertices and try to create a simplified sequential anchor representing all the previously collected vertices. Once the simplified anchor is inserted, the collected list is cleared in order to find the next sequence to simplify.
Note that there are some catches to this that are not covered by the above explanation, see the function comments for more details.
Definition at line 984 of file qgraphicsanchorlayout_p.cpp.
References addAnchorMaybeParallel(), QList< T >::append(), QList< T >::at(), QList< T >::clear(), QList< T >::constFirst(), QList< T >::constLast(), QListSpecialMethodsBase< T >::contains(), QSet< T >::contains(), createSequence(), QList< T >::first(), graph, i, QSet< T >::insert(), QtGraphicsAnchorLayout::AnchorData::isCenterAnchor, QList< T >::isEmpty(), QList< T >::last(), layoutFirstVertex, next, QStack< T >::pop(), QStack< T >::push(), Q_ASSERT, qMakePair(), QList< T >::remove(), and QList< T >::size().
Referenced by simplifyGraph().
bool QGraphicsAnchorLayoutPrivate::simplifyVertices | ( | Qt::Orientation | orientation | ) |
Definition at line 871 of file qgraphicsanchorlayout_p.cpp.
References QList< T >::append(), QList< T >::at(), changeLayoutVertex(), QListSpecialMethodsBase< T >::contains(), QSet< T >::contains(), graph, i, QSet< T >::insert(), QList< T >::isEmpty(), layoutFirstVertex, QtGraphicsAnchorLayout::AnchorVertexPair::m_firstAnchors, QtGraphicsAnchorLayout::AnchorVertex::m_item, QtGraphicsAnchorLayout::AnchorVertexPair::m_secondAnchors, next, QStack< T >::pop(), QStack< T >::push(), replaceVertex(), simplifiedVertices, and QList< T >::size().
Referenced by simplifyGraph().
bool QGraphicsAnchorLayoutPrivate::solveMinMax | ( | const QList< QSimplexConstraint * > & | constraints, |
const GraphPath & | path, | ||
qreal * | min, | ||
qreal * | max | ||
) |
Definition at line 2731 of file qgraphicsanchorlayout_p.cpp.
References QList< T >::at(), constraints, g_offset, getVariables(), i, QHash< Key, T >::insert(), iter, QSimplexVariable::result, QSimplex::setConstraints(), QSimplex::setObjective(), QList< T >::size(), QtGraphicsAnchorLayout::AnchorData::sizeAtMaximum, QtGraphicsAnchorLayout::AnchorData::sizeAtMinimum, QSimplex::solveMax(), QSimplex::solveMin(), and QSimplexConstraint::variables.
Referenced by calculateTrunk().
bool QGraphicsAnchorLayoutPrivate::solvePreferred | ( | const QList< QSimplexConstraint * > & | constraints, |
const QList< AnchorData * > & | variables | ||
) |
Definition at line 2786 of file qgraphicsanchorlayout_p.cpp.
References QList< T >::at(), QSimplexConstraint::constant, constraints, createSlack(), QList< T >::first(), g_offset, Grower, i, QHash< Key, T >::insert(), QtGraphicsAnchorLayout::AnchorData::isLayoutAnchor, QtGraphicsAnchorLayout::AnchorData::maxPrefSize, QtGraphicsAnchorLayout::AnchorData::maxSize, QtGraphicsAnchorLayout::AnchorData::minPrefSize, QtGraphicsAnchorLayout::AnchorData::minSize, QtGraphicsAnchorLayout::AnchorData::prefSize, qDeleteAll(), QSimplexVariable::result, QSimplex::setConstraints(), QSimplex::setObjective(), Shrinker, QList< T >::size(), QtGraphicsAnchorLayout::AnchorData::sizeAtPreferred, QSimplex::solveMin(), and QSimplexConstraint::variables.
Referenced by calculateNonTrunk(), and calculateTrunk().
QLayoutStyleInfo & QGraphicsAnchorLayoutPrivate::styleInfo | ( | ) | const |
Definition at line 1970 of file qgraphicsanchorlayout_p.cpp.
References cachedStyleInfo, QGraphicsLayoutItem::graphicsItem(), Qt::Horizontal, QGraphicsLayoutItem::isLayout(), QGraphicsItem::isWidget(), QGraphicsLayoutItemPrivate::parent, QGraphicsLayoutItemPrivate::parentItem(), QGraphicsLayoutItem::parentLayoutItem(), QLayoutStyleInfo::setDefaultSpacing(), spacings, QApplication::style(), styleInfoDirty, and Qt::Vertical.
Referenced by refreshAllSizeHints().
void QGraphicsAnchorLayoutPrivate::updateAnchorSizes | ( | Qt::Orientation | orientation | ) |
Definition at line 2335 of file qgraphicsanchorlayout_p.cpp.
References QList< T >::at(), graph, i, QList< T >::size(), and QtGraphicsAnchorLayout::AnchorData::updateChildrenSizes().
Referenced by calculateGraphs().
|
friend |
Definition at line 564 of file qgraphicsanchorlayout_p.h.
QHVContainer<QList<AnchorData *> > QGraphicsAnchorLayoutPrivate::anchorsFromSimplifiedVertices |
Definition at line 541 of file qgraphicsanchorlayout_p.h.
Referenced by replaceVertex(), restoreSimplifiedAnchor(), restoreSimplifiedGraph(), and restoreVertices().
|
mutable |
Definition at line 562 of file qgraphicsanchorlayout_p.h.
Referenced by styleInfo().
uint QGraphicsAnchorLayoutPrivate::calculateGraphCacheDirty |
Definition at line 560 of file qgraphicsanchorlayout_p.h.
Referenced by calculateGraphs().
QHVContainer<QList<QSimplexConstraint *> > QGraphicsAnchorLayoutPrivate::constraints |
Definition at line 545 of file qgraphicsanchorlayout_p.h.
Referenced by addAnchorMaybeParallel(), calculateGraphs(), calculateNonTrunk(), calculateTrunk(), constraintsFromPaths(), getGraphParts(), solveMinMax(), and solvePreferred().
QHVContainer<Graph<AnchorVertex, AnchorData> > QGraphicsAnchorLayoutPrivate::graph |
Definition at line 533 of file qgraphicsanchorlayout_p.h.
Referenced by addAnchor_helper(), addAnchorMaybeParallel(), calculateVertexPositions(), constraintsFromSizeHints(), findPaths(), getAnchor(), getGraphParts(), refreshAllSizeHints(), removeAnchor_helper(), removeCenterAnchors(), removeCenterConstraints(), removeVertex(), replaceVertex(), restoreSimplifiedAnchor(), restoreSimplifiedGraph(), restoreVertices(), simplifyGraphIteration(), simplifyVertices(), and updateAnchorSizes().
QHVContainer<bool> QGraphicsAnchorLayoutPrivate::graphHasConflicts = {} |
Definition at line 553 of file qgraphicsanchorlayout_p.h.
Referenced by calculateGraphs(), and hasConflicts().
QHVContainer<QMultiHash<AnchorVertex *, GraphPath> > QGraphicsAnchorLayoutPrivate::graphPaths |
Definition at line 544 of file qgraphicsanchorlayout_p.h.
Referenced by calculateGraphs(), constraintsFromPaths(), and findPaths().
|
inlinestaticconstexpr |
Definition at line 363 of file qgraphicsanchorlayout_p.h.
Referenced by restoreSimplifiedGraph(), and simplifyGraph().
QHVContainer<Interval> QGraphicsAnchorLayoutPrivate::interpolationInterval |
Definition at line 550 of file qgraphicsanchorlayout_p.h.
Referenced by interpolateEdge(), and setupEdgesInterpolation().
QHVContainer<qreal> QGraphicsAnchorLayoutPrivate::interpolationProgress = {-1, -1} |
Definition at line 551 of file qgraphicsanchorlayout_p.h.
Referenced by interpolateEdge(), and setupEdgesInterpolation().
QHVContainer<QList<QSimplexConstraint *> > QGraphicsAnchorLayoutPrivate::itemCenterConstraints |
Definition at line 546 of file qgraphicsanchorlayout_p.h.
Referenced by addAnchorMaybeParallel(), createCenterAnchors(), getGraphParts(), removeCenterAnchors(), and removeCenterConstraints().
QList<QGraphicsLayoutItem *> QGraphicsAnchorLayoutPrivate::items |
Definition at line 525 of file qgraphicsanchorlayout_p.h.
Referenced by addAnchor(), createItemEdges(), identifyFloatItems(), removeAnchor(), setItemsGeometries(), and simplifyGraph().
QHVContainer<AnchorVertex *> QGraphicsAnchorLayoutPrivate::layoutCentralVertex = {} |
Definition at line 536 of file qgraphicsanchorlayout_p.h.
Referenced by constraintsFromSizeHints(), createCenterAnchors(), createLayoutEdges(), getGraphParts(), and removeCenterAnchors().
QHVContainer<AnchorVertex *> QGraphicsAnchorLayoutPrivate::layoutFirstVertex = {} |
Definition at line 535 of file qgraphicsanchorlayout_p.h.
Referenced by calculateVertexPositions(), constraintsFromSizeHints(), createLayoutEdges(), findPaths(), getGraphParts(), simplifyGraphIteration(), and simplifyVertices().
QHVContainer<AnchorVertex *> QGraphicsAnchorLayoutPrivate::layoutLastVertex = {} |
Definition at line 537 of file qgraphicsanchorlayout_p.h.
Referenced by calculateGraphs(), constraintsFromSizeHints(), createLayoutEdges(), and getGraphParts().
QHVContainer<QSet<QGraphicsLayoutItem *> > QGraphicsAnchorLayoutPrivate::m_floatItems |
Definition at line 554 of file qgraphicsanchorlayout_p.h.
Referenced by hasConflicts(), identifyFloatItems(), and setItemsGeometries().
QHash<QPair<QGraphicsLayoutItem*, Qt::AnchorPoint>, QPair<AnchorVertex *, int> > QGraphicsAnchorLayoutPrivate::m_vertexList |
Definition at line 530 of file qgraphicsanchorlayout_p.h.
Referenced by addInternalVertex(), removeAnchor(), and removeInternalVertex().
QHVContainer<QList<AnchorVertexPair *> > QGraphicsAnchorLayoutPrivate::simplifiedVertices |
Definition at line 540 of file qgraphicsanchorlayout_p.h.
Referenced by restoreVertices(), and simplifyVertices().
QHVContainer<std::array<qreal, 3> > QGraphicsAnchorLayoutPrivate::sizeHints = {{-1, -1, -1}, {-1, -1, -1}} |
Definition at line 522 of file qgraphicsanchorlayout_p.h.
Referenced by calculateTrunk(), and setupEdgesInterpolation().
QHVContainer<qreal> QGraphicsAnchorLayoutPrivate::spacings = {-1, -1} |
Definition at line 520 of file qgraphicsanchorlayout_p.h.
Referenced by styleInfo().
|
mutable |
Definition at line 561 of file qgraphicsanchorlayout_p.h.
Referenced by styleInfo().
|
inlinestaticconstexpr |
Definition at line 364 of file qgraphicsanchorlayout_p.h.