summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>2009-10-28 14:17:18 (GMT)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>2009-10-28 14:17:18 (GMT)
commite77732c9b0c8b8313138306d723f5227cfbc124d (patch)
treecd5048827c7a6d4f5f35b43c307ff17daae8dd5e
parent1607216cc6292ef9a4af68ce6d29dc79fffea92c (diff)
downloadQt-e77732c9b0c8b8313138306d723f5227cfbc124d.zip
Qt-e77732c9b0c8b8313138306d723f5227cfbc124d.tar.gz
Qt-e77732c9b0c8b8313138306d723f5227cfbc124d.tar.bz2
QGAL: set the orientation bit for complex anchors
Sets the orientation bit for complex anchors. This is being done in the constructor, and I did a minor refactor to make the constructor of SequentialAnchor take the list of vertices and anchors that it is simplifying. Before that we set one of those directly in the structure and the other via a setter function. The tests were passing because right now, complex anchors do not use the orientation bit, while some Normal anchors use in the refreshSizeHints() function (to get either the width() or height() of an item). Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.cpp6
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.h15
2 files changed, 8 insertions, 13 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
index b4666c6..ac81ddc 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -577,18 +577,18 @@ static AnchorData *createSequence(Graph<AnchorVertex, AnchorData> *graph,
qDebug("simplifying [%s] to [%s - %s]", qPrintable(strPath), qPrintable(before->toString()), qPrintable(after->toString()));
#endif
- SequentialAnchorData *sequence = new SequentialAnchorData;
AnchorVertex *prev = before;
+ QVector<AnchorData *> edges;
for (int i = 0; i <= orderedVertices.count(); ++i) {
AnchorVertex *next = (i < orderedVertices.count()) ? orderedVertices.at(i) : after;
AnchorData *ad = graph->takeEdge(prev, next);
Q_ASSERT(ad);
- sequence->m_edges.append(ad);
+ edges.append(ad);
prev = next;
}
- sequence->setVertices(orderedVertices);
+ SequentialAnchorData *sequence = new SequentialAnchorData(orderedVertices, edges);
sequence->from = before;
sequence->to = after;
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
index 8eb65c5..600b06c 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
@@ -223,11 +223,13 @@ inline QString AnchorData::toString() const
struct SequentialAnchorData : public AnchorData
{
- SequentialAnchorData() : AnchorData()
+ SequentialAnchorData(const QVector<AnchorVertex *> &vertices, const QVector<AnchorData *> &edges)
+ : AnchorData(), m_children(vertices), m_edges(edges)
{
type = AnchorData::Sequential;
+ orientation = m_edges.at(0)->orientation;
#ifdef QT_DEBUG
- name = QLatin1String("SequentialAnchorData");
+ name = QString::fromAscii("%1 -- %2").arg(vertices.first()->toString(), vertices.last()->toString());
#endif
}
@@ -236,14 +238,6 @@ struct SequentialAnchorData : public AnchorData
bool refreshSizeHints_helper(qreal effectiveSpacing, bool refreshChildren = true);
- void setVertices(const QVector<AnchorVertex*> &vertices)
- {
- m_children = vertices;
-#ifdef QT_DEBUG
- name = QString::fromAscii("%1 -- %2").arg(vertices.first()->toString(), vertices.last()->toString());
-#endif
- }
-
QVector<AnchorVertex*> m_children; // list of vertices in the sequence
QVector<AnchorData*> m_edges; // keep the list of edges too.
};
@@ -254,6 +248,7 @@ struct ParallelAnchorData : public AnchorData
: AnchorData(), firstEdge(first), secondEdge(second)
{
type = AnchorData::Parallel;
+ orientation = first->orientation;
// ### Those asserts force that both child anchors have the same direction,
// but can't we simplify a pair of anchors in opposite directions?