summaryrefslogtreecommitdiffstats
path: root/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2020-05-05 15:28:46 +0200
committerMarc Mutz <marc.mutz@kdab.com>2020-05-07 21:06:02 +0200
commit2f8cfc2c608159bfbe6e085c37bd76bbaa5bd607 (patch)
tree59f4ae608e1fe8864ccd055f788bc2c94463fa27 /src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
parentfc65683e65191ed03ecd96a22a491c81c0717003 (diff)
QGraphicsAnchorLayout: port to QHVContainer [1/4]: local QHVContainer
This part of the patch changes the definitons of the member variables from 'C arrays of extent 2' to QHVContainer and fixes the code where ints were used to index into the array. To not drown in renames, keep the locally-defined enum 'Orientation', and create a local version of QHVContainer whose index operator is overloaded for both Qt::Orientation and the local 'Orientation'. Follow-up patches will remove these, then, completely. After this patch, NOrientations is no longer used, and consequently removed. Change-Id: I2a241520fce4beeb87fc0e26cd6ab18f324a956a Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp')
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp25
1 files changed, 6 insertions, 19 deletions
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
index 78549e4c24..9934255d25 100644
--- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -621,19 +621,6 @@ QString GraphPath::toString() const
QGraphicsAnchorLayoutPrivate::QGraphicsAnchorLayoutPrivate()
: calculateGraphCacheDirty(true), styleInfoDirty(true)
{
- for (int i = 0; i < NOrientations; ++i) {
- for (int j = 0; j < 3; ++j) {
- sizeHints[i][j] = -1;
- }
- interpolationProgress[i] = -1;
-
- spacings[i] = -1;
- graphHasConflicts[i] = false;
-
- layoutFirstVertex[i] = nullptr;
- layoutCentralVertex[i] = nullptr;
- layoutLastVertex[i] = nullptr;
- }
}
Qt::AnchorPoint QGraphicsAnchorLayoutPrivate::oppositeEdge(Qt::AnchorPoint edge)
@@ -2032,8 +2019,8 @@ QLayoutStyleInfo &QGraphicsAnchorLayoutPrivate::styleInfo() const
QStyle *style = w ? w->style() : QApplication::style();
cachedStyleInfo = QLayoutStyleInfo(style, wid);
- cachedStyleInfo.setDefaultSpacing(Qt::Horizontal, spacings[0]);
- cachedStyleInfo.setDefaultSpacing(Qt::Vertical, spacings[1]);
+ cachedStyleInfo.setDefaultSpacing(Qt::Horizontal, spacings[Qt::Horizontal]);
+ cachedStyleInfo.setDefaultSpacing(Qt::Vertical, spacings[Qt::Vertical]);
styleInfoDirty = false;
}
@@ -2953,9 +2940,9 @@ bool QGraphicsAnchorLayoutPrivate::hasConflicts() const
QGraphicsAnchorLayoutPrivate *that = const_cast<QGraphicsAnchorLayoutPrivate*>(this);
that->calculateGraphs();
- bool floatConflict = !m_floatItems[0].isEmpty() || !m_floatItems[1].isEmpty();
+ bool floatConflict = !m_floatItems[Qt::Horizontal].isEmpty() || !m_floatItems[Qt::Vertical].isEmpty();
- return graphHasConflicts[0] || graphHasConflicts[1] || floatConflict;
+ return graphHasConflicts[Qt::Horizontal] || graphHasConflicts[Qt::Vertical] || floatConflict;
}
#ifdef QT_DEBUG
@@ -2966,8 +2953,8 @@ void QGraphicsAnchorLayoutPrivate::dumpGraph(const QString &name)
qWarning("Could not write to %ls", qUtf16Printable(file.fileName()));
QString str = QString::fromLatin1("digraph anchorlayout {\nnode [shape=\"rect\"]\n%1}");
- QString dotContents = graph[0].serializeToDot();
- dotContents += graph[1].serializeToDot();
+ QString dotContents = graph[Qt::Horizontal].serializeToDot();
+ dotContents += graph[Qt::Vertical].serializeToDot();
file.write(str.arg(dotContents).toLocal8Bit());
file.close();