summaryrefslogtreecommitdiffstats
path: root/src/chartsqml2/declarativecandlestickseries_p.h
blob: 8c98742b5c45d54d96ef26fdb018e616f67b72ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Charts module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:COMM$
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** $QT_END_LICENSE$
**
**
**
**
**
**
**
**
**
****************************************************************************/

//  W A R N I N G
//  -------------
//
// This file is not part of the Qt Chart API.  It exists purely as an
// implementation detail.  This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.

#ifndef DECLARATIVECANDLESTICKSERIES_H
#define DECLARATIVECANDLESTICKSERIES_H

#include <QtCharts/QCandlestickSeries>
#include <QtCharts/QCandlestickSet>
#include <QtQml/QQmlParserStatus>
#include <QtQuick/QQuickItem>
#include <private/declarativechartglobal_p.h>

QT_CHARTS_BEGIN_NAMESPACE

class DeclarativeAxes;
class QAbstractAxis;

class Q_QMLCHARTS_PRIVATE_EXPORT DeclarativeCandlestickSet : public QCandlestickSet
{
    Q_OBJECT
    Q_PROPERTY(QString brushFilename READ brushFilename WRITE setBrushFilename NOTIFY brushFilenameChanged)

public:
    explicit DeclarativeCandlestickSet(qreal timestamp = 0.0, QObject *parent = nullptr);
    void setBrushFilename(const QString &brushFilename);
    QString brushFilename() const;

Q_SIGNALS:
    void brushFilenameChanged(const QString &brushFilename);

private Q_SLOTS:
    void handleBrushChanged();

private:
    QString m_brushFilename;
    QImage m_brushImage;
};

class DeclarativeCandlestickSeries : public QCandlestickSeries, public QQmlParserStatus
{
    Q_OBJECT
    Q_INTERFACES(QQmlParserStatus)
    Q_PROPERTY(QtCharts::QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged)
    Q_PROPERTY(QtCharts::QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged)
    Q_PROPERTY(QtCharts::QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged)
    Q_PROPERTY(QtCharts::QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged)
    Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren)
    Q_PROPERTY(QString brushFilename READ brushFilename WRITE setBrushFilename NOTIFY brushFilenameChanged)
    Q_CLASSINFO("DefaultProperty", "seriesChildren")

public:
    explicit DeclarativeCandlestickSeries(QQuickItem *parent = nullptr);
    void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); }
    QAbstractAxis *axisX() { return m_axes->axisX(); }
    void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); }
    QAbstractAxis *axisY() { return m_axes->axisY(); }
    void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); }
    QAbstractAxis *axisXTop() { return m_axes->axisXTop(); }
    void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); }
    QAbstractAxis *axisYRight() { return m_axes->axisYRight(); }
    QQmlListProperty<QObject> seriesChildren();
    void setBrushFilename(const QString &brushFilename);
    QString brushFilename() const;

public:
    Q_INVOKABLE DeclarativeCandlestickSet *at(int index);
    Q_INVOKABLE bool append(DeclarativeCandlestickSet *set);
    Q_INVOKABLE bool remove(DeclarativeCandlestickSet *set);
    Q_INVOKABLE bool append(qreal open, qreal high, qreal low, qreal close, qreal timestamp);
    Q_INVOKABLE bool remove(qreal timestamp);
    Q_INVOKABLE bool insert(int index, DeclarativeCandlestickSet *set);
    Q_INVOKABLE void clear();

public: // from QDeclarativeParserStatus
    void classBegin();
    void componentComplete();

Q_SIGNALS:
    void axisXChanged(QAbstractAxis *axis);
    void axisYChanged(QAbstractAxis *axis);
    void axisXTopChanged(QAbstractAxis *axis);
    void axisYRightChanged(QAbstractAxis *axis);
    void clicked(DeclarativeCandlestickSet *set);
    void hovered(bool status, DeclarativeCandlestickSet *set);
    void pressed(DeclarativeCandlestickSet *set);
    void released(DeclarativeCandlestickSet *set);
    void doubleClicked(DeclarativeCandlestickSet *set);
    void brushFilenameChanged(const QString &brushFilename);

public Q_SLOTS:
    static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element);
    void onClicked(QCandlestickSet *set);
    void onHovered(bool status, QCandlestickSet *set);
    void onPressed(QCandlestickSet *set);
    void onReleased(QCandlestickSet *set);
    void onDoubleClicked(QCandlestickSet *set);

private Q_SLOTS:
    void handleBrushChanged();

public:
    DeclarativeAxes *m_axes;

private:
    QString m_brushFilename;
    QImage m_brushImage;
};

QT_CHARTS_END_NAMESPACE

#endif // DECLARATIVECANDLESTICKSERIES_H