bar.cpp
71 lines
| 1.9 KiB
| text/x-c
|
CppLexer
|
r794 | /**************************************************************************** | ||
** | ||||
|
r2688 | ** Copyright (C) 2014 Digia Plc | ||
|
r794 | ** All rights reserved. | ||
** For any questions to Digia, please use contact form at http://qt.digia.com | ||||
** | ||||
|
r2574 | ** This file is part of the Qt Enterprise Charts Add-on. | ||
|
r794 | ** | ||
** $QT_BEGIN_LICENSE$ | ||||
|
r2574 | ** Licensees holding valid Qt Enterprise licenses may use this file in | ||
** accordance with the Qt Enterprise License Agreement provided with the | ||||
|
r794 | ** 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$ | ||||
** | ||||
****************************************************************************/ | ||||
|
r118 | #include "bar_p.h" | ||
|
r59 | #include <QPainter> | ||
|
r283 | #include <QGraphicsSceneEvent> | ||
|
r56 | |||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
|
r1321 | Bar::Bar(QBarSet *barset, int index, QGraphicsItem *parent) : QGraphicsRectItem(parent), | ||
m_index(index), | ||||
|
r1563 | m_barset(barset), | ||
m_hovering(false) | ||||
|
r56 | { | ||
|
r1321 | setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton); | ||
|
r280 | setAcceptHoverEvents(true); | ||
|
r56 | } | ||
|
r1563 | Bar::~Bar() | ||
{ | ||||
// End hover event, if bar is deleted during it | ||||
if (m_hovering) { | ||||
emit hovered(false, m_barset); | ||||
|
r2600 | emit hovered(false, m_index, m_barset); | ||
|
r1563 | } | ||
} | ||||
|
r737 | void Bar::mousePressEvent(QGraphicsSceneMouseEvent *event) | ||
|
r256 | { | ||
|
r1011 | Q_UNUSED(event) | ||
|
r1563 | emit clicked(m_index, m_barset); | ||
|
r1747 | QGraphicsItem::mousePressEvent(event); | ||
|
r256 | } | ||
|
r737 | void Bar::hoverEnterEvent(QGraphicsSceneHoverEvent *event) | ||
|
r276 | { | ||
|
r978 | Q_UNUSED(event) | ||
|
r1563 | m_hovering = true; | ||
emit hovered(true, m_barset); | ||||
|
r2600 | emit hovered(true, m_index, m_barset); | ||
|
r1747 | |||
|
r276 | } | ||
|
r737 | void Bar::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) | ||
|
r276 | { | ||
|
r737 | Q_UNUSED(event) | ||
|
r1563 | m_hovering = false; | ||
emit hovered(false, m_barset); | ||||
|
r2600 | emit hovered(false, m_index, m_barset); | ||
|
r276 | } | ||
|
r256 | #include "moc_bar_p.cpp" | ||
|
r239 | |||
|
r56 | QTCOMMERCIALCHART_END_NAMESPACE | ||