bar.cpp
68 lines
| 1.7 KiB
| text/x-c
|
CppLexer
Jani Honkonen
|
r794 | /**************************************************************************** | ||
** | ||||
Miikka Heikkinen
|
r2432 | ** Copyright (C) 2013 Digia Plc | ||
Jani Honkonen
|
r794 | ** All rights reserved. | ||
** For any questions to Digia, please use contact form at http://qt.digia.com | ||||
** | ||||
** This file is part of the Qt Commercial Charts Add-on. | ||||
** | ||||
** $QT_BEGIN_LICENSE$ | ||||
** Licensees holding valid Qt Commercial licenses may use this file in | ||||
** accordance with the Qt Commercial License Agreement provided with the | ||||
** Software or, alternatively, in accordance with the terms contained in | ||||
** a written agreement between you and Digia. | ||||
** | ||||
** If you have questions regarding the use of this file, please use | ||||
** contact form at http://qt.digia.com | ||||
** $QT_END_LICENSE$ | ||||
** | ||||
****************************************************************************/ | ||||
sauimone
|
r118 | #include "bar_p.h" | ||
Michal Klocek
|
r59 | #include <QPainter> | ||
sauimone
|
r283 | #include <QGraphicsSceneEvent> | ||
sauimone
|
r56 | |||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
sauimone
|
r1321 | Bar::Bar(QBarSet *barset, int index, QGraphicsItem *parent) : QGraphicsRectItem(parent), | ||
m_index(index), | ||||
sauimone
|
r1563 | m_barset(barset), | ||
m_hovering(false) | ||||
sauimone
|
r56 | { | ||
sauimone
|
r1321 | setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton); | ||
sauimone
|
r280 | setAcceptHoverEvents(true); | ||
sauimone
|
r56 | } | ||
sauimone
|
r1563 | Bar::~Bar() | ||
{ | ||||
// End hover event, if bar is deleted during it | ||||
if (m_hovering) { | ||||
emit hovered(false, m_barset); | ||||
} | ||||
} | ||||
Tero Ahola
|
r737 | void Bar::mousePressEvent(QGraphicsSceneMouseEvent *event) | ||
sauimone
|
r256 | { | ||
Jani Honkonen
|
r1011 | Q_UNUSED(event) | ||
sauimone
|
r1563 | emit clicked(m_index, m_barset); | ||
Michal Klocek
|
r1747 | QGraphicsItem::mousePressEvent(event); | ||
sauimone
|
r256 | } | ||
Tero Ahola
|
r737 | void Bar::hoverEnterEvent(QGraphicsSceneHoverEvent *event) | ||
sauimone
|
r276 | { | ||
Jani Honkonen
|
r978 | Q_UNUSED(event) | ||
sauimone
|
r1563 | m_hovering = true; | ||
emit hovered(true, m_barset); | ||||
Michal Klocek
|
r1747 | |||
sauimone
|
r276 | } | ||
Tero Ahola
|
r737 | void Bar::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) | ||
sauimone
|
r276 | { | ||
Tero Ahola
|
r737 | Q_UNUSED(event) | ||
sauimone
|
r1563 | m_hovering = false; | ||
emit hovered(false, m_barset); | ||||
sauimone
|
r276 | } | ||
sauimone
|
r256 | #include "moc_bar_p.cpp" | ||
sauimone
|
r239 | |||
sauimone
|
r56 | QTCOMMERCIALCHART_END_NAMESPACE | ||