1 | // Copyright (C) 2016 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | // W A R N I N G |
5 | // ------------- |
6 | // |
7 | // This file is not part of the Qt Chart API. It exists purely as an |
8 | // implementation detail. This header file may change from version to |
9 | // version without notice, or even be removed. |
10 | // |
11 | // We mean it. |
12 | |
13 | #ifndef LINEARROWITEM_P_H |
14 | #define LINEARROWITEM_P_H |
15 | |
16 | #include <private/chartaxiselement_p.h> |
17 | #include <private/qabstractaxis_p.h> |
18 | #include <QtWidgets/QGraphicsLineItem> |
19 | #include <QtCharts/private/qchartglobal_p.h> |
20 | |
21 | QT_BEGIN_NAMESPACE |
22 | |
23 | class Q_CHARTS_PRIVATE_EXPORT LineArrowItem: public QGraphicsLineItem |
24 | { |
25 | public: |
26 | explicit LineArrowItem(ChartAxisElement *axis, QGraphicsItem *parent = 0) |
27 | : QGraphicsLineItem(parent), |
28 | m_axis(axis), |
29 | m_axisOrientation(axis->axis()->orientation()) |
30 | { |
31 | } |
32 | |
33 | protected: |
34 | void mousePressEvent(QGraphicsSceneMouseEvent *event) override |
35 | { |
36 | m_axis->axisSelected(); |
37 | QGraphicsLineItem::mousePressEvent(event); |
38 | } |
39 | |
40 | QRectF boundingRect() const override |
41 | { |
42 | return shape().boundingRect(); |
43 | } |
44 | |
45 | QPainterPath shape() const override |
46 | { |
47 | QPainterPath path = QGraphicsLineItem::shape(); |
48 | QRectF rect = path.boundingRect(); |
49 | path.addRect(rect: rect.adjusted(xp1: 0, yp1: 0, xp2: m_axisOrientation != Qt::Horizontal ? 8 : 0, yp2: m_axisOrientation != Qt::Vertical ? 8 : 0)); |
50 | return path; |
51 | } |
52 | |
53 | private: |
54 | ChartAxisElement *m_axis; |
55 | Qt::Orientation m_axisOrientation; |
56 | }; |
57 | |
58 | QT_END_NAMESPACE |
59 | |
60 | #endif /* LINEARROWITEM_P_H */ |
61 |