1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QITEMMODELSURFACEDATAPROXY_H |
5 | #define QITEMMODELSURFACEDATAPROXY_H |
6 | |
7 | #include <QtDataVisualization/qsurfacedataproxy.h> |
8 | #include <QtCore/QAbstractItemModel> |
9 | #include <QtCore/QStringList> |
10 | #include <QtCore/QRegularExpression> |
11 | |
12 | QT_BEGIN_NAMESPACE |
13 | |
14 | class QItemModelSurfaceDataProxyPrivate; |
15 | |
16 | class Q_DATAVISUALIZATION_EXPORT QItemModelSurfaceDataProxy : public QSurfaceDataProxy |
17 | { |
18 | Q_OBJECT |
19 | Q_ENUMS(MultiMatchBehavior) |
20 | Q_PROPERTY(QAbstractItemModel* itemModel READ itemModel WRITE setItemModel NOTIFY itemModelChanged) |
21 | Q_PROPERTY(QString rowRole READ rowRole WRITE setRowRole NOTIFY rowRoleChanged) |
22 | Q_PROPERTY(QString columnRole READ columnRole WRITE setColumnRole NOTIFY columnRoleChanged) |
23 | Q_PROPERTY(QString xPosRole READ xPosRole WRITE setXPosRole NOTIFY xPosRoleChanged) |
24 | Q_PROPERTY(QString yPosRole READ yPosRole WRITE setYPosRole NOTIFY yPosRoleChanged) |
25 | Q_PROPERTY(QString zPosRole READ zPosRole WRITE setZPosRole NOTIFY zPosRoleChanged) |
26 | Q_PROPERTY(QStringList rowCategories READ rowCategories WRITE setRowCategories NOTIFY rowCategoriesChanged) |
27 | Q_PROPERTY(QStringList columnCategories READ columnCategories WRITE setColumnCategories NOTIFY columnCategoriesChanged) |
28 | Q_PROPERTY(bool useModelCategories READ useModelCategories WRITE setUseModelCategories NOTIFY useModelCategoriesChanged) |
29 | Q_PROPERTY(bool autoRowCategories READ autoRowCategories WRITE setAutoRowCategories NOTIFY autoRowCategoriesChanged) |
30 | Q_PROPERTY(bool autoColumnCategories READ autoColumnCategories WRITE setAutoColumnCategories NOTIFY autoColumnCategoriesChanged) |
31 | Q_PROPERTY(QRegularExpression rowRolePattern READ rowRolePattern WRITE setRowRolePattern NOTIFY rowRolePatternChanged REVISION(1, 1)) |
32 | Q_PROPERTY(QRegularExpression columnRolePattern READ columnRolePattern WRITE setColumnRolePattern NOTIFY columnRolePatternChanged REVISION(1, 1)) |
33 | Q_PROPERTY(QRegularExpression xPosRolePattern READ xPosRolePattern WRITE setXPosRolePattern NOTIFY xPosRolePatternChanged REVISION(1, 1)) |
34 | Q_PROPERTY(QRegularExpression yPosRolePattern READ yPosRolePattern WRITE setYPosRolePattern NOTIFY yPosRolePatternChanged REVISION(1, 1)) |
35 | Q_PROPERTY(QRegularExpression zPosRolePattern READ zPosRolePattern WRITE setZPosRolePattern NOTIFY zPosRolePatternChanged REVISION(1, 1)) |
36 | Q_PROPERTY(QString rowRoleReplace READ rowRoleReplace WRITE setRowRoleReplace NOTIFY rowRoleReplaceChanged REVISION(1, 1)) |
37 | Q_PROPERTY(QString columnRoleReplace READ columnRoleReplace WRITE setColumnRoleReplace NOTIFY columnRoleReplaceChanged REVISION(1, 1)) |
38 | Q_PROPERTY(QString xPosRoleReplace READ xPosRoleReplace WRITE setXPosRoleReplace NOTIFY xPosRoleReplaceChanged REVISION(1, 1)) |
39 | Q_PROPERTY(QString yPosRoleReplace READ yPosRoleReplace WRITE setYPosRoleReplace NOTIFY yPosRoleReplaceChanged REVISION(1, 1)) |
40 | Q_PROPERTY(QString zPosRoleReplace READ zPosRoleReplace WRITE setZPosRoleReplace NOTIFY zPosRoleReplaceChanged REVISION(1, 1)) |
41 | Q_PROPERTY(MultiMatchBehavior multiMatchBehavior READ multiMatchBehavior WRITE setMultiMatchBehavior NOTIFY multiMatchBehaviorChanged REVISION(1, 1)) |
42 | |
43 | public: |
44 | enum MultiMatchBehavior { |
45 | MMBFirst = 0, |
46 | MMBLast = 1, |
47 | MMBAverage = 2, |
48 | MMBCumulativeY = 3 |
49 | }; |
50 | |
51 | explicit QItemModelSurfaceDataProxy(QObject *parent = nullptr); |
52 | explicit QItemModelSurfaceDataProxy(QAbstractItemModel *itemModel, QObject *parent = nullptr); |
53 | explicit QItemModelSurfaceDataProxy(QAbstractItemModel *itemModel, const QString &yPosRole, |
54 | QObject *parent = nullptr); |
55 | explicit QItemModelSurfaceDataProxy(QAbstractItemModel *itemModel, const QString &rowRole, |
56 | const QString &columnRole, const QString &yPosRole, |
57 | QObject *parent = nullptr); |
58 | explicit QItemModelSurfaceDataProxy(QAbstractItemModel *itemModel, const QString &rowRole, |
59 | const QString &columnRole, const QString &xPosRole, |
60 | const QString &yPosRole, const QString &zPosRole, |
61 | QObject *parent = nullptr); |
62 | explicit QItemModelSurfaceDataProxy(QAbstractItemModel *itemModel, const QString &rowRole, |
63 | const QString &columnRole, const QString &yPosRole, |
64 | const QStringList &rowCategories, |
65 | const QStringList &columnCategories, |
66 | QObject *parent = nullptr); |
67 | explicit QItemModelSurfaceDataProxy(QAbstractItemModel *itemModel, const QString &rowRole, |
68 | const QString &columnRole, const QString &xPosRole, |
69 | const QString &yPosRole, const QString &zPosRole, |
70 | const QStringList &rowCategories, |
71 | const QStringList &columnCategories, |
72 | QObject *parent = nullptr); |
73 | virtual ~QItemModelSurfaceDataProxy(); |
74 | |
75 | void setItemModel(QAbstractItemModel *itemModel); |
76 | QAbstractItemModel *itemModel() const; |
77 | |
78 | void setRowRole(const QString &role); |
79 | QString rowRole() const; |
80 | void setColumnRole(const QString &role); |
81 | QString columnRole() const; |
82 | void setXPosRole(const QString &role); |
83 | QString xPosRole() const; |
84 | void setYPosRole(const QString &role); |
85 | QString yPosRole() const; |
86 | void setZPosRole(const QString &role); |
87 | QString zPosRole() const; |
88 | |
89 | void setRowCategories(const QStringList &categories); |
90 | QStringList rowCategories() const; |
91 | void setColumnCategories(const QStringList &categories); |
92 | QStringList columnCategories() const; |
93 | |
94 | void setUseModelCategories(bool enable); |
95 | bool useModelCategories() const; |
96 | void setAutoRowCategories(bool enable); |
97 | bool autoRowCategories() const; |
98 | void setAutoColumnCategories(bool enable); |
99 | bool autoColumnCategories() const; |
100 | |
101 | void remap(const QString &rowRole, const QString &columnRole, |
102 | const QString &xPosRole, const QString &yPosRole, |
103 | const QString &zPosRole, const QStringList &rowCategories, |
104 | const QStringList &columnCategories); |
105 | |
106 | Q_INVOKABLE int rowCategoryIndex(const QString& category); |
107 | Q_INVOKABLE int columnCategoryIndex(const QString& category); |
108 | |
109 | void setRowRolePattern(const QRegularExpression &pattern); |
110 | QRegularExpression rowRolePattern() const; |
111 | void setColumnRolePattern(const QRegularExpression &pattern); |
112 | QRegularExpression columnRolePattern() const; |
113 | void setXPosRolePattern(const QRegularExpression &pattern); |
114 | QRegularExpression xPosRolePattern() const; |
115 | void setYPosRolePattern(const QRegularExpression &pattern); |
116 | QRegularExpression yPosRolePattern() const; |
117 | void setZPosRolePattern(const QRegularExpression &pattern); |
118 | QRegularExpression zPosRolePattern() const; |
119 | |
120 | void setRowRoleReplace(const QString &replace); |
121 | QString rowRoleReplace() const; |
122 | void setColumnRoleReplace(const QString &replace); |
123 | QString columnRoleReplace() const; |
124 | void setXPosRoleReplace(const QString &replace); |
125 | QString xPosRoleReplace() const; |
126 | void setYPosRoleReplace(const QString &replace); |
127 | QString yPosRoleReplace() const; |
128 | void setZPosRoleReplace(const QString &replace); |
129 | QString zPosRoleReplace() const; |
130 | |
131 | void setMultiMatchBehavior(MultiMatchBehavior behavior); |
132 | MultiMatchBehavior multiMatchBehavior() const; |
133 | |
134 | Q_SIGNALS: |
135 | void itemModelChanged(const QAbstractItemModel* itemModel); |
136 | void rowRoleChanged(const QString &role); |
137 | void columnRoleChanged(const QString &role); |
138 | void xPosRoleChanged(const QString &role); |
139 | void yPosRoleChanged(const QString &role); |
140 | void zPosRoleChanged(const QString &role); |
141 | void rowCategoriesChanged(); |
142 | void columnCategoriesChanged(); |
143 | void useModelCategoriesChanged(bool enable); |
144 | void autoRowCategoriesChanged(bool enable); |
145 | void autoColumnCategoriesChanged(bool enable); |
146 | Q_REVISION(1, 1) void rowRolePatternChanged(const QRegularExpression &pattern); |
147 | Q_REVISION(1, 1) void columnRolePatternChanged(const QRegularExpression &pattern); |
148 | Q_REVISION(1, 1) void xPosRolePatternChanged(const QRegularExpression &pattern); |
149 | Q_REVISION(1, 1) void yPosRolePatternChanged(const QRegularExpression &pattern); |
150 | Q_REVISION(1, 1) void zPosRolePatternChanged(const QRegularExpression &pattern); |
151 | Q_REVISION(1, 1) void rowRoleReplaceChanged(const QString &replace); |
152 | Q_REVISION(1, 1) void columnRoleReplaceChanged(const QString &replace); |
153 | Q_REVISION(1, 1) void xPosRoleReplaceChanged(const QString &replace); |
154 | Q_REVISION(1, 1) void yPosRoleReplaceChanged(const QString &replace); |
155 | Q_REVISION(1, 1) void zPosRoleReplaceChanged(const QString &replace); |
156 | Q_REVISION(1, 1) void multiMatchBehaviorChanged(MultiMatchBehavior behavior); |
157 | |
158 | protected: |
159 | QItemModelSurfaceDataProxyPrivate *dptr(); |
160 | const QItemModelSurfaceDataProxyPrivate *dptrc() const; |
161 | |
162 | private: |
163 | Q_DISABLE_COPY(QItemModelSurfaceDataProxy) |
164 | |
165 | friend class SurfaceItemModelHandler; |
166 | }; |
167 | |
168 | QT_END_NAMESPACE |
169 | |
170 | #endif |
171 | |