1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 or (at your option) any later version |
20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by |
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 |
22 | ** included in the packaging of this file. Please review the following |
23 | ** information to ensure the GNU General Public License requirements will |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
25 | ** |
26 | ** $QT_END_LICENSE$ |
27 | ** |
28 | ****************************************************************************/ |
29 | |
30 | // W A R N I N G |
31 | // ------------- |
32 | // |
33 | // This file is not part of the Qt Chart API. It exists purely as an |
34 | // implementation detail. This header file may change from version to |
35 | // version without notice, or even be removed. |
36 | // |
37 | // We mean it. |
38 | |
39 | #ifndef DECLARATIVECANDLESTICKSERIES_H |
40 | #define DECLARATIVECANDLESTICKSERIES_H |
41 | |
42 | #include <QtCharts/QCandlestickSeries> |
43 | #include <QtCharts/QCandlestickSet> |
44 | #include <QtQml/QQmlParserStatus> |
45 | #include <QtQuick/QQuickItem> |
46 | #include <private/declarativechartglobal_p.h> |
47 | |
48 | QT_CHARTS_BEGIN_NAMESPACE |
49 | |
50 | class DeclarativeAxes; |
51 | class QAbstractAxis; |
52 | |
53 | class Q_QMLCHARTS_PRIVATE_EXPORT DeclarativeCandlestickSet : public QCandlestickSet |
54 | { |
55 | Q_OBJECT |
56 | Q_PROPERTY(QString brushFilename READ brushFilename WRITE setBrushFilename NOTIFY brushFilenameChanged) |
57 | |
58 | public: |
59 | explicit DeclarativeCandlestickSet(qreal timestamp = 0.0, QObject *parent = nullptr); |
60 | void setBrushFilename(const QString &brushFilename); |
61 | QString brushFilename() const; |
62 | |
63 | Q_SIGNALS: |
64 | void brushFilenameChanged(const QString &brushFilename); |
65 | |
66 | private Q_SLOTS: |
67 | void handleBrushChanged(); |
68 | |
69 | private: |
70 | QString m_brushFilename; |
71 | QImage m_brushImage; |
72 | }; |
73 | |
74 | class DeclarativeCandlestickSeries : public QCandlestickSeries, public QQmlParserStatus |
75 | { |
76 | Q_OBJECT |
77 | Q_INTERFACES(QQmlParserStatus) |
78 | Q_PROPERTY(QtCharts::QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged) |
79 | Q_PROPERTY(QtCharts::QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged) |
80 | Q_PROPERTY(QtCharts::QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged) |
81 | Q_PROPERTY(QtCharts::QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged) |
82 | Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren) |
83 | Q_PROPERTY(QString brushFilename READ brushFilename WRITE setBrushFilename NOTIFY brushFilenameChanged) |
84 | Q_CLASSINFO("DefaultProperty" , "seriesChildren" ) |
85 | |
86 | public: |
87 | explicit DeclarativeCandlestickSeries(QQuickItem *parent = nullptr); |
88 | void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); } |
89 | QAbstractAxis *axisX() { return m_axes->axisX(); } |
90 | void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); } |
91 | QAbstractAxis *axisY() { return m_axes->axisY(); } |
92 | void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); } |
93 | QAbstractAxis *axisXTop() { return m_axes->axisXTop(); } |
94 | void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); } |
95 | QAbstractAxis *axisYRight() { return m_axes->axisYRight(); } |
96 | QQmlListProperty<QObject> seriesChildren(); |
97 | void setBrushFilename(const QString &brushFilename); |
98 | QString brushFilename() const; |
99 | |
100 | public: |
101 | Q_INVOKABLE DeclarativeCandlestickSet *at(int index); |
102 | Q_INVOKABLE bool append(DeclarativeCandlestickSet *set); |
103 | Q_INVOKABLE bool remove(DeclarativeCandlestickSet *set); |
104 | Q_INVOKABLE bool append(qreal open, qreal high, qreal low, qreal close, qreal timestamp); |
105 | Q_INVOKABLE bool remove(qreal timestamp); |
106 | Q_INVOKABLE bool insert(int index, DeclarativeCandlestickSet *set); |
107 | Q_INVOKABLE void clear(); |
108 | |
109 | public: // from QDeclarativeParserStatus |
110 | void classBegin(); |
111 | void componentComplete(); |
112 | |
113 | Q_SIGNALS: |
114 | void axisXChanged(QAbstractAxis *axis); |
115 | void axisYChanged(QAbstractAxis *axis); |
116 | void axisXTopChanged(QAbstractAxis *axis); |
117 | void axisYRightChanged(QAbstractAxis *axis); |
118 | void clicked(DeclarativeCandlestickSet *set); |
119 | void hovered(bool status, DeclarativeCandlestickSet *set); |
120 | void pressed(DeclarativeCandlestickSet *set); |
121 | void released(DeclarativeCandlestickSet *set); |
122 | void doubleClicked(DeclarativeCandlestickSet *set); |
123 | void brushFilenameChanged(const QString &brushFilename); |
124 | |
125 | public Q_SLOTS: |
126 | static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element); |
127 | void onClicked(QCandlestickSet *set); |
128 | void onHovered(bool status, QCandlestickSet *set); |
129 | void onPressed(QCandlestickSet *set); |
130 | void onReleased(QCandlestickSet *set); |
131 | void onDoubleClicked(QCandlestickSet *set); |
132 | |
133 | private Q_SLOTS: |
134 | void handleBrushChanged(); |
135 | |
136 | public: |
137 | DeclarativeAxes *m_axes; |
138 | |
139 | private: |
140 | QString m_brushFilename; |
141 | QImage m_brushImage; |
142 | }; |
143 | |
144 | QT_CHARTS_END_NAMESPACE |
145 | |
146 | #endif // DECLARATIVECANDLESTICKSERIES_H |
147 | |