1 // Copyright 2001-2018 Crytek GmbH / Crytek Group. All rights reserved.
7 #include <QItemSelection>
8 #include <QAdvancedTreeView.h>
10 #include <CrySerialization/IArchive.h>
11 #include <CrySerialization/NameGeneration.h>
12 #include "Serialization/QPropertyTree/QPropertyTree.h"
21 class QAbstractItemModel
;
30 class EDITOR_COMMON_API ExplorerTreeView
: public QAdvancedTreeView
36 void setModel(QAbstractItemModel
* model
);
37 void mousePressEvent(QMouseEvent
* ev
) override
;
40 void SignalClickOnSelectedItem(const QModelIndex
& index
);
41 void SignalStartDrag(const QModelIndex
& index
);
44 void mouseMoveEvent(QMouseEvent
* event
) override
;
45 void startDrag(Qt::DropActions supportedActions
) override
;
48 QMetaObject::Connection m_selectionHandler
;
50 bool m_treeSelectionChanged
;
55 class ExplorerFilterProxyModel
;
58 class EDITOR_COMMON_API ExplorerPanel
: public QWidget
63 ExplorerPanel(QWidget
* parent
, ExplorerData
* explorerData
);
65 ExplorerData
* GetExplorerData() const { return m_explorerData
; }
66 void SetDockWidget(QDockWidget
* dockWidget
);
67 void SetRootIndex(int rootIndex
);
68 int RootIndex() const { return m_explorerRootIndex
; }
69 void GetSelectedEntries(ExplorerEntries
* entries
, enum BMerge merge
= BMerge(0)) const;
70 void SetSelectedEntries(const ExplorerEntries
& entries
);
71 bool IsEntrySelected(ExplorerEntry
* entry
) const;
72 ExplorerEntry
* GetEntryByPath(const char* szPath
) const;
73 ExplorerEntry
* GetCurrentEntry() const;
74 void SetCurrentEntry(ExplorerEntry
* entry
);
76 void Serialize(Serialization::IArchive
& ar
);
79 void OnFilterTextChanged(const QString
& str
);
80 void OnTreeSelectionChanged(const QItemSelection
& selected
, const QItemSelection
& deselected
);
81 void OnClickedSelectedItem(const QModelIndex
& index
);
82 void OnStartDrag(const QModelIndex
& index
);
83 void OnHeaderContextMenu(const QPoint
& pos
);
84 void OnHeaderColumnToggle();
85 void OnContextMenu(const QPoint
& pos
);
86 void OnMenuCopyName();
87 void OnMenuCopyPath();
88 void OnMenuPasteSelection();
89 void OnMenuExpandAll();
90 void OnMenuCollapseAll();
92 void OnActivated(const QModelIndex
& index
);
93 void OnExplorerAction(const ExplorerAction
& action
);
94 void OnEntryImported(ExplorerEntry
* entry
, ExplorerEntry
* oldEntry
);
95 void OnEntryLoaded(ExplorerEntry
* entry
);
96 void OnRootButtonPressed();
97 void OnRootSelected(bool);
98 void OnExplorerEndReset();
99 void OnExplorerBeginBatchChange(int subtree
);
100 void OnExplorerEndBatchChange(int subtree
);
101 void OnExplorerEntryModified(ExplorerEntryModifyEvent
& ev
);
102 void OnAssetLoaded();
103 void OnRefreshFilter();
104 void OnFilterButtonToggled(bool filterMode
);
105 void OnFilterOptionsChanged();
107 void SignalSelectionChanged();
108 void SignalActivated(const ExplorerEntry
* entry
);
109 void SignalStartDrag(const ExplorerEntry
* entry
);
110 void SignalFocusIn();
112 bool eventFilter(QObject
* sender
, QEvent
* ev
) override
;
114 void SetTreeViewModel(QAbstractItemModel
* model
);
115 void UpdateRootMenu();
116 void SetExpanded(const QModelIndex
& index
, bool bExpand
, uint depth
= 0);
117 QModelIndex
FindIndexByEntry(ExplorerEntry
* entry
) const;
118 ExplorerEntry
* GetEntryByIndex(const QModelIndex
& index
) const;
120 unique_ptr
<FilterOptions
> m_filterOptions
;
121 QDockWidget
* m_dockWidget
;
122 ExplorerTreeView
* m_treeView
;
123 ExplorerModel
* m_model
;
124 ExplorerData
* m_explorerData
;
125 ExplorerFilterProxyModel
* m_filterModel
;
126 QSearchBox
* m_searchBox
;
127 QPushButton
* m_rootButton
;
128 QToolButton
* m_filterButton
;
131 vector
<QAction
*> m_rootMenuActions
;
132 int m_explorerRootIndex
;
134 uint m_batchChangesRunning
;
135 QPropertyTree
* m_filterOptionsTree
;