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 DECLARATIVECANDLESTICKSERIES_H
14#define DECLARATIVECANDLESTICKSERIES_H
15
16#include <QtQml/qqmlregistration.h>
17#include <QtCharts/QCandlestickSeries>
18#include <QtCharts/qabstractaxis.h>
19#include <QtCharts/QCandlestickSet>
20#include <QtQml/QQmlParserStatus>
21#include <QtQuick/QQuickItem>
22#include <private/declarativechartglobal_p.h>
23
24QT_BEGIN_NAMESPACE
25
26class DeclarativeAxes;
27
28class Q_CHARTSQML_PRIVATE_EXPORT DeclarativeCandlestickSet : public QCandlestickSet
29{
30 Q_OBJECT
31 Q_PROPERTY(QString brushFilename READ brushFilename WRITE setBrushFilename NOTIFY brushFilenameChanged)
32 QML_NAMED_ELEMENT(CandlestickSet)
33 QML_ADDED_IN_VERSION(2, 2)
34
35public:
36 explicit DeclarativeCandlestickSet(qreal timestamp = 0.0, QObject *parent = nullptr);
37 void setBrushFilename(const QString &brushFilename);
38 QString brushFilename() const;
39
40Q_SIGNALS:
41 void brushFilenameChanged(const QString &brushFilename);
42
43private Q_SLOTS:
44 void handleBrushChanged();
45
46private:
47 QString m_brushFilename;
48 QImage m_brushImage;
49};
50
51class DeclarativeCandlestickSeries : public QCandlestickSeries, public QQmlParserStatus
52{
53 Q_OBJECT
54 Q_INTERFACES(QQmlParserStatus)
55 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged)
56 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged)
57 Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged)
58 Q_PROPERTY(QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged)
59 Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren)
60 Q_PROPERTY(QString brushFilename READ brushFilename WRITE setBrushFilename NOTIFY brushFilenameChanged)
61 Q_CLASSINFO("DefaultProperty", "seriesChildren")
62 QML_NAMED_ELEMENT(CandlestickSeries)
63 QML_ADDED_IN_VERSION(2, 2)
64
65public:
66 explicit DeclarativeCandlestickSeries(QQuickItem *parent = nullptr);
67 void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); }
68 QAbstractAxis *axisX() { return m_axes->axisX(); }
69 void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); }
70 QAbstractAxis *axisY() { return m_axes->axisY(); }
71 void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); }
72 QAbstractAxis *axisXTop() { return m_axes->axisXTop(); }
73 void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); }
74 QAbstractAxis *axisYRight() { return m_axes->axisYRight(); }
75 QQmlListProperty<QObject> seriesChildren();
76 void setBrushFilename(const QString &brushFilename);
77 QString brushFilename() const;
78
79public:
80 Q_INVOKABLE DeclarativeCandlestickSet *at(int index);
81 Q_INVOKABLE bool append(DeclarativeCandlestickSet *set);
82 Q_INVOKABLE bool remove(DeclarativeCandlestickSet *set);
83 Q_INVOKABLE bool append(qreal open, qreal high, qreal low, qreal close, qreal timestamp);
84 Q_INVOKABLE bool remove(qreal timestamp);
85 Q_INVOKABLE bool insert(int index, DeclarativeCandlestickSet *set);
86 Q_INVOKABLE void clear();
87
88public: // from QDeclarativeParserStatus
89 void classBegin() override;
90 void componentComplete() override;
91
92Q_SIGNALS:
93 void axisXChanged(QAbstractAxis *axis);
94 void axisYChanged(QAbstractAxis *axis);
95 void axisXTopChanged(QAbstractAxis *axis);
96 void axisYRightChanged(QAbstractAxis *axis);
97 void clicked(DeclarativeCandlestickSet *set);
98 void hovered(bool status, DeclarativeCandlestickSet *set);
99 void pressed(DeclarativeCandlestickSet *set);
100 void released(DeclarativeCandlestickSet *set);
101 void doubleClicked(DeclarativeCandlestickSet *set);
102 void brushFilenameChanged(const QString &brushFilename);
103
104public Q_SLOTS:
105 static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element);
106 void onClicked(QCandlestickSet *set);
107 void onHovered(bool status, QCandlestickSet *set);
108 void onPressed(QCandlestickSet *set);
109 void onReleased(QCandlestickSet *set);
110 void onDoubleClicked(QCandlestickSet *set);
111
112private Q_SLOTS:
113 void handleBrushChanged();
114
115public:
116 DeclarativeAxes *m_axes;
117
118private:
119 QString m_brushFilename;
120 QImage m_brushImage;
121};
122
123QT_END_NAMESPACE
124
125#endif // DECLARATIVECANDLESTICKSERIES_H
126

source code of qtcharts/src/chartsqml2/declarativecandlestickseries_p.h