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