KDStateMachineEditor API Documentation  1.2.50
objecttreemodel.h
1 /*
2  This file is part of the KDAB State Machine Editor Library.
3 
4  SPDX-FileCopyrightText: 2014-2021 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5  Author: Kevin Funk <kevin.funk@kdab.com>
6 
7  SPDX-License-Identifier: LGPL-2.1-only OR LicenseRef-KDAB-KDStateMachineEditor
8 
9  Licensees holding valid commercial KDAB State Machine Editor Library
10  licenses may use this file in accordance with the KDAB State Machine Editor
11  Library License Agreement provided with the Software.
12 
13  Contact info@kdab.com if any conditions of this licensing are not clear to you.
14 */
15 
16 #ifndef KDSME_UTIL_OBJECTTREEMODEL_H
17 #define KDSME_UTIL_OBJECTTREEMODEL_H
18 
19 #include "kdsme_core_export.h"
20 
21 #include <QAbstractItemModel>
22 
23 namespace KDSME {
24 
25 class ObjectTreeModelPrivate;
26 
27 class KDSME_CORE_EXPORT ObjectTreeModel : public QAbstractItemModel
28 {
29  Q_OBJECT
30 
31 public:
32  class KDSME_CORE_EXPORT AppendOperation //krazy:exclude=dpointer
33  {
34  public:
35  AppendOperation(ObjectTreeModel* model, QObject* parent, int count = 1, int index = -1);
36  ~AppendOperation();
37 
38  private:
39  ObjectTreeModel* m_model;
40  };
41 
42  class KDSME_CORE_EXPORT RemoveOperation //krazy:exclude=dpointer
43  {
44  public:
45  RemoveOperation(ObjectTreeModel* model, QObject* object);
46  ~RemoveOperation();
47 
48  private:
49  ObjectTreeModel* m_model;
50  };
51 
52  class KDSME_CORE_EXPORT ResetOperation //krazy:exclude=dpointer
53  {
54  public:
55  explicit ResetOperation(ObjectTreeModel* model);
56  ~ResetOperation();
57 
58  private:
59  ObjectTreeModel* m_model;
60  };
61 
62  class KDSME_CORE_EXPORT ReparentOperation //krazy:exclude=dpointer
63  {
64  public:
65  ReparentOperation(ObjectTreeModel* model, QObject* object, QObject* newParent);
67 
68  private:
69  ObjectTreeModel* m_model;
70  };
71 
72  enum Roles {
73  ObjectRole = Qt::UserRole + 1,
75  UserRole = Qt::UserRole + 100
76  };
77 
78  explicit ObjectTreeModel(QObject *parent = nullptr);
79  ~ObjectTreeModel();
80 
81  void appendRootObject(QObject* object);
82  QList<QObject*> rootObjects() const;
83  void setRootObject(QObject* rootObject);
84  void setRootObjects(const QList<QObject*>& rootObjects);
85  void clear();
86 
87  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
88  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
89  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
90  QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
91  QModelIndex parent(const QModelIndex &index) const override;
92  QHash< int, QByteArray > roleNames() const override;
93 
94  QModelIndex indexForObject(QObject* object) const;
95 
96  protected:
97  Q_DECLARE_PRIVATE(ObjectTreeModel)
98  ObjectTreeModelPrivate * const d_ptr;
99 };
100 
101 }
102 
103 Q_DECLARE_METATYPE(KDSME::ObjectTreeModel*)
104 
105 #endif
Definition: objecttreemodel.h:32
Definition: objecttreemodel.h:42
Definition: objecttreemodel.h:62
Definition: objecttreemodel.h:27
return quint64
Definition: objecttreemodel.h:74
Roles
Definition: objecttreemodel.h:72
Definition: objecttreemodel.h:52
Definition: mainwindow.h:21

Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDStateMachineEditor
Create Qt State Machine metacode using a graphical user interface
https://github.com/KDAB/KDStateMachineEditor