KDStateMachineEditor  1.1.0
A framework for creating Qt State Machine metacode using a graphical user interface
objecttreemodel.h
1 /*
2  objecttreemodel.h
3 
4  This file is part of the KDAB State Machine Editor Library.
5 
6  Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com.
7  All rights reserved.
8  Author: Kevin Funk <kevin.funk@kdab.com>
9 
10  Licensees holding valid commercial KDAB State Machine Editor Library
11  licenses may use this file in accordance with the KDAB State Machine Editor
12  Library License Agreement provided with the Software.
13 
14  This file may be distributed and/or modified under the terms of the
15  GNU Lesser General Public License version 2.1 as published by the
16  Free Software Foundation and appearing in the file LICENSE.LGPL.txt included.
17 
18  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
19  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 
21  Contact info@kdab.com if any conditions of this licensing are not
22  clear to you.
23 */
24 
25 #ifndef KDSME_UTIL_OBJECTTREEMODEL_H
26 #define KDSME_UTIL_OBJECTTREEMODEL_H
27 
28 #include "kdsme_core_export.h"
29 
30 #include <QAbstractItemModel>
31 
32 namespace KDSME {
33 
34 class ObjectTreeModelPrivate;
35 
36 class KDSME_CORE_EXPORT ObjectTreeModel : public QAbstractItemModel
37 {
38  Q_OBJECT
39 
40 public:
41  class KDSME_CORE_EXPORT AppendOperation //krazy:exclude=dpointer
42  {
43  public:
44  AppendOperation(ObjectTreeModel* model, QObject* parent, int count = 1, int index = -1);
45  ~AppendOperation();
46 
47  private:
48  ObjectTreeModel* m_model;
49  };
50 
51  class KDSME_CORE_EXPORT RemoveOperation //krazy:exclude=dpointer
52  {
53  public:
54  RemoveOperation(ObjectTreeModel* model, QObject* object);
55  ~RemoveOperation();
56 
57  private:
58  ObjectTreeModel* m_model;
59  };
60 
61  class KDSME_CORE_EXPORT ResetOperation //krazy:exclude=dpointer
62  {
63  public:
64  explicit ResetOperation(ObjectTreeModel* model);
65  ~ResetOperation();
66 
67  private:
68  ObjectTreeModel* m_model;
69  };
70 
71  class KDSME_CORE_EXPORT ReparentOperation //krazy:exclude=dpointer
72  {
73  public:
74  ReparentOperation(ObjectTreeModel* model, QObject* object, QObject* newParent);
76 
77  private:
78  ObjectTreeModel* m_model;
79  };
80 
81  enum Roles {
82  ObjectRole = Qt::UserRole + 1,
84  UserRole = Qt::UserRole + 100
85  };
86 
87  explicit ObjectTreeModel(QObject *parent = nullptr);
88  ~ObjectTreeModel();
89 
90  void appendRootObject(QObject* object);
91  QList<QObject*> rootObjects() const;
92  void setRootObject(QObject* rootObject);
93  void setRootObjects(const QList<QObject*>& rootObjects);
94  void clear();
95 
96  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
97  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
98  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
99  QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
100  QModelIndex parent(const QModelIndex &index) const override;
101  QHash< int, QByteArray > roleNames() const override;
102 
103  QModelIndex indexForObject(QObject* object) const;
104 
105  protected:
106  Q_DECLARE_PRIVATE(ObjectTreeModel)
107  ObjectTreeModelPrivate * const d_ptr;
108 };
109 
110 }
111 
112 Q_DECLARE_METATYPE(KDSME::ObjectTreeModel*)
113 
114 #endif
Definition: objecttreemodel.h:41
Definition: objecttreemodel.h:51
Definition: objecttreemodel.h:71
Definition: objecttreemodel.h:36
return quint64
Definition: objecttreemodel.h:83
Roles
Definition: objecttreemodel.h:81
Definition: objecttreemodel.h:61
Definition: abstractexporter.h:33

Klarälvdalens Datakonsult AB (KDAB)
Qt-related services and products
http://www.kdab.com/
https://github.com/KDAB/KDStateMachineEditor