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 QPIEMODELMAPPER_P_H |
14 | #define QPIEMODELMAPPER_P_H |
15 | |
16 | #include <QtCore/QObject> |
17 | #include <QtCharts/QPieModelMapper> |
18 | #include <QtCharts/private/qchartglobal_p.h> |
19 | |
20 | QT_BEGIN_NAMESPACE |
21 | class QModelIndex; |
22 | QT_END_NAMESPACE |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class QPieSlice; |
27 | |
28 | class Q_CHARTS_PRIVATE_EXPORT QPieModelMapperPrivate : public QObject |
29 | { |
30 | Q_OBJECT |
31 | |
32 | public: |
33 | explicit QPieModelMapperPrivate(QPieModelMapper *q); |
34 | |
35 | public Q_SLOTS: |
36 | // for the model |
37 | void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); |
38 | void modelRowsAdded(QModelIndex parent, int start, int end); |
39 | void modelRowsRemoved(QModelIndex parent, int start, int end); |
40 | void modelColumnsAdded(QModelIndex parent, int start, int end); |
41 | void modelColumnsRemoved(QModelIndex parent, int start, int end); |
42 | void handleModelDestroyed(); |
43 | |
44 | // for the series |
45 | void slicesAdded(const QList<QPieSlice *> &slices); |
46 | void slicesRemoved(const QList<QPieSlice *> &slices); |
47 | void sliceLabelChanged(); |
48 | void sliceValueChanged(); |
49 | void handleSeriesDestroyed(); |
50 | |
51 | void initializePieFromModel(); |
52 | |
53 | private: |
54 | QPieSlice *pieSlice(QModelIndex index) const; |
55 | bool isLabelIndex(QModelIndex index) const; |
56 | bool isValueIndex(QModelIndex index) const; |
57 | QModelIndex valueModelIndex(int slicePos); |
58 | QModelIndex labelModelIndex(int slicePos); |
59 | void insertData(int start, int end); |
60 | void removeData(int start, int end); |
61 | |
62 | void blockModelSignals(bool block = true); |
63 | void blockSeriesSignals(bool block = true); |
64 | |
65 | private: |
66 | QPieSeries *m_series; |
67 | QList<QPieSlice *> m_slices; |
68 | QAbstractItemModel *m_model; |
69 | int m_first; |
70 | int m_count; |
71 | Qt::Orientation m_orientation; |
72 | int m_valuesSection; |
73 | int m_labelsSection; |
74 | bool m_seriesSignalsBlock; |
75 | bool m_modelSignalsBlock; |
76 | |
77 | private: |
78 | |
79 | QPieModelMapper *q_ptr; |
80 | Q_DECLARE_PUBLIC(QPieModelMapper) |
81 | }; |
82 | |
83 | QT_END_NAMESPACE |
84 | |
85 | #endif // QPIEMODELMAPPER_P_H |
86 | |