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 DECLARATIVEBARSERIES_H
40#define DECLARATIVEBARSERIES_H
41
42#include <QtCharts/QBarSeries>
43#include <QtCharts/QStackedBarSeries>
44#include <QtCharts/QPercentBarSeries>
45#include <QtCharts/QHorizontalBarSeries>
46#include <QtCharts/QHorizontalStackedBarSeries>
47#include <QtCharts/QHorizontalPercentBarSeries>
48#include <QtCharts/QBarSet>
49#include <private/declarativechartglobal_p.h>
50#include <private/declarativeaxes_p.h>
51
52#include <QtQuick/QQuickItem>
53#include <QtQml/QQmlParserStatus>
54
55QT_CHARTS_BEGIN_NAMESPACE
56
57class QChart;
58
59class Q_QMLCHARTS_PRIVATE_EXPORT DeclarativeBarSet : public QBarSet
60{
61 Q_OBJECT
62 Q_PROPERTY(QVariantList values READ values WRITE setValues)
63 Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged REVISION 1)
64 Q_PROPERTY(int count READ count NOTIFY countChanged)
65 Q_PROPERTY(QString brushFilename READ brushFilename WRITE setBrushFilename NOTIFY brushFilenameChanged REVISION 2)
66
67public:
68 explicit DeclarativeBarSet(QObject *parent = 0);
69 QVariantList values();
70 void setValues(QVariantList values);
71 qreal borderWidth() const;
72 void setBorderWidth(qreal borderWidth);
73 QString brushFilename() const;
74 void setBrushFilename(const QString &brushFilename);
75
76public: // From QBarSet
77 Q_INVOKABLE void append(qreal value) { QBarSet::append(value); }
78 Q_INVOKABLE void remove(const int index, const int count = 1) { QBarSet::remove(index, count); }
79 Q_INVOKABLE void replace(int index, qreal value) { QBarSet::replace(index, value); }
80 Q_INVOKABLE qreal at(int index) { return QBarSet::at(index); }
81
82Q_SIGNALS:
83 void countChanged(int count);
84 Q_REVISION(1) void borderWidthChanged(qreal width);
85 Q_REVISION(2) void brushFilenameChanged(const QString &brushFilename);
86
87private Q_SLOTS:
88 void handleCountChanged(int index, int count);
89 void handleBrushChanged();
90
91private:
92 QString m_brushFilename;
93 QImage m_brushImage;
94};
95
96class Q_QMLCHARTS_PRIVATE_EXPORT DeclarativeBarSeries : public QBarSeries, public QQmlParserStatus
97{
98 Q_OBJECT
99 Q_INTERFACES(QQmlParserStatus)
100 Q_PROPERTY(QtCharts::QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
101 Q_PROPERTY(QtCharts::QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
102 Q_PROPERTY(QtCharts::QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2)
103 Q_PROPERTY(QtCharts::QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2)
104 Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren)
105 Q_CLASSINFO("DefaultProperty", "seriesChildren")
106
107public:
108 explicit DeclarativeBarSeries(QQuickItem *parent = 0);
109 QAbstractAxis *axisX() { return m_axes->axisX(); }
110 void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); }
111 QAbstractAxis *axisY() { return m_axes->axisY(); }
112 void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); }
113 QAbstractAxis *axisXTop() { return m_axes->axisXTop(); }
114 void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); }
115 QAbstractAxis *axisYRight() { return m_axes->axisYRight(); }
116 void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); }
117 QQmlListProperty<QObject> seriesChildren();
118
119public:
120 Q_INVOKABLE DeclarativeBarSet *at(int index);
121 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(index: count(), label, values); }
122 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
123 Q_INVOKABLE bool remove(QBarSet *barset) { return QBarSeries::remove(set: barset); }
124 Q_INVOKABLE void clear() { return QBarSeries::clear(); }
125
126public: // from QDeclarativeParserStatus
127 void classBegin();
128 void componentComplete();
129
130Q_SIGNALS:
131 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
132 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
133 Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis);
134 Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis);
135
136public Q_SLOTS:
137 static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element);
138
139public:
140 DeclarativeAxes *m_axes;
141};
142
143class Q_QMLCHARTS_PRIVATE_EXPORT DeclarativeStackedBarSeries : public QStackedBarSeries, public QQmlParserStatus
144{
145 Q_OBJECT
146 Q_INTERFACES(QQmlParserStatus)
147 Q_PROPERTY(QtCharts::QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
148 Q_PROPERTY(QtCharts::QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
149 Q_PROPERTY(QtCharts::QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2)
150 Q_PROPERTY(QtCharts::QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2)
151 Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren)
152 Q_CLASSINFO("DefaultProperty", "seriesChildren")
153
154public:
155 explicit DeclarativeStackedBarSeries(QQuickItem *parent = 0);
156 QAbstractAxis *axisX() { return m_axes->axisX(); }
157 void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); }
158 QAbstractAxis *axisY() { return m_axes->axisY(); }
159 void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); }
160 QAbstractAxis *axisXTop() { return m_axes->axisXTop(); }
161 void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); }
162 QAbstractAxis *axisYRight() { return m_axes->axisYRight(); }
163 void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); }
164 QQmlListProperty<QObject> seriesChildren();
165
166public:
167 Q_INVOKABLE DeclarativeBarSet *at(int index);
168 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(index: count(), label, values); }
169 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
170 Q_INVOKABLE bool remove(QBarSet *barset) { return QStackedBarSeries::remove(set: barset); }
171 Q_INVOKABLE void clear() { return QStackedBarSeries::clear(); }
172
173public: // from QDeclarativeParserStatus
174 void classBegin();
175 void componentComplete();
176
177Q_SIGNALS:
178 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
179 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
180 Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis);
181 Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis);
182
183public Q_SLOTS:
184 static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element);
185
186public:
187 DeclarativeAxes *m_axes;
188};
189
190class Q_QMLCHARTS_PRIVATE_EXPORT DeclarativePercentBarSeries : public QPercentBarSeries, public QQmlParserStatus
191{
192 Q_OBJECT
193 Q_INTERFACES(QQmlParserStatus)
194 Q_PROPERTY(QtCharts::QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
195 Q_PROPERTY(QtCharts::QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
196 Q_PROPERTY(QtCharts::QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2)
197 Q_PROPERTY(QtCharts::QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2)
198 Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren)
199 Q_CLASSINFO("DefaultProperty", "seriesChildren")
200
201public:
202 explicit DeclarativePercentBarSeries(QQuickItem *parent = 0);
203 QAbstractAxis *axisX() { return m_axes->axisX(); }
204 void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); }
205 QAbstractAxis *axisY() { return m_axes->axisY(); }
206 void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); }
207 QAbstractAxis *axisXTop() { return m_axes->axisXTop(); }
208 void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); }
209 QAbstractAxis *axisYRight() { return m_axes->axisYRight(); }
210 void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); }
211 QQmlListProperty<QObject> seriesChildren();
212
213public:
214 Q_INVOKABLE DeclarativeBarSet *at(int index);
215 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(index: count(), label, values); }
216 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
217 Q_INVOKABLE bool remove(QBarSet *barset) { return QPercentBarSeries::remove(set: barset); }
218 Q_INVOKABLE void clear() { return QPercentBarSeries::clear(); }
219
220public: // from QDeclarativeParserStatus
221 void classBegin();
222 void componentComplete();
223
224Q_SIGNALS:
225 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
226 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
227 Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis);
228 Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis);
229
230public Q_SLOTS:
231 static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element);
232
233public:
234 DeclarativeAxes *m_axes;
235};
236
237class Q_QMLCHARTS_PRIVATE_EXPORT DeclarativeHorizontalBarSeries : public QHorizontalBarSeries, public QQmlParserStatus
238{
239 Q_OBJECT
240 Q_INTERFACES(QQmlParserStatus)
241 Q_PROPERTY(QtCharts::QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
242 Q_PROPERTY(QtCharts::QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
243 Q_PROPERTY(QtCharts::QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2)
244 Q_PROPERTY(QtCharts::QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2)
245 Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren)
246 Q_CLASSINFO("DefaultProperty", "seriesChildren")
247
248public:
249 explicit DeclarativeHorizontalBarSeries(QQuickItem *parent = 0);
250 QAbstractAxis *axisX() { return m_axes->axisX(); }
251 void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); }
252 QAbstractAxis *axisY() { return m_axes->axisY(); }
253 void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); }
254 QAbstractAxis *axisXTop() { return m_axes->axisXTop(); }
255 void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); }
256 QAbstractAxis *axisYRight() { return m_axes->axisYRight(); }
257 void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); }
258 QQmlListProperty<QObject> seriesChildren();
259
260public:
261 Q_INVOKABLE DeclarativeBarSet *at(int index);
262 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(index: count(), label, values); }
263 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
264 Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalBarSeries::remove(set: barset); }
265 Q_INVOKABLE void clear() { return QHorizontalBarSeries::clear(); }
266
267public: // from QDeclarativeParserStatus
268 void classBegin();
269 void componentComplete();
270
271Q_SIGNALS:
272 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
273 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
274 Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis);
275 Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis);
276
277public Q_SLOTS:
278 static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element);
279
280public:
281 DeclarativeAxes *m_axes;
282};
283
284class Q_QMLCHARTS_PRIVATE_EXPORT DeclarativeHorizontalStackedBarSeries : public QHorizontalStackedBarSeries, public QQmlParserStatus
285{
286 Q_OBJECT
287 Q_INTERFACES(QQmlParserStatus)
288 Q_PROPERTY(QtCharts::QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
289 Q_PROPERTY(QtCharts::QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
290 Q_PROPERTY(QtCharts::QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2)
291 Q_PROPERTY(QtCharts::QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2)
292 Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren)
293 Q_CLASSINFO("DefaultProperty", "seriesChildren")
294
295public:
296 explicit DeclarativeHorizontalStackedBarSeries(QQuickItem *parent = 0);
297 QAbstractAxis *axisX() { return m_axes->axisX(); }
298 void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); }
299 QAbstractAxis *axisY() { return m_axes->axisY(); }
300 void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); }
301 QAbstractAxis *axisXTop() { return m_axes->axisXTop(); }
302 void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); }
303 QAbstractAxis *axisYRight() { return m_axes->axisYRight(); }
304 void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); }
305 QQmlListProperty<QObject> seriesChildren();
306
307public:
308 Q_INVOKABLE DeclarativeBarSet *at(int index);
309 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(index: count(), label, values); }
310 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
311 Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalStackedBarSeries::remove(set: barset); }
312 Q_INVOKABLE void clear() { return QHorizontalStackedBarSeries::clear(); }
313
314public: // from QDeclarativeParserStatus
315 void classBegin();
316 void componentComplete();
317
318Q_SIGNALS:
319 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
320 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
321 Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis);
322 Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis);
323
324public Q_SLOTS:
325 static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element);
326
327public:
328 DeclarativeAxes *m_axes;
329};
330
331class Q_QMLCHARTS_PRIVATE_EXPORT DeclarativeHorizontalPercentBarSeries : public QHorizontalPercentBarSeries, public QQmlParserStatus
332{
333 Q_OBJECT
334 Q_INTERFACES(QQmlParserStatus)
335 Q_PROPERTY(QtCharts::QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged REVISION 1)
336 Q_PROPERTY(QtCharts::QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged REVISION 1)
337 Q_PROPERTY(QtCharts::QAbstractAxis *axisXTop READ axisXTop WRITE setAxisXTop NOTIFY axisXTopChanged REVISION 2)
338 Q_PROPERTY(QtCharts::QAbstractAxis *axisYRight READ axisYRight WRITE setAxisYRight NOTIFY axisYRightChanged REVISION 2)
339 Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren)
340 Q_CLASSINFO("DefaultProperty", "seriesChildren")
341
342public:
343 explicit DeclarativeHorizontalPercentBarSeries(QQuickItem *parent = 0);
344 QAbstractAxis *axisX() { return m_axes->axisX(); }
345 void setAxisX(QAbstractAxis *axis) { m_axes->setAxisX(axis); }
346 QAbstractAxis *axisY() { return m_axes->axisY(); }
347 void setAxisY(QAbstractAxis *axis) { m_axes->setAxisY(axis); }
348 QAbstractAxis *axisXTop() { return m_axes->axisXTop(); }
349 void setAxisXTop(QAbstractAxis *axis) { m_axes->setAxisXTop(axis); }
350 QAbstractAxis *axisYRight() { return m_axes->axisYRight(); }
351 void setAxisYRight(QAbstractAxis *axis) { m_axes->setAxisYRight(axis); }
352 QQmlListProperty<QObject> seriesChildren();
353
354public:
355 Q_INVOKABLE DeclarativeBarSet *at(int index);
356 Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(index: count(), label, values); }
357 Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values);
358 Q_INVOKABLE bool remove(QBarSet *barset) { return QHorizontalPercentBarSeries::remove(set: barset); }
359 Q_INVOKABLE void clear() { return QHorizontalPercentBarSeries::clear(); }
360
361public: // from QDeclarativeParserStatus
362 void classBegin();
363 void componentComplete();
364
365Q_SIGNALS:
366 Q_REVISION(1) void axisXChanged(QAbstractAxis *axis);
367 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
368 Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis);
369 Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis);
370
371public Q_SLOTS:
372 static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element);
373
374public:
375 DeclarativeAxes *m_axes;
376};
377
378QT_CHARTS_END_NAMESPACE
379
380#endif // DECLARATIVEBARSERIES_H
381

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