bar.cpp
38 lines
| 850 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), | ||
sauimone
|
r763 | m_category(category) | ||
sauimone
|
r56 | { | ||
Tero Ahola
|
r737 | setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton); | ||
sauimone
|
r280 | setAcceptHoverEvents(true); | ||
sauimone
|
r56 | } | ||
Tero Ahola
|
r737 | void Bar::mousePressEvent(QGraphicsSceneMouseEvent *event) | ||
sauimone
|
r256 | { | ||
sauimone
|
r412 | if (event->button() == Qt::LeftButton) { | ||
sauimone
|
r763 | emit clicked(m_category); | ||
sauimone
|
r412 | } else if (event->button() == Qt::RightButton) { | ||
sauimone
|
r763 | emit rightClicked(m_category); | ||
sauimone
|
r412 | } | ||
sauimone
|
r256 | } | ||
Tero Ahola
|
r737 | void Bar::hoverEnterEvent(QGraphicsSceneHoverEvent *event) | ||
sauimone
|
r276 | { | ||
sauimone
|
r283 | emit hoverEntered(event->lastScreenPos()); | ||
sauimone
|
r276 | } | ||
Tero Ahola
|
r737 | void Bar::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) | ||
sauimone
|
r276 | { | ||
Tero Ahola
|
r737 | Q_UNUSED(event) | ||
sauimone
|
r283 | emit hoverLeaved(); | ||
sauimone
|
r276 | } | ||
sauimone
|
r256 | #include "moc_bar_p.cpp" | ||
sauimone
|
r239 | |||
sauimone
|
r56 | QTCOMMERCIALCHART_END_NAMESPACE | ||