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 DECLARATIVEPIESERIES_H
14#define DECLARATIVEPIESERIES_H
15
16#include <QtQml/qqmlregistration.h>
17#include <QtCharts/QPieSeries>
18#include <QtCharts/QPieSlice>
19#include <private/declarativechartglobal_p.h>
20
21#include <QtQuick/QQuickItem>
22#include <QtQml/QQmlParserStatus>
23
24QT_BEGIN_NAMESPACE
25
26class Q_CHARTSQML_PRIVATE_EXPORT DeclarativePieSlice : public QPieSlice
27{
28 Q_OBJECT
29 Q_PROPERTY(QString brushFilename READ brushFilename WRITE setBrushFilename NOTIFY brushFilenameChanged)
30 QML_NAMED_ELEMENT(PieSlice)
31 QML_ADDED_IN_VERSION(1, 0)
32 QML_EXTRA_VERSION(2, 0)
33
34public:
35 explicit DeclarativePieSlice(QObject *parent = 0);
36 QString brushFilename() const;
37 void setBrushFilename(const QString &brushFilename);
38
39Q_SIGNALS:
40 void brushFilenameChanged(const QString &brushFilename);
41
42private Q_SLOTS:
43 void handleBrushChanged();
44
45private:
46 QString m_brushFilename;
47 QImage m_brushImage;
48};
49
50class DeclarativePieSeries : public QPieSeries, public QQmlParserStatus
51{
52 Q_OBJECT
53 Q_INTERFACES(QQmlParserStatus)
54 Q_PROPERTY(QQmlListProperty<QObject> seriesChildren READ seriesChildren)
55 Q_CLASSINFO("DefaultProperty", "seriesChildren")
56 QML_NAMED_ELEMENT(PieSeries)
57 QML_ADDED_IN_VERSION(1, 0)
58 QML_EXTRA_VERSION(2, 0)
59
60public:
61 explicit DeclarativePieSeries(QQuickItem *parent = 0);
62 QQmlListProperty<QObject> seriesChildren();
63 Q_INVOKABLE QPieSlice *at(int index);
64 Q_INVOKABLE QPieSlice *find(QString label);
65 Q_INVOKABLE DeclarativePieSlice *append(QString label, qreal value);
66 Q_INVOKABLE bool remove(QPieSlice *slice);
67 Q_INVOKABLE void clear();
68
69public:
70 void classBegin() override;
71 void componentComplete() override;
72
73Q_SIGNALS:
74 void sliceAdded(QPieSlice *slice);
75 void sliceRemoved(QPieSlice *slice);
76
77public Q_SLOTS:
78 static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element);
79 void handleAdded(const QList<QPieSlice *> &slices);
80 void handleRemoved(const QList<QPieSlice *> &slices);
81};
82
83QT_END_NAMESPACE
84
85#endif // DECLARATIVEPIESERIES_H
86

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