bar.cpp
37 lines
| 829 B
| text/x-c
|
CppLexer
sauimone
|
r118 | #include "bar_p.h" | ||
sauimone
|
r56 | #include <QDebug> | ||
Michal Klocek
|
r59 | #include <QPainter> | ||
sauimone
|
r283 | #include <QGraphicsSceneEvent> | ||
sauimone
|
r56 | |||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
sauimone
|
r425 | Bar::Bar(QString category, QGraphicsItem *parent) | ||
Michal Klocek
|
r679 | : QGraphicsRectItem(parent), | ||
Jani Honkonen
|
r609 | mCategory(category) | ||
sauimone
|
r56 | { | ||
sauimone
|
r412 | setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton); | ||
sauimone
|
r280 | setAcceptHoverEvents(true); | ||
sauimone
|
r56 | } | ||
sauimone
|
r412 | void Bar::mousePressEvent(QGraphicsSceneMouseEvent* event) | ||
sauimone
|
r256 | { | ||
sauimone
|
r412 | if (event->button() == Qt::LeftButton) { | ||
sauimone
|
r425 | emit clicked(mCategory); | ||
sauimone
|
r412 | } else if (event->button() == Qt::RightButton) { | ||
sauimone
|
r425 | emit rightClicked(mCategory); | ||
sauimone
|
r412 | } | ||
sauimone
|
r256 | } | ||
sauimone
|
r280 | void Bar::hoverEnterEvent(QGraphicsSceneHoverEvent* event) | ||
sauimone
|
r276 | { | ||
sauimone
|
r283 | emit hoverEntered(event->lastScreenPos()); | ||
sauimone
|
r276 | } | ||
sauimone
|
r283 | void Bar::hoverLeaveEvent(QGraphicsSceneHoverEvent* /*event*/) | ||
sauimone
|
r276 | { | ||
sauimone
|
r283 | emit hoverLeaved(); | ||
sauimone
|
r276 | } | ||
sauimone
|
r256 | #include "moc_bar_p.cpp" | ||
sauimone
|
r239 | |||
sauimone
|
r56 | QTCOMMERCIALCHART_END_NAMESPACE | ||