42 #include <QtGui/qwidget.h> 43 #include <QtGui/qapplication.h> 44 #include <QtCore/qlinkedlist.h> 45 #include <QtCore/qstack.h> 48 #include <QtCore/qfile.h> 53 #ifndef QT_NO_GRAPHICSVIEW 93 qWarning(
"QGraphicsAnchor::setSpacing: The anchor does not exist.");
110 qWarning(
"QGraphicsAnchor::setSpacing: The anchor does not exist.");
123 qWarning(
"QGraphicsAnchor::setSpacing: The anchor does not exist.");
150 *minSize = minSizeHint;
152 *minSize = prefSizeHint;
155 *maxSize = maxSizeHint;
157 *maxSize = prefSizeHint;
161 *prefSize = *minSize;
163 *prefSize = prefSizeHint;
168 if (graphicsAnchor) {
171 graphicsAnchor->d_func()->data = 0;
173 delete graphicsAnchor;
187 if (isLayoutAnchor) {
194 minPrefSize = prefSize;
195 maxPrefSize = maxSize;
199 policy = item->sizePolicy().horizontalPolicy();
204 policy = item->sizePolicy().verticalPolicy();
210 if (isCenterAnchor) {
237 s = styleInfo->
perItemSpacing(controlTypeFrom, controlTypeTo, orient);
251 &minSize, &prefSize, &maxSize);
253 minPrefSize = prefSize;
254 maxPrefSize = maxSize;
263 sizeAtMinimum = prefSize;
264 sizeAtPreferred = prefSize;
265 sizeAtMaximum = prefSize;
270 firstEdge->sizeAtMinimum = sizeAtMinimum;
271 firstEdge->sizeAtPreferred = sizeAtPreferred;
272 firstEdge->sizeAtMaximum = sizeAtMaximum;
274 if (secondForward()) {
275 secondEdge->sizeAtMinimum = sizeAtMinimum;
276 secondEdge->sizeAtPreferred = sizeAtPreferred;
277 secondEdge->sizeAtMaximum = sizeAtMaximum;
279 secondEdge->sizeAtMinimum = -sizeAtMinimum;
280 secondEdge->sizeAtPreferred = -sizeAtPreferred;
281 secondEdge->sizeAtMaximum = -sizeAtMaximum;
284 firstEdge->updateChildrenSizes();
285 secondEdge->updateChildrenSizes();
309 if (secondForward()) {
310 secondMin = secondEdge->minSize;
311 secondMinPref = secondEdge->minPrefSize;
312 secondPref = secondEdge->prefSize;
313 secondMaxPref = secondEdge->maxPrefSize;
314 secondMax = secondEdge->maxSize;
316 secondMin = -secondEdge->maxSize;
317 secondMinPref = -secondEdge->maxPrefSize;
318 secondPref = -secondEdge->prefSize;
319 secondMaxPref = -secondEdge->minPrefSize;
320 secondMax = -secondEdge->minSize;
323 minSize =
qMax(firstEdge->minSize, secondMin);
324 maxSize =
qMin(firstEdge->maxSize, secondMax);
329 if (minSize > maxSize) {
362 if (firstEdge->isLayoutAnchor) {
363 prefSize =
qBound(minSize, secondPref, maxSize);
364 minPrefSize =
qBound(minSize, secondMinPref, maxSize);
365 maxPrefSize =
qBound(minSize, secondMaxPref, maxSize);
366 }
else if (secondEdge->isLayoutAnchor) {
367 prefSize =
qBound(minSize, firstEdge->prefSize, maxSize);
368 minPrefSize =
qBound(minSize, firstEdge->minPrefSize, maxSize);
369 maxPrefSize =
qBound(minSize, firstEdge->maxPrefSize, maxSize);
372 const qreal lowerBoundary =
373 qBound(minSize,
qMax(firstEdge->minPrefSize, secondMinPref), maxSize);
374 const qreal upperBoundary =
375 qBound(minSize,
qMin(firstEdge->maxPrefSize, secondMaxPref), maxSize);
376 const qreal prefMean =
377 qBound(minSize, (firstEdge->prefSize + secondPref) / 2, maxSize);
379 if (lowerBoundary < upperBoundary) {
384 prefSize =
qBound(lowerBoundary, prefMean, upperBoundary);
385 minPrefSize = lowerBoundary;
386 maxPrefSize = upperBoundary;
394 prefSize =
qBound(upperBoundary, prefMean, lowerBoundary);
395 minPrefSize = upperBoundary;
396 maxPrefSize = lowerBoundary;
401 sizeAtMinimum = prefSize;
402 sizeAtPreferred = prefSize;
403 sizeAtMaximum = prefSize;
423 if (value < minPref) {
427 }
else if (value < pref) {
431 }
else if (value < maxPref) {
442 if (upper == lower) {
445 progress = (value - lower) / (upper - lower);
457 switch (factor.
first) {
476 return lower + factor.
second * (upper - lower);
485 getFactor(sizeAtMinimum, minSize, minPrefSize, prefSize, maxPrefSize, maxSize);
487 getFactor(sizeAtPreferred, minSize, minPrefSize, prefSize, maxPrefSize, maxSize);
489 getFactor(sizeAtMaximum, minSize, minPrefSize, prefSize, maxPrefSize, maxSize);
496 for (
int i = 0; i < m_edges.count(); ++i) {
499 const bool edgeIsForward = (e->
from == prev);
533 for (
int i = 0; i < m_edges.count(); ++i) {
536 const bool edgeIsForward = (edge->
from == prev);
556 sizeAtMinimum = prefSize;
557 sizeAtPreferred = prefSize;
558 sizeAtMaximum = prefSize;
563 if (
type == Parallel) {
564 qDebug(
"%*s type: parallel:", indent,
"");
568 }
else if (
type == Sequential) {
571 qDebug(
"%*s type: sequential(%d):", indent,
"", kids);
572 for (
int i = 0; i < kids; ++i) {
576 qDebug(
"%*s type: Normal:", indent,
"");
592 intersection = cPositives & cNegatives;
594 cPositives -= intersection;
595 cNegatives -= intersection;
600 for (i = cPositives.
begin(); i != cPositives.
end(); ++i)
603 for (i = cNegatives.begin(); i != cNegatives.end(); ++i)
624 : calculateGraphCacheDirty(true), styleInfoDirty(true)
627 for (
int j = 0; j < 3; ++j) {
711 AnchorData *children[2] = { oldAnchor, newAnchor };
715 for (
int i = 0; i < 2; ++i) {
724 const bool needsReverse = i == 1 && !parallel->
secondForward();
731 for (
int j = 0; j < constraints.
count(); ++j) {
734 childConstraints->
append(c);
746 newAnchor = parallel;
771 #if defined(QT_DEBUG) && 0 773 for (
int i = 0; i < vertices.
count(); ++i) {
784 for (
int i = 0; i < vertices.
count(); ++i) {
799 sequence->
from = before;
800 sequence->
to = after;
852 #if defined(QT_DEBUG) && 0 853 qDebug(
"Simplifying Graph for %s",
854 orientation ==
Horizontal ?
"Horizontal" :
"Vertical");
856 static int count = 0;
871 bool feasible =
true;
874 }
while (dirty && feasible);
883 #if defined(QT_DEBUG) && 0 894 if (data->
from == oldV) {
908 bool feasible =
true;
910 for (
int i = 0; i < edges.
count(); ++i) {
914 #if defined(QT_DEBUG) 920 feasible &= newFeasible;
922 if (newAnchor != ad) {
958 while (index < adjacents.
count()) {
963 const bool bothLayoutVertices = v->
m_item == q && next->
m_item == q;
966 if (!bothLayoutVertices && zeroSized) {
978 for (
int i = 0; i < vAdjacents.
count(); ++i) {
980 if (adjacent != next) {
986 for (
int i = 0; i < nextAdjacents.
count(); ++i) {
995 adjacents.
append(adjacent);
1008 else if (next->
m_item == q)
1009 layoutVertex = next;
1083 const bool isLayoutVertex = v->
m_item == q;
1085 bool endOfSequence =
false;
1092 endOfSequence = isLayoutVertex || adjacents.
count() != 2;
1094 if (!endOfSequence) {
1106 after = (beforeSequence == adjacents.
last() ? adjacents.
first() : adjacents.
last());
1108 after = (candidates.
last() == adjacents.
last() ? adjacents.
first() : adjacents.
last());
1116 const bool cycleFound = visited.
contains(after);
1119 endOfSequence = cycleFound || data->isCenterAnchor;
1121 if (!endOfSequence) {
1125 }
else if (cycleFound && (beforeSequence != after)) {
1126 afterSequence = after;
1134 for (
int i = 0; i < adjacents.
count(); ++i) {
1151 if (!endOfSequence || candidates.
isEmpty())
1162 beforeSequence = candidates.
first();
1172 afterSequence = candidates.
last();
1199 if (newAnchor != sequence)
1213 static const char *anchortypes[] = {
"Normal",
1216 qDebug(
"Restoring %s edge.", anchortypes[
int(edge->
type)]);
1286 qDebug(
"Restoring Simplified Graph for %s",
1287 orientation ==
Horizontal ?
"Horizontal" :
"Vertical");
1293 for (
int i = 0; i < connections.
count(); ++i) {
1329 for (
int i = parallelAnchors.
count() - 1; i >= 0; --i) {
1336 for (
int i = toRestore.
count() - 1; i >= 0; --i) {
1364 for (
int j = 0; j < adjacents.
count(); ++j) {
1379 parallelAnchors.
clear();
1477 switch (centerEdge) {
1543 switch (centerEdge) {
1601 for (
int i = 0; i < adjacents.
count(); ++i) {
1669 if ((firstItem == 0) || (secondItem == 0)) {
1670 qWarning(
"QGraphicsAnchorLayout::addAnchor(): " 1671 "Cannot anchor NULL items");
1675 if (firstItem == secondItem) {
1676 qWarning(
"QGraphicsAnchorLayout::addAnchor(): " 1677 "Cannot anchor the item to itself");
1682 qWarning(
"QGraphicsAnchorLayout::addAnchor(): " 1683 "Cannot anchor edges of different orientations");
1688 if (firstItem == parentWidget || secondItem == parentWidget) {
1689 qWarning(
"QGraphicsAnchorLayout::addAnchor(): " 1690 "You cannot add the parent of the layout to the layout.");
1744 return graphicsAnchor;
1771 if (
graph[orientation].edgeData(v1, v2)) {
1776 if (firstItem == secondItem)
1777 data->
item = firstItem;
1802 if (firstItem == secondItem)
1822 return graphicsAnchor;
1844 firstVertex = secondVertex = 0;
1847 bool keepFirstItem =
false;
1848 bool keepSecondItem =
false;
1853 if (firstItem != q) {
1862 if (v.
second > refcount) {
1863 keepFirstItem =
true;
1869 keepFirstItem =
true;
1871 if (secondItem != q) {
1880 if (v.
second > refcount) {
1881 keepSecondItem =
true;
1887 keepSecondItem =
true;
1892 if (!keepSecondItem)
1946 qWarning(
"This item with this edge is not in the graph");
1973 foreach (v2, allVertices) {
2027 if ((firstItem != q) && (secondItem != q)) {
2030 if (firstEdge < secondEdge) {
2031 qSwap(firstItem, secondItem);
2032 qSwap(firstEdge, secondEdge);
2034 }
else if (firstItem == q) {
2038 qSwap(firstItem, secondItem);
2039 qSwap(firstEdge, secondEdge);
2044 qSwap(firstItem, secondItem);
2045 qSwap(firstEdge, secondEdge);
2057 while (parent && parent->
isLayout()) {
2063 if (parentItem && parentItem->
isWidget())
2064 w = static_cast<QGraphicsWidget*>(parentItem);
2101 for (
int i = 0; i < constraints.
count(); ++i) {
2104 variableSet +=
static_cast<AnchorData *
>(var);
2107 return variableSet.
toList();
2139 #if defined(QT_DEBUG) || defined(Q_AUTOTEST_EXPORT) 2143 static bool simplificationEnabled =
qgetenv(
"QT_ANCHORLAYOUT_NO_SIMPLIFICATION").
isEmpty();
2150 qWarning(
"QGraphicsAnchorLayout: anchor setup is not feasible.");
2185 bool feasible =
calculateTrunk(orientation, trunkPath, trunkConstraints, trunkVariables);
2192 for (
int i = 1; i < parts.
count(); ++i) {
2214 if (simplificationEnabled)
2230 for (
int i = 0; i < constraints.
count(); ++i) {
2232 qreal multiplier = 0;
2236 c->
constant += multiplier * amount;
2253 bool feasible =
true;
2254 bool needsSimplex = !constraints.
isEmpty();
2257 qDebug(
"Simplex %s for trunk of %s", needsSimplex ?
"used" :
"NOT used",
2258 orientation ==
Horizontal ?
"Horizontal" :
"Vertical");
2270 feasible =
solveMinMax(allConstraints, path, &min, &max);
2300 ad->sizeAtMinimum = ad->minSize;
2301 ad->sizeAtPreferred = ad->prefSize;
2302 ad->sizeAtMaximum = ad->maxSize;
2309 #if defined(QT_DEBUG) || defined(Q_AUTOTEST_EXPORT) 2328 for (
int j = 0; j < variables.
count(); ++j) {
2355 for (
int i = 0; i < vertices.
count(); ++i) {
2406 graph[orientation].adjacentVertices(pair.
second)) {
2435 if (valueCount == 1)
2439 for (
int i = 1; i < valueCount; ++i) {
2441 pathsToVertex[0].constraint(pathsToVertex.
at(i));
2454 for (
int i = 0; i < vertices.
count(); ++i) {
2489 actualMax = layoutEdge->maxSize;
2491 actualMax = -layoutEdge->minSize;
2493 if (actualMax != expectedMax) {
2499 bool unboundedProblem =
true;
2500 for (
int i = 0; i < anchors.
size(); ++i) {
2515 if ((boundedMin == boundedMax) ||
qFuzzyCompare(boundedMin, boundedMax)) {
2520 anchorConstraints +=
c;
2521 unboundedProblem =
false;
2527 anchorConstraints +=
c;
2532 if (ad == layoutEdge)
2539 anchorConstraints +=
c;
2540 unboundedProblem =
false;
2545 if (unboundedProblem) {
2551 anchorConstraints +=
c;
2554 return anchorConstraints;
2588 trunkVariables += edgeL1;
2590 trunkVariables += edgeL2;
2597 while (it != remainingConstraints.
end()) {
2613 trunkConstraints +=
c;
2615 it = remainingConstraints.
erase(it);
2632 result += trunkConstraints;
2634 if (!remainingConstraints.
isEmpty()) {
2637 while (it != remainingConstraints.
end()) {
2638 nonTrunkConstraints += *
it;
2641 result += nonTrunkConstraints;
2686 nonFloatingItemsIdentifiedSoFar->
insert(ad->
item);
2689 foreach (
const AnchorData *
d, static_cast<const SequentialAnchorData *>(ad)->m_edges)
2717 q->getContentsMargins(&left, &top, &right, 0);
2722 left += geom.
left();
2801 for (
int i = 0; i < adjacents.
count(); ++i) {
2824 current = (orientation ==
Horizontal) ? q->contentsRect().width() : q->contentsRect().height();
2830 sizeHints[orientation][Qt::PreferredSize],
2831 sizeHints[orientation][Qt::PreferredSize],
2869 if (edge->
from == base) {
2895 *min = simplex.
solveMin() - objectiveOffset;
2899 for (
int i = 0; i < variables.
size(); ++i) {
2905 *max = simplex.
solveMax() - objectiveOffset;
2908 for (
int i = 0; i < variables.
size(); ++i) {
2956 for (
int i = 0; i < variables.
size(); ++i) {
2966 preferredConstraints += sizeConstraint;
2973 if (softShrinkInterval) {
2975 preferredVariables += slack.
first;
2976 preferredConstraints += slack.
second;
2984 if (softGrowInterval) {
2986 preferredVariables += slack.
first;
2987 preferredConstraints += slack.
second;
2995 if (hardShrinkInterval) {
2997 preferredVariables += slack.
first;
2998 preferredConstraints += slack.
second;
3006 if (hardGrowInterval) {
3008 preferredVariables += slack.
first;
3009 preferredConstraints += slack.
second;
3017 bool feasible = simplex->
setConstraints(constraints + preferredConstraints);
3025 for (
int i = 0; i < variables.
size(); ++i) {
3079 #endif //QT_NO_GRAPHICSVIEW
QSizeF effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const
Returns the effective size hint for this QGraphicsLayoutItem.
QString fileName() const
Returns the name set by setFileName() or to the QFile constructors.
void updateAnchorSizes(Orientation orientation)
iterator erase(iterator pos)
Removes the item pointed to by the iterator pos from the list, and returns an iterator to the next it...
virtual void setGeometry(const QRectF &rect)
This virtual function sets the geometry of the QGraphicsLayoutItem to rect, which is in parent coordi...
bool secondForward() const
bool graphHasConflicts[2]
qreal right() const
Returns the x-coordinate of the rectangle's right edge.
void dumpGraph(const QString &name=QString())
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
QLayoutStyleInfo & styleInfo() const
QGraphicsAnchorLayoutPrivate()
Represents an edge (anchor) in the internal graph.
void findPaths(Orientation orientation)
This method walks the graph using a breadth-first search to find paths between the root vertex and ea...
QGraphicsAnchorPrivate(int version=QObjectPrivateVersion)
void calculateGraphs()
Called on activation.
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
bool setConstraints(const QList< QSimplexConstraint *> constraints)
Sets the new constraints in the simplex solver and returns whether the problem is feasible...
QGraphicsAnchor * acquireGraphicsAnchor(AnchorData *data)
#define QT_END_NAMESPACE
This macro expands to.
qreal spacings[NOrientations]
The QQueue class is a generic container that provides a queue.
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
bool simplifyGraphIteration(Orientation orientation, bool *feasible)
One iteration of the simplification algorithm.
void clear()
Removes all items from the hash.
void refreshSizeHints(const QLayoutStyleInfo *styleInfo=0)
int remove(const Key &key)
Removes all the items that have the key from the hash.
QList< QSimplexConstraint * > m_firstConstraints
void remove(int i)
Removes the element at index position i.
void calculateSizeHints()
void setLeft(qreal pos)
Sets the left edge of the rectangle to the given x coordinate.
bool solveMinMax(const QList< QSimplexConstraint *> &constraints, GraphPath path, qreal *min, qreal *max)
QSet< QGraphicsLayoutItem * > m_floatItems[2]
#define it(className, varName)
QGraphicsItem * graphicsItem() const
Returns the QGraphicsItem that this layout item represents.
QList< QList< QSimplexConstraint * > > getGraphParts(Orientation orientation)
bool open(OpenMode flags)
Opens the file using OpenMode mode, returning true if successful; otherwise false.
int count(const T &t) const
Returns the number of occurrences of value in the vector.
QGraphicsLayoutItem * item
qreal solveMax()
Maximize the original objective.
qreal width() const
Returns the width.
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
T & first()
Returns a reference to the first item in the vector.
#define at(className, varName)
const_iterator constEnd() const
The QGraphicsAnchor class represents an anchor between two items in a QGraphicsAnchorLayout.
void createLayoutEdges()
Create internal anchors to connect the layout edges (Left to Right and Top to Bottom).
void addChildLayoutItem(QGraphicsLayoutItem *item)
This function is called from subclasses to add a layout item layoutItem to a layout.
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
qreal height() const
Returns the height.
int count(const Key &key, const T &value) const
Returns the number of items with the key and value.
qreal left() const
Returns the x-coordinate of the rectangle's left edge.
QHash< QPair< QGraphicsLayoutItem *, Qt::AnchorPoint >, QPair< AnchorVertex *, int > > m_vertexList
QMultiHash< AnchorVertex *, GraphPath > graphPaths[2]
QGraphicsAnchor * addAnchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge, QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge, qreal *spacing=0)
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
QList< QPair< Vertex *, Vertex * > > connections() const
static Qt::AnchorPoint pickEdge(Qt::AnchorPoint edge, Orientation orientation)
static bool match(const uchar *found, const char *target, uint len)
QList< AnchorData * > getVariables(QList< QSimplexConstraint *> constraints)
void calculateVertexPositions(Orientation orientation)
Calculate the position of each vertex based on the paths to each of them as well as the current edges...
void setTop(qreal pos)
Sets the top edge of the rectangle to the given y coordinate.
void setBottom(qreal pos)
Sets the bottom edge of the rectangle to the given y coordinate.
static Q_DECL_CONSTEXPR bool qFuzzyCompare(double p1, double p2)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QStack class is a template class that provides a stack.
QSimplexConstraint * constraint(const GraphPath &path) const
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
static QStyle * style()
Returns the application's style object.
static qreal interpolate(const QPair< QGraphicsAnchorLayoutPrivate::Interval, qreal > &factor, qreal min, qreal minPref, qreal pref, qreal maxPref, qreal max)
The QString class provides a Unicode character string.
AnchorData * addAnchorMaybeParallel(AnchorData *newAnchor, bool *feasible)
Adds newAnchor to the graph.
T take(const Key &key)
Removes the item with the key from the hash and returns the value associated with it...
EdgeData * edgeData(Vertex *first, Vertex *second)
QGraphicsAnchor * graphicsAnchor
void createEdge(Vertex *first, Vertex *second, EdgeData *data)
The QVector class is a template class that provides a dynamic array.
Representation of a valid path for a given vertex in the graph.
QHash< QSimplexVariable *, qreal > variables
QGraphicsAnchorLayoutPrivate * layoutPrivate
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
The QSizeF class defines the size of a two-dimensional object using floating point precision...
const T value(const Key &key) const
Returns the value associated with the key.
void setRight(qreal pos)
Sets the right edge of the rectangle to the given x coordinate.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
~QGraphicsAnchorPrivate()
QList< QSimplexConstraint * > m_secondConstraints
T pop()
Removes the top item from the stack and returns it.
Q_CORE_EXPORT void qDebug(const char *,...)
static QPair< QGraphicsAnchorLayoutPrivate::Interval, qreal > getFactor(qreal value, qreal min, qreal minPref, qreal pref, qreal maxPref, qreal max)
void removeCenterAnchors(QGraphicsLayoutItem *item, Qt::AnchorPoint centerEdge, bool substitute=true)
The QLinkedList class is a template class that provides linked lists.
QList< QSimplexConstraint * > constraintsFromSizeHints(const QList< AnchorData *> &anchors)
QLayoutStyleInfo cachedStyleInfo
void append(const T &t)
Inserts value at the end of the list.
QSet< AnchorData * > negatives
static Qt::AnchorPoint oppositeEdge(Qt::AnchorPoint edge)
void setObjective(QSimplexConstraint *objective)
#define QT_BEGIN_NAMESPACE
This macro expands to.
void refreshAllSizeHints(Orientation orientation)
Traverse the graph refreshing the size hints.
The QRectF class defines a rectangle in the plane using floating point precision. ...
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
static void applySizePolicy(QSizePolicy::Policy policy, qreal minSizeHint, qreal prefSizeHint, qreal maxSizeHint, qreal *minSize, qreal *prefSize, qreal *maxSize)
void constraintsFromPaths(Orientation orientation)
Each vertex on the graph that has more than one path to it represents a contra int to the sizes of th...
QList< AnchorData * > anchorsFromSimplifiedVertices[2]
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
bool contains(const T &value) const
AnchorVertex * addInternalVertex(QGraphicsLayoutItem *item, Qt::AnchorPoint edge)
QList< T > toList() const
virtual void updateChildrenSizes()
static AnchorData * createSequence(Graph< AnchorVertex, AnchorData > *graph, AnchorVertex *before, const QVector< AnchorVertex *> &vertices, AnchorVertex *after)
Takes the sequence of vertices described by (before, vertices, after) and removes all anchors connect...
QList< Vertex * > adjacentVertices(Vertex *vertex) const
void removeAnchors(QGraphicsLayoutItem *item)
bool simplifyVertices(Orientation orientation)
const T & at(int i) const
Returns the item at index position i in the list.
void setDefaultSpacing(Qt::Orientation o, qreal spacing)
void append(const T &t)
Inserts value at the end of the vector.
QList< AnchorData * > m_secondAnchors
Q_CORE_EXPORT void qWarning(const char *,...)
const_iterator insert(const T &value)
void restoreSimplifiedConstraints(ParallelAnchorData *parallel)
static const char * data(const QByteArray &arr)
static Orientation edgeOrientation(Qt::AnchorPoint edge)
QGraphicsLayoutItem * m_item
The QLinkedList::iterator class provides an STL-style non-const iterator for QLinkedList.
The QGraphicsLayoutItem class can be inherited to allow your custom items to be managed by layouts...
QVector< QGraphicsLayoutItem * > items
Interval interpolationInterval[2]
void clear()
Removes all items from the list.
bool calculateSizeHints()
int indexOf(const T &t, int from=0) const
Returns the index position of the first occurrence of value in the vector, searching forward from ind...
QGraphicsItem * parentItem() const
Returns the parent item of this layout, or 0 if this layout is not installed on any widget...
void removeAnchor_helper(AnchorVertex *v1, AnchorVertex *v2)
AnchorVertex * layoutLastVertex[2]
void setSpacing(qreal spacing)
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
qreal perItemSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation) const
void push(const T &t)
Adds element t to the top of the stack.
void removeCenterConstraints(QGraphicsLayoutItem *item, Orientation orientation)
void addAnchor_helper(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge, QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge, AnchorData *data)
QList< AnchorData * > m_firstAnchors
void qSwap(T &value1, T &value2)
const T & at(int i) const
Returns the item at index position i in the vector.
AnchorVertex * layoutCentralVertex[2]
The QGraphicsAnchorLayout class provides a layout where one can anchor widgets together in Graphics V...
static QWidget * parentWidget(const QWidget *w)
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
bool isLayout() const
Returns true if this QGraphicsLayoutItem is a layout (e.g., is inherited by an object that arranges o...
T & first()
Returns a reference to the first item in the list.
const char * constData() const
Returns a pointer to the data stored in the byte array.
QHash< Key, T >::iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
void removeInternalVertex(QGraphicsLayoutItem *item, Qt::AnchorPoint edge)
void restoreSimplifiedAnchor(AnchorData *edge)
void enqueue(const T &t)
Adds value t to the tail of the queue.
bool calculateNonTrunk(const QList< QSimplexConstraint *> &constraints, const QList< AnchorData *> &variables)
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Qt::LayoutDirection visualDirection() const
static AnchorVertex * replaceVertex_helper(AnchorData *data, AnchorVertex *oldV, AnchorVertex *newV)
Graph< AnchorVertex, AnchorData > graph[2]
The QFile class provides an interface for reading from and writing to files.
QSet< AnchorData * > positives
QGraphicsLayoutItem * parentLayoutItem() const
Returns the parent of this QGraphicsLayoutItem, or 0 if there is no parent, or if the parent does not...
bool solvePreferred(const QList< QSimplexConstraint *> &constraints, const QList< AnchorData *> &variables)
void setSizePolicy(QSizePolicy::Policy policy)
qreal defaultSpacing(Qt::Orientation o) const
QList< T > values() const
Returns a list containing all the values in the hash, in an arbitrary order.
Q_OUTOFLINE_TEMPLATE QPair< T1, T2 > qMakePair(const T1 &x, const T2 &y)
bool hasConflicts() const
Returns true if there are no arrangement that satisfies all constraints.
T & last()
Returns a reference to the last item in the vector.
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
T & last()
Returns a reference to the last item in the list.
static qreal checkAdd(qreal a, qreal b)
void 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...
static void shiftConstraints(const QList< QSimplexConstraint *> &constraints, qreal amount)
Shift all the constraints by a certain amount.
int size() const
Returns the number of items in the list.
uint calculateGraphCacheDirty
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
void setItemsGeometries(const QRectF &geom)
Use the current vertices distance to calculate and set the geometry of each item. ...
bool isWidget() const
Returns true if this item is a widget (i.
void identifyFloatItems(const QSet< AnchorData *> &visited, Orientation orientation)
Use all visited Anchors on findPaths() so we can identify non-float Items.
const_iterator constBegin() const
AnchorVertex * layoutFirstVertex[2]
T takeAt(int i)
Removes the item at index position i and returns it.
bool contains(const T &t) const
Returns true if the vector contains an occurrence of value; otherwise returns false.
void removeVertex(QGraphicsLayoutItem *item, Qt::AnchorPoint edge)
bool lastCalculationUsedSimplex[2]
QList< QSimplexConstraint * > constraints[2]
void changeLayoutVertex(Orientation orientation, AnchorVertex *oldV, AnchorVertex *newV)
EdgeData * takeEdge(Vertex *first, Vertex *second)
AnchorData * m_removedAnchor
qreal top() const
Returns the y-coordinate of the rectangle's top edge.
The QSimplex class is a Linear Programming problem solver based on the two-phase simplex method...
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
void setSpacing(qreal value)
void correctEdgeDirection(QGraphicsLayoutItem *&firstItem, Qt::AnchorPoint &firstEdge, QGraphicsLayoutItem *&secondItem, Qt::AnchorPoint &secondEdge)
Use heuristics to determine the correct orientation of a given anchor.
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
bool simplifyGraph(Orientation orientation)
The purpose of this function is to simplify the graph.
bool replaceVertex(Orientation orientation, AnchorVertex *oldV, AnchorVertex *newV, const QList< AnchorData *> &edges)
bool calculateTrunk(Orientation orientation, const GraphPath &trunkPath, const QList< QSimplexConstraint *> &constraints, const QList< AnchorData *> &variables)
Calculate the sizes for all anchors which are part of the trunk.
QList< QSimplexConstraint * > itemCenterConstraints[2]
qreal interpolationProgress[2]
QGraphicsAnchor * getAnchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge, QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge)
void removeEdge(Vertex *first, Vertex *second)
T dequeue()
Removes the head item in the queue and returns it.
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
void setupEdgesInterpolation(Orientation orientation)
Calculate interpolation parameters based on current Layout Size.
static QSet< T > fromList(const QList< T > &list)
QSizePolicy::Policy sizePolicy
QList< AnchorVertexPair * > simplifiedVertices[2]
AnchorVertex * internalVertex(const QPair< QGraphicsLayoutItem *, Qt::AnchorPoint > &itemEdge) const
void removeAnchor(AnchorVertex *firstVertex, AnchorVertex *secondVertex)
void restoreSimplifiedGraph(Orientation orientation)
virtual void close()
Calls QFile::flush() and closes the file.
#define qPrintable(string)
static QPair< QSimplexVariable *, QSimplexConstraint * > createSlack(QSimplexConstraint *sizeConstraint, qreal interval, slackType type)
void restoreVertices(Orientation orientation)
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
void createCenterAnchors(QGraphicsLayoutItem *item, Qt::AnchorPoint centerEdge)
By default, each item in the layout is represented internally as a single anchor in each direction...
void interpolateEdge(AnchorVertex *base, AnchorData *edge)
Calculate the current Edge size based on the current Layout size and the size the edge is supposed to...
QList< Key > keys() const
Returns a list containing all the keys in the hash, in an arbitrary order.
virtual void updateChildrenSizes()
QGraphicsAnchorLayout private methods and attributes.
QVector< AnchorData * > m_edges
qreal solveMin()
Minimize the original objective.
QGraphicsLayoutItem * parent
The QList class is a template class that provides lists.
void createItemEdges(QGraphicsLayoutItem *item)
virtual void updateChildrenSizes()