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 DECLARATIVEBOXPLOT_H
14#define DECLARATIVEBOXPLOT_H
15
16#include <QtQml/qqmlregistration.h>
17#include <QtCharts/QBoxSet>
18#include <private/declarativeaxes_p.h>
19#include <QtCharts/QBoxPlotSeries>
20#include <private/declarativechartglobal_p.h>
21
22#include <QtQuick/QQuickItem>
23#include <QtQml/QQmlParserStatus>
24
25QT_BEGIN_NAMESPACE
26
27class Q_CHARTSQML_PRIVATE_EXPORT DeclarativeBoxSet : public QBoxSet
28{
29 Q_OBJECT
30 Q_PROPERTY(QVariantList values READ values WRITE setValues)
31 Q_PROPERTY(QString label READ label WRITE setLabel)
32 Q_PROPERTY(int count READ count)
33 Q_PROPERTY(QString brushFilename READ brushFilename WRITE setBrushFilename NOTIFY brushFilenameChanged REVISION(1, 4))
34 Q_ENUMS(ValuePositions)
35 QML_NAMED_ELEMENT(BoxSet)
36 QML_ADDED_IN_VERSION(1, 3)
37 QML_EXTRA_VERSION(2, 0)
38
39public: // duplicate from QBoxSet
40 enum ValuePositions {
41 LowerExtreme = 0x0,
42 LowerQuartile,
43 Median,
44 UpperQuartile,
45 UpperExtreme
46 };
47
48public:
49 explicit DeclarativeBoxSet(const QString label = QString(), QObject *parent = 0);
50 QVariantList values();
51 void setValues(QVariantList values);
52 QString brushFilename() const;
53 void setBrushFilename(const QString &brushFilename);
54
55public: // From QBoxSet
56 Q_INVOKABLE void append(qreal value) { QBoxSet::append(value); }
57 Q_INVOKABLE void clear() {QBoxSet::clear(); }
58 Q_INVOKABLE qreal at(int index) { return QBoxSet::at(index); }
59 Q_INVOKABLE void setValue(int index, qreal value) { QBoxSet::setValue(index, value); }
60
61Q_SIGNALS:
62 void changedValues();
63 void changedValue(int index);
64 Q_REVISION(1, 4) void brushFilenameChanged(const QString &brushFilename);
65
66private Q_SLOTS:
67 void handleBrushChanged();
68
69private:
70 QString m_brushFilename;
71 QImage m_brushImage;
72};
73
74class Q_CHARTSQML_PRIVATE_EXPORT DeclarativeBoxPlotSeries : public QBoxPlotSeries, public QQmlParserStatus
75{
76 Q_OBJECT
77 Q_INTERFACES(QQmlParserStatus)
78 Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged)
79 Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged)
80 Q_PROPERTY(QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged)
81 Q_PROPERTY(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 REVISION(1, 4))
84 Q_CLASSINFO("DefaultProperty", "seriesChildren")
85 QML_NAMED_ELEMENT(BoxPlotSeries)
86 QML_ADDED_IN_VERSION(1, 3)
87 QML_EXTRA_VERSION(2, 0)
88
89public:
90 explicit DeclarativeBoxPlotSeries(QQuickItem *parent = 0);
91 QAbstractAxis *axisX() { return m_axes->axisX(); }
92 void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); }
93 QAbstractAxis *axisY() { return m_axes->axisY(); }
94 void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); }
95 QAbstractAxis *axisXTop() { return m_axes->axisXTop(); }
96 void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); }
97 QAbstractAxis *axisYRight() { return m_axes->axisYRight(); }
98 void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); }
99 QQmlListProperty<QObject> seriesChildren();
100 QString brushFilename() const;
101 void setBrushFilename(const QString &brushFilename);
102
103public:
104 Q_INVOKABLE DeclarativeBoxSet *at(int index);
105 Q_INVOKABLE DeclarativeBoxSet *append(const QString label, QVariantList values) { return insert(index: count(), label, values); }
106 Q_INVOKABLE void append(DeclarativeBoxSet *box) { QBoxPlotSeries::append(box); }
107 Q_INVOKABLE DeclarativeBoxSet *insert(int index, const QString label, QVariantList values);
108 Q_INVOKABLE bool remove(DeclarativeBoxSet *box) { return QBoxPlotSeries::remove(box: qobject_cast<QBoxSet *>(object: box)); }
109 Q_INVOKABLE void clear() { return QBoxPlotSeries::clear(); }
110
111public: // from QDeclarativeParserStatus
112 void classBegin() override;
113 void componentComplete() override;
114
115Q_SIGNALS:
116 void axisXChanged(QAbstractAxis *axis);
117 void axisYChanged(QAbstractAxis *axis);
118 void axisXTopChanged(QAbstractAxis *axis);
119 void axisYRightChanged(QAbstractAxis *axis);
120 void clicked(DeclarativeBoxSet *boxset);
121 void hovered(bool status, DeclarativeBoxSet *boxset);
122 void pressed(DeclarativeBoxSet *boxset);
123 void released(DeclarativeBoxSet *boxset);
124 void doubleClicked(DeclarativeBoxSet *boxset);
125 Q_REVISION(1, 4) void brushFilenameChanged(const QString &brushFilename);
126
127public Q_SLOTS:
128 static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element);
129 void onHovered(bool status, QBoxSet *boxset);
130 void onClicked(QBoxSet *boxset);
131 void onPressed(QBoxSet *boxset);
132 void onReleased(QBoxSet *boxset);
133 void onDoubleClicked(QBoxSet *boxset);
134
135private Q_SLOTS:
136 void handleBrushChanged();
137
138public:
139 DeclarativeAxes *m_axes;
140
141private:
142 QString m_brushFilename;
143 QImage m_brushImage;
144};
145
146QT_END_NAMESPACE
147
148#endif // DECLARATIVEBOXPLOT_H
149

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