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 DECLARATIVEBOXPLOT_H
40#define DECLARATIVEBOXPLOT_H
41
42#include <QtCharts/QBoxSet>
43#include <private/declarativeaxes_p.h>
44#include <QtCharts/QBoxPlotSeries>
45#include <private/declarativechartglobal_p.h>
46
47#include <QtQuick/QQuickItem>
48#include <QtQml/QQmlParserStatus>
49
50QT_CHARTS_BEGIN_NAMESPACE
51
52class Q_QMLCHARTS_PRIVATE_EXPORT DeclarativeBoxSet : public QBoxSet
53{
54 Q_OBJECT
55 Q_PROPERTY(QVariantList values READ values WRITE setValues)
56 Q_PROPERTY(QString label READ label WRITE setLabel)
57 Q_PROPERTY(int count READ count)
58 Q_PROPERTY(QString brushFilename READ brushFilename WRITE setBrushFilename NOTIFY brushFilenameChanged REVISION 1)
59 Q_ENUMS(ValuePositions)
60
61public: // duplicate from QBoxSet
62 enum ValuePositions {
63 LowerExtreme = 0x0,
64 LowerQuartile,
65 Median,
66 UpperQuartile,
67 UpperExtreme
68 };
69
70public:
71 explicit DeclarativeBoxSet(const QString label = "", QObject *parent = 0);
72 QVariantList values();
73 void setValues(QVariantList values);
74 QString brushFilename() const;
75 void setBrushFilename(const QString &brushFilename);
76
77public: // From QBoxSet
78 Q_INVOKABLE void append(qreal value) { QBoxSet::append(value); }
79 Q_INVOKABLE void clear() {QBoxSet::clear(); }
80 Q_INVOKABLE qreal at(int index) { return QBoxSet::at(index); }
81 Q_INVOKABLE void setValue(int index, qreal value) { QBoxSet::setValue(index, value); }
82
83Q_SIGNALS:
84 void changedValues();
85 void changedValue(int index);
86 Q_REVISION(1) void brushFilenameChanged(const QString &brushFilename);
87
88private Q_SLOTS:
89 void handleBrushChanged();
90
91private:
92 QString m_brushFilename;
93 QImage m_brushImage;
94};
95
96class Q_QMLCHARTS_PRIVATE_EXPORT DeclarativeBoxPlotSeries : public QBoxPlotSeries, public QQmlParserStatus
97{
98 Q_OBJECT
99 Q_INTERFACES(QQmlParserStatus)
100 Q_PROPERTY(QtCharts::QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged)
101 Q_PROPERTY(QtCharts::QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged)
102 Q_PROPERTY(QtCharts::QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged)
103 Q_PROPERTY(QtCharts::QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged)
104 Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren)
105 Q_PROPERTY(QString brushFilename READ brushFilename WRITE setBrushFilename NOTIFY brushFilenameChanged REVISION 1)
106 Q_CLASSINFO("DefaultProperty", "seriesChildren")
107
108public:
109 explicit DeclarativeBoxPlotSeries(QQuickItem *parent = 0);
110 QAbstractAxis *axisX() { return m_axes->axisX(); }
111 void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); }
112 QAbstractAxis *axisY() { return m_axes->axisY(); }
113 void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); }
114 QAbstractAxis *axisXTop() { return m_axes->axisXTop(); }
115 void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); }
116 QAbstractAxis *axisYRight() { return m_axes->axisYRight(); }
117 void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); }
118 QQmlListProperty<QObject> seriesChildren();
119 QString brushFilename() const;
120 void setBrushFilename(const QString &brushFilename);
121
122public:
123 Q_INVOKABLE DeclarativeBoxSet *at(int index);
124 Q_INVOKABLE DeclarativeBoxSet *append(const QString label, QVariantList values) { return insert(index: count(), label, values); }
125 Q_INVOKABLE void append(DeclarativeBoxSet *box) { QBoxPlotSeries::append(box); }
126 Q_INVOKABLE DeclarativeBoxSet *insert(int index, const QString label, QVariantList values);
127 Q_INVOKABLE bool remove(DeclarativeBoxSet *box) { return QBoxPlotSeries::remove(box: qobject_cast<QBoxSet *>(object: box)); }
128 Q_INVOKABLE void clear() { return QBoxPlotSeries::clear(); }
129
130public: // from QDeclarativeParserStatus
131 void classBegin();
132 void componentComplete();
133
134Q_SIGNALS:
135 void axisXChanged(QAbstractAxis *axis);
136 void axisYChanged(QAbstractAxis *axis);
137 void axisXTopChanged(QAbstractAxis *axis);
138 void axisYRightChanged(QAbstractAxis *axis);
139 void clicked(DeclarativeBoxSet *boxset);
140 void hovered(bool status, DeclarativeBoxSet *boxset);
141 void pressed(DeclarativeBoxSet *boxset);
142 void released(DeclarativeBoxSet *boxset);
143 void doubleClicked(DeclarativeBoxSet *boxset);
144 Q_REVISION(1) void brushFilenameChanged(const QString &brushFilename);
145
146public Q_SLOTS:
147 static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element);
148 void onHovered(bool status, QBoxSet *boxset);
149 void onClicked(QBoxSet *boxset);
150 void onPressed(QBoxSet *boxset);
151 void onReleased(QBoxSet *boxset);
152 void onDoubleClicked(QBoxSet *boxset);
153
154private Q_SLOTS:
155 void handleBrushChanged();
156
157public:
158 DeclarativeAxes *m_axes;
159
160private:
161 QString m_brushFilename;
162 QImage m_brushImage;
163};
164
165QT_CHARTS_END_NAMESPACE
166
167#endif // DECLARATIVEBOXPLOT_H
168

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