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#ifndef QPIESERIES_H
31#define QPIESERIES_H
32
33#include <QtCharts/QAbstractSeries>
34#include <QtCharts/QPieSlice>
35
36QT_CHARTS_BEGIN_NAMESPACE
37class QPieSeriesPrivate;
38
39class Q_CHARTS_EXPORT QPieSeries : public QAbstractSeries
40{
41 Q_OBJECT
42 Q_PROPERTY(qreal horizontalPosition READ horizontalPosition WRITE setHorizontalPosition)
43 Q_PROPERTY(qreal verticalPosition READ verticalPosition WRITE setVerticalPosition)
44 Q_PROPERTY(qreal size READ pieSize WRITE setPieSize)
45 Q_PROPERTY(qreal startAngle READ pieStartAngle WRITE setPieStartAngle)
46 Q_PROPERTY(qreal endAngle READ pieEndAngle WRITE setPieEndAngle)
47 Q_PROPERTY(int count READ count NOTIFY countChanged)
48 Q_PROPERTY(qreal sum READ sum NOTIFY sumChanged)
49 Q_PROPERTY(qreal holeSize READ holeSize WRITE setHoleSize)
50
51public:
52 explicit QPieSeries(QObject *parent = nullptr);
53 virtual ~QPieSeries();
54
55 QAbstractSeries::SeriesType type() const;
56
57 bool append(QPieSlice *slice);
58 bool append(QList<QPieSlice *> slices);
59 QPieSeries &operator << (QPieSlice *slice);
60 QPieSlice *append(QString label, qreal value);
61
62 bool insert(int index, QPieSlice *slice);
63
64 bool remove(QPieSlice *slice);
65 bool take(QPieSlice *slice);
66 void clear();
67
68 QList<QPieSlice *> slices() const;
69 int count() const;
70
71 bool isEmpty() const;
72
73 qreal sum() const;
74
75 void setHoleSize(qreal holeSize);
76 qreal holeSize() const;
77
78 void setHorizontalPosition(qreal relativePosition);
79 qreal horizontalPosition() const;
80
81 void setVerticalPosition(qreal relativePosition);
82 qreal verticalPosition() const;
83
84 void setPieSize(qreal relativeSize);
85 qreal pieSize() const;
86
87 void setPieStartAngle(qreal startAngle);
88 qreal pieStartAngle() const;
89
90 void setPieEndAngle(qreal endAngle);
91 qreal pieEndAngle() const;
92
93 void setLabelsVisible(bool visible = true);
94 void setLabelsPosition(QPieSlice::LabelPosition position);
95
96Q_SIGNALS:
97 void added(QList<QPieSlice *> slices);
98 void removed(QList<QPieSlice *> slices);
99 void clicked(QPieSlice *slice);
100 void hovered(QPieSlice *slice, bool state);
101 void pressed(QPieSlice *slice);
102 void released(QPieSlice *slice);
103 void doubleClicked(QPieSlice *slice);
104 void countChanged();
105 void sumChanged();
106
107private:
108 Q_DECLARE_PRIVATE(QPieSeries)
109 Q_DISABLE_COPY(QPieSeries)
110 friend class PieChartItem;
111};
112
113QT_CHARTS_END_NAMESPACE
114
115#endif // QPIESERIES_H
116

source code of qtcharts/src/charts/piechart/qpieseries.h