Plasma Engine  2.0
Loading...
Searching...
No Matches
RawDocumentTreeModel.moc.h
1#pragma once
2
3#include <EditorFramework/EditorFrameworkDLL.h>
4
5#include <QAbstractItemModel>
6#include <ToolsFoundation/Object/DocumentObjectManager.h>
7
9
15class PL_EDITORFRAMEWORK_DLL plQtDocumentTreeModelAdapter : public QObject
16{
17 Q_OBJECT;
18
19public:
21 plQtDocumentTreeModelAdapter(const plDocumentObjectManager* pTree, const plRTTI* pType, const char* szChildProperty);
22 virtual const plRTTI* GetType() const;
23 virtual const plString& GetChildProperty() const;
24
25 virtual QVariant data(const plDocumentObject* pObject, int iRow, int iColumn, int iRole = Qt::DisplayRole) const = 0;
26 virtual bool setData(const plDocumentObject* pObject, int iRow, int iColumn, const QVariant& value, int iRole) const;
27 virtual Qt::ItemFlags flags(const plDocumentObject* pObject, int iRow, int iColumn) const;
28
29Q_SIGNALS:
30 void dataChanged(const plDocumentObject* pObject, QVector<int> roles);
31
32protected:
33 const plDocumentObjectManager* m_pTree = nullptr;
34 const plRTTI* m_pType = nullptr;
35 plString m_sChildProperty;
36};
37
43class PL_EDITORFRAMEWORK_DLL plQtDummyAdapter : public plQtDocumentTreeModelAdapter
44{
45 Q_OBJECT;
46
47public:
48 plQtDummyAdapter(const plDocumentObjectManager* pTree, const plRTTI* pType, const char* szChildProperty);
49
50 virtual QVariant data(const plDocumentObject* pObject, int iRow, int iColumn, int iRole) const override;
51};
52
54class PL_EDITORFRAMEWORK_DLL plQtNamedAdapter : public plQtDocumentTreeModelAdapter
55{
56 Q_OBJECT;
57
58public:
59 plQtNamedAdapter(const plDocumentObjectManager* pTree, const plRTTI* pType, const char* szChildProperty, const char* szNameProperty);
61 virtual QVariant data(const plDocumentObject* pObject, int iRow, int iColumn, int iRole) const override;
62
63protected:
64 virtual void TreePropertyEventHandler(const plDocumentObjectPropertyEvent& e);
65
66protected:
67 plString m_sNameProperty;
68};
69
71class PL_EDITORFRAMEWORK_DLL plQtNameableAdapter : public plQtNamedAdapter
72{
73 Q_OBJECT;
74
75public:
76 plQtNameableAdapter(const plDocumentObjectManager* pTree, const plRTTI* pType, const char* szChildProperty, const char* szNameProperty);
78 virtual bool setData(const plDocumentObject* pObject, int iRow, int iColumn, const QVariant& value, int iRole) const override;
79 virtual Qt::ItemFlags flags(const plDocumentObject* pObject, int iRow, int iColumn) const override;
80};
81
85class PL_EDITORFRAMEWORK_DLL plQtDocumentTreeModel : public QAbstractItemModel
86{
87public:
88 plQtDocumentTreeModel(const plDocumentObjectManager* pTree, const plUuid& root = plUuid());
90
91 const plDocumentObjectManager* GetDocumentTree() const { return m_pDocumentTree; }
94 void AddAdapter(plQtDocumentTreeModelAdapter* pAdapter);
97 QModelIndex ComputeModelIndex(const plDocumentObject* pObject) const;
98
100 void SetAllowDragDrop(bool bAllow);
101
102 static bool MoveObjects(const plDragDropInfo& info);
103
104public: // QAbstractItemModel
105 virtual QModelIndex index(int iRow, int iColumn, const QModelIndex& parent = QModelIndex()) const override;
106 virtual QModelIndex parent(const QModelIndex& child) const override;
107
108 virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override;
109 virtual int columnCount(const QModelIndex& parent = QModelIndex()) const override;
110 virtual Qt::ItemFlags flags(const QModelIndex& index) const override;
111
112 virtual QVariant data(const QModelIndex& index, int iRole = Qt::DisplayRole) const override;
113 virtual bool setData(const QModelIndex& index, const QVariant& value, int iRole) override;
114
115 virtual Qt::DropActions supportedDropActions() const override;
116
117 virtual bool canDropMimeData(const QMimeData* pData, Qt::DropAction action, int iRow, int iColumn, const QModelIndex& parent) const override;
118 virtual bool dropMimeData(const QMimeData* pData, Qt::DropAction action, int iRow, int iColumn, const QModelIndex& parent) override;
119 virtual QStringList mimeTypes() const override;
120 virtual QMimeData* mimeData(const QModelIndexList& indexes) const override;
121
122protected:
123 virtual void TreeEventHandler(const plDocumentObjectStructureEvent& e);
124
125private:
126 QModelIndex ComputeParent(const plDocumentObject* pObject) const;
127 plInt32 ComputeIndex(const plDocumentObject* pObject) const;
128 const plDocumentObject* GetRoot() const;
129 bool IsUnderRoot(const plDocumentObject* pObject) const;
130
131 const plQtDocumentTreeModelAdapter* GetAdapter(const plRTTI* pType) const;
132
133protected:
134 const plDocumentObjectManager* m_pDocumentTree = nullptr;
135 const plUuid m_Root;
137 bool m_bAllowDragDrop = false;
138 plString m_sTargetContext = "scenetree";
139};
140
Definition EditorApp.moc.h:27
Definition DocumentObjectBase.h:11
Represents to content of a document. Every document has exactly one root object under which all objec...
Definition DocumentObjectManager.h:116
This type is used to provide plDragDropHandler instances with all the important information for a dra...
Definition DragDropInfo.h:16
Definition HashTable.h:333
Adapter that defines data for specific type in the plQtDocumentTreeModel.
Definition RawDocumentTreeModel.moc.h:16
Model that maps a document to a qt tree model.
Definition RawDocumentTreeModel.moc.h:86
Convenience class that returns the typename as Qt::DisplayRole. Use this for testing or for the docum...
Definition RawDocumentTreeModel.moc.h:44
Convenience class that implements setting the name via a property on the object.
Definition RawDocumentTreeModel.moc.h:72
Convenience class that implements getting the name via a property on the object.
Definition RawDocumentTreeModel.moc.h:55
This class holds information about reflected types. Each instance represents one type that is known t...
Definition RTTI.h:30
This data type is the abstraction for 128-bit Uuid (also known as GUID) instances.
Definition Uuid.h:11
Used by plDocumentObjectManager::m_PropertyEvents.
Definition DocumentObjectManager.h:77
Used by plDocumentObjectManager::m_StructureEvents.
Definition DocumentObjectManager.h:45