1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QITEMMODELSCATTERDATAPROXY_H
5#define QITEMMODELSCATTERDATAPROXY_H
6
7#include <QtGraphs/qscatterdataproxy.h>
8#include <QtCore/QAbstractItemModel>
9#include <QtCore/QString>
10#include <QtCore/QRegularExpression>
11
12QT_BEGIN_NAMESPACE
13
14class QItemModelScatterDataProxyPrivate;
15
16class Q_GRAPHS_EXPORT QItemModelScatterDataProxy : public QScatterDataProxy
17{
18 Q_OBJECT
19 Q_DECLARE_PRIVATE(QItemModelScatterDataProxy)
20 Q_PROPERTY(QAbstractItemModel* itemModel READ itemModel WRITE setItemModel NOTIFY itemModelChanged)
21 Q_PROPERTY(QString xPosRole READ xPosRole WRITE setXPosRole NOTIFY xPosRoleChanged)
22 Q_PROPERTY(QString yPosRole READ yPosRole WRITE setYPosRole NOTIFY yPosRoleChanged)
23 Q_PROPERTY(QString zPosRole READ zPosRole WRITE setZPosRole NOTIFY zPosRoleChanged)
24 Q_PROPERTY(QString rotationRole READ rotationRole WRITE setRotationRole NOTIFY rotationRoleChanged)
25 Q_PROPERTY(QRegularExpression xPosRolePattern READ xPosRolePattern WRITE setXPosRolePattern NOTIFY xPosRolePatternChanged)
26 Q_PROPERTY(QRegularExpression yPosRolePattern READ yPosRolePattern WRITE setYPosRolePattern NOTIFY yPosRolePatternChanged)
27 Q_PROPERTY(QRegularExpression zPosRolePattern READ zPosRolePattern WRITE setZPosRolePattern NOTIFY zPosRolePatternChanged)
28 Q_PROPERTY(QRegularExpression rotationRolePattern READ rotationRolePattern WRITE setRotationRolePattern NOTIFY rotationRolePatternChanged)
29 Q_PROPERTY(QString xPosRoleReplace READ xPosRoleReplace WRITE setXPosRoleReplace NOTIFY xPosRoleReplaceChanged)
30 Q_PROPERTY(QString yPosRoleReplace READ yPosRoleReplace WRITE setYPosRoleReplace NOTIFY yPosRoleReplaceChanged)
31 Q_PROPERTY(QString zPosRoleReplace READ zPosRoleReplace WRITE setZPosRoleReplace NOTIFY zPosRoleReplaceChanged)
32 Q_PROPERTY(QString rotationRoleReplace READ rotationRoleReplace WRITE setRotationRoleReplace NOTIFY rotationRoleReplaceChanged)
33
34public:
35 explicit QItemModelScatterDataProxy(QObject *parent = nullptr);
36 explicit QItemModelScatterDataProxy(QAbstractItemModel *itemModel, QObject *parent = nullptr);
37 explicit QItemModelScatterDataProxy(QAbstractItemModel *itemModel,
38 const QString &xPosRole, const QString &yPosRole,
39 const QString &zPosRole, QObject *parent = nullptr);
40 explicit QItemModelScatterDataProxy(QAbstractItemModel *itemModel,
41 const QString &xPosRole, const QString &yPosRole,
42 const QString &zPosRole, const QString &rotationRole,
43 QObject *parent = nullptr);
44 virtual ~QItemModelScatterDataProxy();
45
46 void setItemModel(QAbstractItemModel *itemModel);
47 QAbstractItemModel *itemModel() const;
48
49 void setXPosRole(const QString &role);
50 QString xPosRole() const;
51 void setYPosRole(const QString &role);
52 QString yPosRole() const;
53 void setZPosRole(const QString &role);
54 QString zPosRole() const;
55 void setRotationRole(const QString &role);
56 QString rotationRole() const;
57
58 void remap(const QString &xPosRole, const QString &yPosRole, const QString &zPosRole,
59 const QString &rotationRole);
60
61 void setXPosRolePattern(const QRegularExpression &pattern);
62 QRegularExpression xPosRolePattern() const;
63 void setYPosRolePattern(const QRegularExpression &pattern);
64 QRegularExpression yPosRolePattern() const;
65 void setZPosRolePattern(const QRegularExpression &pattern);
66 QRegularExpression zPosRolePattern() const;
67 void setRotationRolePattern(const QRegularExpression &pattern);
68 QRegularExpression rotationRolePattern() const;
69
70 void setXPosRoleReplace(const QString &replace);
71 QString xPosRoleReplace() const;
72 void setYPosRoleReplace(const QString &replace);
73 QString yPosRoleReplace() const;
74 void setZPosRoleReplace(const QString &replace);
75 QString zPosRoleReplace() const;
76 void setRotationRoleReplace(const QString &replace);
77 QString rotationRoleReplace() const;
78
79Q_SIGNALS:
80 void itemModelChanged(const QAbstractItemModel* itemModel);
81 void xPosRoleChanged(const QString &role);
82 void yPosRoleChanged(const QString &role);
83 void zPosRoleChanged(const QString &role);
84 void rotationRoleChanged(const QString &role);
85 void xPosRolePatternChanged(const QRegularExpression &pattern);
86 void yPosRolePatternChanged(const QRegularExpression &pattern);
87 void zPosRolePatternChanged(const QRegularExpression &pattern);
88 void rotationRolePatternChanged(const QRegularExpression &pattern);
89 void rotationRoleReplaceChanged(const QString &replace);
90 void xPosRoleReplaceChanged(const QString &replace);
91 void yPosRoleReplaceChanged(const QString &replace);
92 void zPosRoleReplaceChanged(const QString &replace);
93
94private:
95 Q_DISABLE_COPY(QItemModelScatterDataProxy)
96};
97
98QT_END_NAMESPACE
99
100#endif
101

source code of qtgraphs/src/graphs/data/qitemmodelscatterdataproxy.h