1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QPIESERIES_H |
5 | #define QPIESERIES_H |
6 | |
7 | #include <QtCharts/QAbstractSeries> |
8 | #include <QtCharts/QPieSlice> |
9 | |
10 | QT_BEGIN_NAMESPACE |
11 | class QPieSeriesPrivate; |
12 | |
13 | class Q_CHARTS_EXPORT QPieSeries : public QAbstractSeries |
14 | { |
15 | Q_OBJECT |
16 | Q_PROPERTY(qreal horizontalPosition READ horizontalPosition WRITE setHorizontalPosition) |
17 | Q_PROPERTY(qreal verticalPosition READ verticalPosition WRITE setVerticalPosition) |
18 | Q_PROPERTY(qreal size READ pieSize WRITE setPieSize) |
19 | Q_PROPERTY(qreal startAngle READ pieStartAngle WRITE setPieStartAngle) |
20 | Q_PROPERTY(qreal endAngle READ pieEndAngle WRITE setPieEndAngle) |
21 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
22 | Q_PROPERTY(qreal sum READ sum NOTIFY sumChanged) |
23 | Q_PROPERTY(qreal holeSize READ holeSize WRITE setHoleSize) |
24 | |
25 | public: |
26 | explicit QPieSeries(QObject *parent = nullptr); |
27 | virtual ~QPieSeries(); |
28 | |
29 | QAbstractSeries::SeriesType type() const override; |
30 | |
31 | bool append(QPieSlice *slice); |
32 | bool append(const QList<QPieSlice *> &slices); |
33 | QPieSeries &operator << (QPieSlice *slice); |
34 | QPieSlice *append(const QString &label, qreal value); |
35 | |
36 | bool insert(int index, QPieSlice *slice); |
37 | |
38 | bool remove(QPieSlice *slice); |
39 | bool take(QPieSlice *slice); |
40 | void clear(); |
41 | |
42 | QList<QPieSlice *> slices() const; |
43 | int count() const; |
44 | |
45 | bool isEmpty() const; |
46 | |
47 | qreal sum() const; |
48 | |
49 | void setHoleSize(qreal holeSize); |
50 | qreal holeSize() const; |
51 | |
52 | void setHorizontalPosition(qreal relativePosition); |
53 | qreal horizontalPosition() const; |
54 | |
55 | void setVerticalPosition(qreal relativePosition); |
56 | qreal verticalPosition() const; |
57 | |
58 | void setPieSize(qreal relativeSize); |
59 | qreal pieSize() const; |
60 | |
61 | void setPieStartAngle(qreal startAngle); |
62 | qreal pieStartAngle() const; |
63 | |
64 | void setPieEndAngle(qreal endAngle); |
65 | qreal pieEndAngle() const; |
66 | |
67 | void setLabelsVisible(bool visible = true); |
68 | void setLabelsPosition(QPieSlice::LabelPosition position); |
69 | |
70 | Q_SIGNALS: |
71 | void added(const QList<QPieSlice *> &slices); |
72 | void removed(const QList<QPieSlice *> &slices); |
73 | void clicked(QPieSlice *slice); |
74 | void hovered(QPieSlice *slice, bool state); |
75 | void pressed(QPieSlice *slice); |
76 | void released(QPieSlice *slice); |
77 | void doubleClicked(QPieSlice *slice); |
78 | void countChanged(); |
79 | void sumChanged(); |
80 | |
81 | private: |
82 | Q_DECLARE_PRIVATE(QPieSeries) |
83 | Q_DISABLE_COPY(QPieSeries) |
84 | friend class PieChartItem; |
85 | }; |
86 | |
87 | QT_END_NAMESPACE |
88 | |
89 | #endif // QPIESERIES_H |
90 | |