diff options
author | Eduardo M. Fleury <eduardo.fleury@openbossa.org> | 2009-05-28 17:41:37 (GMT) |
---|---|---|
committer | Eduardo M. Fleury <eduardo.fleury@openbossa.org> | 2009-07-22 18:04:12 (GMT) |
commit | 35f33618ec766e4922977c31a5f522c261b19c61 (patch) | |
tree | 893236423058a733d881cd0b2e86a4122a5c6879 /src/gui/graphicsview/qgraph_p.h | |
parent | 4cb58c203242e6e24d1628673b145a038c93531f (diff) | |
download | Qt-35f33618ec766e4922977c31a5f522c261b19c61.zip Qt-35f33618ec766e4922977c31a5f522c261b19c61.tar.gz Qt-35f33618ec766e4922977c31a5f522c261b19c61.tar.bz2 |
QGraphicsAnchorLayout: Apply Jan-Arve's patch
Applying the patch sent by email.
Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
Diffstat (limited to 'src/gui/graphicsview/qgraph_p.h')
-rw-r--r-- | src/gui/graphicsview/qgraph_p.h | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/gui/graphicsview/qgraph_p.h b/src/gui/graphicsview/qgraph_p.h index 4a6bc8f..e487eca 100644 --- a/src/gui/graphicsview/qgraph_p.h +++ b/src/gui/graphicsview/qgraph_p.h @@ -68,7 +68,8 @@ public: return iterator(this,false); } - EdgeData *edgeData(Vertex *first, Vertex *second) { + EdgeData *edgeData(Vertex* first, Vertex* second) { + Q_ASSERT(m_graph.value(first)); return m_graph.value(first)->value(second); } @@ -81,11 +82,20 @@ public: void removeEdge(Vertex *first, Vertex *second) { - // Creates a bidirectional edge + // Removes a bidirectional edge EdgeData *data = edgeData(first, second); + removeDirectedEdge(first, second); + removeDirectedEdge(second, first); if (data) delete data; + } + + EdgeData *takeEdge(Vertex* first, Vertex* second) + { + // Removes a bidirectional edge + EdgeData *data = edgeData(first, second); removeDirectedEdge(first, second); removeDirectedEdge(second, first); + return data; } QList<Vertex *> adjacentVertices(Vertex *vertex) const @@ -163,12 +173,13 @@ protected: void removeDirectedEdge(Vertex *from, Vertex *to) { QHash<Vertex *, EdgeData *> *adjacentToFirst = m_graph.value(from); - adjacentToFirst->remove(to); - if (adjacentToFirst->isEmpty()) { - //nobody point to 'from' so we can remove it from the graph - QHash<Vertex *, EdgeData *> *adjacentToFirst = m_graph.take(from); - delete adjacentToFirst; - delete from; + if (adjacentToFirst) { + adjacentToFirst->remove(to); + if (adjacentToFirst->isEmpty()) { + //nobody point to 'from' so we can remove it from the graph + m_graph.remove(from); + delete adjacentToFirst; + } } } |