summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout_p.h35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.h b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h
index 25f7379517..4f746f0172 100644
--- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.h
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h
@@ -83,25 +83,22 @@ namespace QtGraphicsAnchorLayout {
Represents a vertex (anchorage point) in the internal graph
*/
-struct AnchorVertex {
- enum Type {
- Normal = 0,
- Pair
- };
-
+struct AnchorVertex
+{
AnchorVertex(QGraphicsLayoutItem *item, Qt::AnchorPoint edge)
- : m_item(item), m_edge(edge), m_type(Normal) {}
+ : m_item(item), m_edge(edge) {}
AnchorVertex()
- : m_item(nullptr), m_edge(Qt::AnchorPoint(0)), m_type(Normal) {}
+ : m_item(nullptr), m_edge(Qt::AnchorPoint(0)) {}
+
+ virtual ~AnchorVertex() = default;
#ifdef QT_DEBUG
- inline QString toString() const;
+ virtual inline QString toString() const;
#endif
QGraphicsLayoutItem *m_item;
Qt::AnchorPoint m_edge;
- uint m_type : 1;
// Current distance from this vertex to the layout edge (Left or Top)
// Value is calculated from the current anchors sizes.
@@ -250,8 +247,8 @@ struct ParallelAnchorData : public AnchorData
struct AnchorVertexPair : public AnchorVertex {
AnchorVertexPair(AnchorVertex *v1, AnchorVertex *v2, AnchorData *data)
- : AnchorVertex(), m_first(v1), m_second(v2), m_removedAnchor(data) {
- m_type = AnchorVertex::Pair;
+ : AnchorVertex(), m_first(v1), m_second(v2), m_removedAnchor(data)
+ {
}
AnchorVertex *m_first;
@@ -260,17 +257,21 @@ struct AnchorVertexPair : public AnchorVertex {
AnchorData *m_removedAnchor;
QList<AnchorData *> m_firstAnchors;
QList<AnchorData *> m_secondAnchors;
+
+#ifdef QT_DEBUG
+ inline QString toString() const override
+ {
+ return QString::fromLatin1("(%1, %2)").arg(m_first->toString(), m_second->toString());
+ }
+#endif
};
#ifdef QT_DEBUG
inline QString AnchorVertex::toString() const
{
- if (m_type == Pair) {
- const AnchorVertexPair *vp = static_cast<const AnchorVertexPair *>(this);
- return QString::fromLatin1("(%1, %2)").arg(vp->m_first->toString(), vp->m_second->toString());
- } else if (!m_item) {
+ if (!m_item)
return QString::fromLatin1("NULL_%1").arg(quintptr(this));
- }
+
QString edge;
switch (m_edge) {
case Qt::AnchorLeft: