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

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