##// END OF EJS Templates
Callout example: removed unnecessary variable
Marek Rosa -
r2379:9645dba0fec9
parent child
Show More
@@ -70,18 +70,13 void Callout::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
70 70
71 71 void Callout::mousePressEvent(QGraphicsSceneMouseEvent *event)
72 72 {
73 if (m_rect.contains(event->pos())) {
74 m_clickOffset = event->pos();
75 event->setAccepted(true);
76 } else {
77 event->setAccepted(false);
78 }
73 event->setAccepted(true);
79 74 }
80 75
81 76 void Callout::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
82 77 {
83 78 if (event->buttons() & Qt::LeftButton){
84 setPos(mapToParent(event->pos() - m_clickOffset));
79 setPos(mapToParent(event->pos() - event->buttonDownPos(Qt::LeftButton)));
85 80 event->setAccepted(true);
86 81 } else {
87 82 event->setAccepted(false);
@@ -94,7 +89,7 void Callout::setText(const QString &text)
94 89 QFontMetrics metrics(m_font);
95 90 m_textRect = metrics.boundingRect(QRect(0, 0, 150, 150), Qt::AlignLeft, m_text);
96 91 m_textRect.translate(5, 5);
97 prepareGeometryChange();
92 prepareGeometryChange();
98 93 m_rect = m_textRect.adjusted(-5, -5, 5, 5);
99 94 }
100 95
@@ -27,7 +27,6 private:
27 27 QRectF m_rect;
28 28 QPointF m_anchor;
29 29 QFont m_font;
30 QPointF m_clickOffset;
31 30 };
32 31
33 32 #endif // CALLOUT_H
General Comments 0
You need to be logged in to leave comments. Login now