ImagingTools Core SDK
CItemModelBase.h
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ImtCore-Commercial
2#pragma once
3
4
5// Qt includes
6#include <QtCore/QObject>
7#include <QtCore/QVariant>
8
9
10namespace imtbase
11{
12
13
14class CItemModelBase : public QObject
15{
16 Q_OBJECT
17public:
18 explicit CItemModelBase(QObject* parent = nullptr);
19
20 Q_INVOKABLE virtual void beginChanges();
21 Q_INVOKABLE virtual void endChanges();
22 Q_INVOKABLE virtual QString toJson() const;
23 Q_INVOKABLE virtual bool createFromJson(const QString& json);
24 Q_INVOKABLE virtual bool fromObject(const QJsonObject& jsonObject); // copyFrom ???
25 Q_INVOKABLE virtual QString toGraphQL() const;
26 Q_INVOKABLE virtual bool isEqualWithModel(CItemModelBase* other) const;
27 Q_INVOKABLE virtual CItemModelBase* copyMe();
28 Q_INVOKABLE virtual bool copyFrom(CItemModelBase* other);
29 Q_INVOKABLE virtual bool copyTo(CItemModelBase* other);
30 Q_INVOKABLE virtual QVariant CreateObject(const QString& key);
31 Q_INVOKABLE virtual QStringList getProperties() const;
32 Q_INVOKABLE virtual QString getJSONKeyForProperty(const QString& propertyName) const;
33
34Q_SIGNALS:
35 void modelChanged(const QVariantList& changes);
36 void finished();
37
38public Q_SLOTS:
39 void OnInternalModelChanged();
40 void OnModelChanged(const QVariantList& changes);
41
42protected:
43 virtual CItemModelBase* CreateItemModel(const QString& jsonKey);
44
45private:
46 bool m_enableNotifications = true;
47 CItemModelBase* m_owner;
48 bool m_isTransaction = false;
49 int m_changeCount = 0;
50 QVariantList m_changeList;
51
52 void emitChange(const QString& name);
53};
54
55
56} // namespace imtbase
57
58