summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan-Arve Sæther <jan-arve.saether@nokia.com>2009-08-18 12:34:24 (GMT)
committerJan-Arve Sæther <jan-arve.saether@nokia.com>2009-08-18 12:34:24 (GMT)
commit14f85a02b7c13b0afc1195df815093640fd7b83e (patch)
tree0a6966d307cfe2db6bb5053039729d5e59d14151
parent8e6c5ceb5b30bf3e9c50a9bf0710b7a0919068b6 (diff)
downloadQt-14f85a02b7c13b0afc1195df815093640fd7b83e.zip
Qt-14f85a02b7c13b0afc1195df815093640fd7b83e.tar.gz
Qt-14f85a02b7c13b0afc1195df815093640fd7b83e.tar.bz2
Only compile in toString() functions if we are compiling in debug mode.
Also, only include the "name" member to AnchorData if we are compiling in debug mode.
-rw-r--r--src/gui/graphicsview/qgraph_p.h10
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.cpp13
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.h24
3 files changed, 32 insertions, 15 deletions
diff --git a/src/gui/graphicsview/qgraph_p.h b/src/gui/graphicsview/qgraph_p.h
index 6cb843f..c228902 100644
--- a/src/gui/graphicsview/qgraph_p.h
+++ b/src/gui/graphicsview/qgraph_p.h
@@ -91,14 +91,16 @@ public:
void createEdge(Vertex *first, Vertex *second, EdgeData *data)
{
// Creates a bidirectional edge
-#if 0
+#if defined(QT_DEBUG) && 0
qDebug("Graph::createEdge(): %s",
qPrintable(QString::fromAscii("%1-%2")
.arg(first->toString()).arg(second->toString())));
#endif
if (edgeData(first, second)) {
+#ifdef QT_DEBUG
qWarning(qPrintable(QString::fromAscii("%1-%2 already has an edge")
.arg(first->toString()).arg(second->toString())));
+#endif
}
createDirectedEdge(first, second, data);
createDirectedEdge(second, first, data);
@@ -107,7 +109,7 @@ public:
void removeEdge(Vertex *first, Vertex *second)
{
// Removes a bidirectional edge
-#if 0
+#if defined(QT_DEBUG) && 0
qDebug("Graph::removeEdge(): %s",
qPrintable(QString::fromAscii("%1-%2")
.arg(first->toString()).arg(second->toString())));
@@ -120,7 +122,7 @@ public:
EdgeData *takeEdge(Vertex* first, Vertex* second)
{
-#if 0
+#if defined(QT_DEBUG) && 0
qDebug("Graph::takeEdge(): %s",
qPrintable(QString::fromAscii("%1-%2")
.arg(first->toString()).arg(second->toString())));
@@ -169,6 +171,7 @@ public:
return conns;
}
+#if defined(QT_DEBUG)
QString serializeToDot() { // traversal
QString strVertices;
QString edges;
@@ -195,6 +198,7 @@ public:
}
return QString::fromAscii("%1\n%2\n").arg(strVertices).arg(edges);
}
+#endif
Vertex *rootVertex() const
{
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
index ba2aadf..4e45fc7 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -217,6 +217,7 @@ void SequentialAnchorData::refreshSizeHints(qreal effectiveSpacing)
sizeAtMaximum = prefSize;
}
+#ifdef QT_DEBUG
void AnchorData::dump(int indent) {
if (type == Parallel) {
qDebug("%*s type: parallel:", indent, "");
@@ -235,6 +236,8 @@ void AnchorData::dump(int indent) {
}
}
+#endif
+
QSimplexConstraint *GraphPath::constraint(const GraphPath &path) const
{
// Calculate
@@ -262,6 +265,7 @@ QSimplexConstraint *GraphPath::constraint(const GraphPath &path) const
return c;
}
+#ifdef QT_DEBUG
QString GraphPath::toString() const
{
QString string(QLatin1String("Path: "));
@@ -273,7 +277,7 @@ QString GraphPath::toString() const
return string;
}
-
+#endif
QGraphicsAnchorLayoutPrivate::QGraphicsAnchorLayoutPrivate()
: calculateGraphCacheDirty(1)
@@ -336,7 +340,7 @@ static bool simplifySequentialChunk(Graph<AnchorVertex, AnchorData> *graph,
AnchorVertex *after)
{
int i;
-#if 0
+#if defined(QT_DEBUG) && 0
QString strVertices;
for (i = 0; i < vertices.count(); ++i)
strVertices += QString::fromAscii("%1 - ").arg(vertices.at(i)->toString());
@@ -536,7 +540,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP
// The complete path of the sequence to simplify is: beforeSequence, <candidates>, afterSequence
// where beforeSequence and afterSequence are the endpoints where the anchor is inserted
// between.
-#if 0
+#if defined(QT_DEBUG) && 0
// ### DEBUG
QString strCandidates;
for (i = 0; i < candidates.count(); ++i)
@@ -1086,8 +1090,9 @@ void QGraphicsAnchorLayoutPrivate::addAnchor(QGraphicsLayoutItem *firstItem,
// so we still know that the anchor direction is from 1 to 2.
data->from = v1;
data->to = v2;
+#ifdef QT_DEBUG
data->name = QString::fromAscii("%1 --to--> %2").arg(v1->toString()).arg(v2->toString());
-
+#endif
// Keep track of anchors that are connected to the layout 'edges'
data->isLayoutAnchor = (v1->m_item == q || v2->m_item == q);
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
index 144465a..7e7cee8 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
@@ -67,8 +67,9 @@ struct AnchorVertex {
AnchorVertex()
: m_item(0), m_edge(QGraphicsAnchorLayout::Edge(0)) {}
+#ifdef QT_DEBUG
inline QString toString() const;
-
+#endif
QGraphicsLayoutItem *m_item;
QGraphicsAnchorLayout::Edge m_edge;
@@ -77,6 +78,7 @@ struct AnchorVertex {
qreal distance;
};
+#ifdef QT_DEBUG
inline QString AnchorVertex::toString() const
{
if (!this || !m_item) {
@@ -117,7 +119,7 @@ inline QString AnchorVertex::toString() const
edge.insert(0, QLatin1String("%1_"));
return edge.arg(itemName);
}
-
+#endif
/*!
\internal
@@ -157,10 +159,11 @@ struct AnchorData : public QSimplexVariable {
virtual ~AnchorData() {}
+#ifdef QT_DEBUG
void dump(int indent = 2);
-
inline QString toString() const;
QString name;
+#endif
// Anchor is semantically directed
AnchorVertex *from;
@@ -195,19 +198,20 @@ protected:
isLayoutAnchor(false) {}
};
+#ifdef QT_DEBUG
inline QString AnchorData::toString() const
{
return QString::fromAscii("Anchor(%1)").arg(name);
- //return QString().sprintf("Anchor %%1 <Min %.1f Pref %.1f Max %.1f>",
- // minSize, prefSize, maxSize).arg(name);
}
-
+#endif
struct SequentialAnchorData : public AnchorData
{
SequentialAnchorData() : AnchorData(AnchorData::Sequential)
{
+#ifdef QT_DEBUG
name = QLatin1String("SequentialAnchorData");
+#endif
}
virtual void updateChildrenSizes();
@@ -216,7 +220,9 @@ struct SequentialAnchorData : public AnchorData
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
@@ -235,7 +241,9 @@ struct ParallelAnchorData : public AnchorData
Q_ASSERT(first->to == second->to);
from = first->from;
to = first->to;
+#ifdef QT_DEBUG
name = QString::fromAscii("%1 | %2").arg(first->toString(), second->toString());
+#endif
}
virtual void updateChildrenSizes();
@@ -262,9 +270,9 @@ public:
GraphPath() {};
QSimplexConstraint *constraint(const GraphPath &path) const;
-
+#ifdef QT_DEBUG
QString toString() const;
-
+#endif
QSet<AnchorData *> positives;
QSet<AnchorData *> negatives;
};