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