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 Data Visualization 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 QITEMMODELBARDATAPROXY_H |
31 | #define QITEMMODELBARDATAPROXY_H |
32 | |
33 | #include <QtDataVisualization/qbardataproxy.h> |
34 | #include <QtCore/QAbstractItemModel> |
35 | #include <QtCore/QRegExp> |
36 | |
37 | QT_BEGIN_NAMESPACE_DATAVISUALIZATION |
38 | |
39 | class QItemModelBarDataProxyPrivate; |
40 | |
41 | class QT_DATAVISUALIZATION_EXPORT QItemModelBarDataProxy : public QBarDataProxy |
42 | { |
43 | Q_OBJECT |
44 | Q_ENUMS(MultiMatchBehavior) |
45 | Q_PROPERTY(QAbstractItemModel* itemModel READ itemModel WRITE setItemModel NOTIFY itemModelChanged) |
46 | Q_PROPERTY(QString rowRole READ rowRole WRITE setRowRole NOTIFY rowRoleChanged) |
47 | Q_PROPERTY(QString columnRole READ columnRole WRITE setColumnRole NOTIFY columnRoleChanged) |
48 | Q_PROPERTY(QString valueRole READ valueRole WRITE setValueRole NOTIFY valueRoleChanged) |
49 | Q_PROPERTY(QString rotationRole READ rotationRole WRITE setRotationRole NOTIFY rotationRoleChanged) |
50 | Q_PROPERTY(QStringList rowCategories READ rowCategories WRITE setRowCategories NOTIFY rowCategoriesChanged) |
51 | Q_PROPERTY(QStringList columnCategories READ columnCategories WRITE setColumnCategories NOTIFY columnCategoriesChanged) |
52 | Q_PROPERTY(bool useModelCategories READ useModelCategories WRITE setUseModelCategories NOTIFY useModelCategoriesChanged) |
53 | Q_PROPERTY(bool autoRowCategories READ autoRowCategories WRITE setAutoRowCategories NOTIFY autoRowCategoriesChanged) |
54 | Q_PROPERTY(bool autoColumnCategories READ autoColumnCategories WRITE setAutoColumnCategories NOTIFY autoColumnCategoriesChanged) |
55 | Q_PROPERTY(QRegExp rowRolePattern READ rowRolePattern WRITE setRowRolePattern NOTIFY rowRolePatternChanged REVISION 1) |
56 | Q_PROPERTY(QRegExp columnRolePattern READ columnRolePattern WRITE setColumnRolePattern NOTIFY columnRolePatternChanged REVISION 1) |
57 | Q_PROPERTY(QRegExp valueRolePattern READ valueRolePattern WRITE setValueRolePattern NOTIFY valueRolePatternChanged REVISION 1) |
58 | Q_PROPERTY(QRegExp rotationRolePattern READ rotationRolePattern WRITE setRotationRolePattern NOTIFY rotationRolePatternChanged REVISION 1) |
59 | Q_PROPERTY(QString rowRoleReplace READ rowRoleReplace WRITE setRowRoleReplace NOTIFY rowRoleReplaceChanged REVISION 1) |
60 | Q_PROPERTY(QString columnRoleReplace READ columnRoleReplace WRITE setColumnRoleReplace NOTIFY columnRoleReplaceChanged REVISION 1) |
61 | Q_PROPERTY(QString valueRoleReplace READ valueRoleReplace WRITE setValueRoleReplace NOTIFY valueRoleReplaceChanged REVISION 1) |
62 | Q_PROPERTY(QString rotationRoleReplace READ rotationRoleReplace WRITE setRotationRoleReplace NOTIFY rotationRoleReplaceChanged REVISION 1) |
63 | Q_PROPERTY(MultiMatchBehavior multiMatchBehavior READ multiMatchBehavior WRITE setMultiMatchBehavior NOTIFY multiMatchBehaviorChanged REVISION 1) |
64 | |
65 | public: |
66 | enum MultiMatchBehavior { |
67 | MMBFirst = 0, |
68 | MMBLast = 1, |
69 | MMBAverage = 2, |
70 | MMBCumulative = 3 |
71 | }; |
72 | |
73 | explicit QItemModelBarDataProxy(QObject *parent = nullptr); |
74 | explicit QItemModelBarDataProxy(QAbstractItemModel *itemModel, QObject *parent = nullptr); |
75 | explicit QItemModelBarDataProxy(QAbstractItemModel *itemModel, const QString &valueRole, |
76 | QObject *parent = nullptr); |
77 | explicit QItemModelBarDataProxy(QAbstractItemModel *itemModel, const QString &rowRole, |
78 | const QString &columnRole, const QString &valueRole, |
79 | QObject *parent = nullptr); |
80 | explicit QItemModelBarDataProxy(QAbstractItemModel *itemModel, const QString &rowRole, |
81 | const QString &columnRole, const QString &valueRole, |
82 | const QString &rotationRole, QObject *parent = nullptr); |
83 | explicit QItemModelBarDataProxy(QAbstractItemModel *itemModel, const QString &rowRole, |
84 | const QString &columnRole, const QString &valueRole, |
85 | const QStringList &rowCategories, const QStringList &columnCategories, |
86 | QObject *parent = nullptr); |
87 | explicit QItemModelBarDataProxy(QAbstractItemModel *itemModel, const QString &rowRole, |
88 | const QString &columnRole, const QString &valueRole, |
89 | const QString &rotationRole, const QStringList &rowCategories, |
90 | const QStringList &columnCategories, QObject *parent = nullptr); |
91 | virtual ~QItemModelBarDataProxy(); |
92 | |
93 | void setItemModel(QAbstractItemModel *itemModel); |
94 | QAbstractItemModel *itemModel() const; |
95 | |
96 | void setRowRole(const QString &role); |
97 | QString rowRole() const; |
98 | void setColumnRole(const QString &role); |
99 | QString columnRole() const; |
100 | void setValueRole(const QString &role); |
101 | QString valueRole() const; |
102 | void setRotationRole(const QString &role); |
103 | QString rotationRole() const; |
104 | |
105 | void setRowCategories(const QStringList &categories); |
106 | QStringList rowCategories() const; |
107 | void setColumnCategories(const QStringList &categories); |
108 | QStringList columnCategories() const; |
109 | |
110 | void setUseModelCategories(bool enable); |
111 | bool useModelCategories() const; |
112 | void setAutoRowCategories(bool enable); |
113 | bool autoRowCategories() const; |
114 | void setAutoColumnCategories(bool enable); |
115 | bool autoColumnCategories() const; |
116 | |
117 | void remap(const QString &rowRole, const QString &columnRole, |
118 | const QString &valueRole, const QString &rotationRole, |
119 | const QStringList &rowCategories, |
120 | const QStringList &columnCategories); |
121 | |
122 | Q_INVOKABLE int rowCategoryIndex(const QString& category); |
123 | Q_INVOKABLE int columnCategoryIndex(const QString& category); |
124 | |
125 | void setRowRolePattern(const QRegExp &pattern); |
126 | QRegExp rowRolePattern() const; |
127 | void setColumnRolePattern(const QRegExp &pattern); |
128 | QRegExp columnRolePattern() const; |
129 | void setValueRolePattern(const QRegExp &pattern); |
130 | QRegExp valueRolePattern() const; |
131 | void setRotationRolePattern(const QRegExp &pattern); |
132 | QRegExp rotationRolePattern() const; |
133 | |
134 | void setRowRoleReplace(const QString &replace); |
135 | QString rowRoleReplace() const; |
136 | void setColumnRoleReplace(const QString &replace); |
137 | QString columnRoleReplace() const; |
138 | void setValueRoleReplace(const QString &replace); |
139 | QString valueRoleReplace() const; |
140 | void setRotationRoleReplace(const QString &replace); |
141 | QString rotationRoleReplace() const; |
142 | |
143 | void setMultiMatchBehavior(MultiMatchBehavior behavior); |
144 | MultiMatchBehavior multiMatchBehavior() const; |
145 | |
146 | Q_SIGNALS: |
147 | void itemModelChanged(const QAbstractItemModel* itemModel); |
148 | void rowRoleChanged(const QString &role); |
149 | void columnRoleChanged(const QString &role); |
150 | void valueRoleChanged(const QString &role); |
151 | void rotationRoleChanged(const QString &role); |
152 | void rowCategoriesChanged(); |
153 | void columnCategoriesChanged(); |
154 | void useModelCategoriesChanged(bool enable); |
155 | void autoRowCategoriesChanged(bool enable); |
156 | void autoColumnCategoriesChanged(bool enable); |
157 | Q_REVISION(1) void rowRolePatternChanged(const QRegExp &pattern); |
158 | Q_REVISION(1) void columnRolePatternChanged(const QRegExp &pattern); |
159 | Q_REVISION(1) void valueRolePatternChanged(const QRegExp &pattern); |
160 | Q_REVISION(1) void rotationRolePatternChanged(const QRegExp &pattern); |
161 | Q_REVISION(1) void rowRoleReplaceChanged(const QString &replace); |
162 | Q_REVISION(1) void columnRoleReplaceChanged(const QString &replace); |
163 | Q_REVISION(1) void valueRoleReplaceChanged(const QString &replace); |
164 | Q_REVISION(1) void rotationRoleReplaceChanged(const QString &replace); |
165 | Q_REVISION(1) void multiMatchBehaviorChanged(MultiMatchBehavior behavior); |
166 | |
167 | protected: |
168 | QItemModelBarDataProxyPrivate *dptr(); |
169 | const QItemModelBarDataProxyPrivate *dptrc() const; |
170 | |
171 | private: |
172 | Q_DISABLE_COPY(QItemModelBarDataProxy) |
173 | |
174 | friend class BarItemModelHandler; |
175 | }; |
176 | |
177 | QT_END_NAMESPACE_DATAVISUALIZATION |
178 | |
179 | #endif |
180 | |