diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-04-23 09:02:14 (GMT) |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-04-23 09:02:14 (GMT) |
commit | 429f29a305559313f92866ac19cf224ad1497b33 (patch) | |
tree | 8f8cc1dd5f6485d3282eec52c83a9fbeb71dd29e /examples | |
parent | 33afa6c1fbe230dec4eea435f9ad5d4141c128a8 (diff) | |
parent | be3916b7e4e8007394cbed40484ef6b696e90f2b (diff) | |
download | Qt-429f29a305559313f92866ac19cf224ad1497b33.zip Qt-429f29a305559313f92866ac19cf224ad1497b33.tar.gz Qt-429f29a305559313f92866ac19cf224ad1497b33.tar.bz2 |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into windows-7-multitouch
Diffstat (limited to 'examples')
-rw-r--r-- | examples/examples.pro | 2 | ||||
-rw-r--r-- | examples/graphicsview/elasticnodes/edge.cpp | 18 |
2 files changed, 14 insertions, 6 deletions
diff --git a/examples/examples.pro b/examples/examples.pro index 2c4fc81..41501a0 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -33,7 +33,7 @@ embedded:SUBDIRS += qws } contains(QT_CONFIG, opengl): SUBDIRS += opengl contains(QT_CONFIG, dbus): SUBDIRS += dbus -win32:!contains(QT_EDITION, OpenSource|Console):SUBDIRS += activeqt +win32: SUBDIRS += activeqt contains(QT_CONFIG, xmlpatterns): SUBDIRS += xmlpatterns contains(DEFINES, QT_NO_CURSOR): SUBDIRS -= mainwindows diff --git a/examples/graphicsview/elasticnodes/edge.cpp b/examples/graphicsview/elasticnodes/edge.cpp index 4018c25..eb02143 100644 --- a/examples/graphicsview/elasticnodes/edge.cpp +++ b/examples/graphicsview/elasticnodes/edge.cpp @@ -93,11 +93,16 @@ void Edge::adjust() QLineF line(mapFromItem(source, 0, 0), mapFromItem(dest, 0, 0)); qreal length = line.length(); - QPointF edgeOffset((line.dx() * 10) / length, (line.dy() * 10) / length); prepareGeometryChange(); - sourcePoint = line.p1() + edgeOffset; - destPoint = line.p2() - edgeOffset; + + if (length > qreal(20.)) { + QPointF edgeOffset((line.dx() * 10) / length, (line.dy() * 10) / length); + sourcePoint = line.p1() + edgeOffset; + destPoint = line.p2() - edgeOffset; + } else { + sourcePoint = destPoint = line.p1(); + } } QRectF Edge::boundingRect() const @@ -119,12 +124,15 @@ void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) if (!source || !dest) return; - // Draw the line itself QLineF line(sourcePoint, destPoint); + if (qFuzzyCompare(line.length(), qreal(0.))) + return; + + // Draw the line itself painter->setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); painter->drawLine(line); - // Draw the arrows if there's enough room + // Draw the arrows double angle = ::acos(line.dx() / line.length()); if (line.dy() >= 0) angle = TwoPi - angle; |