!XT (BREAK-16) (Sandbox) Remove double-newlines at the end of files.
[CRYENGINE.git] / Code / Sandbox / Plugins / EditorCommon / Explorer / ExplorerPanel.h
blob7f6b821e49de56513f4ed11cb93ad0be63581294
1 // Copyright 2001-2018 Crytek GmbH / Crytek Group. All rights reserved.
3 #pragma once
5 #include <memory>
6 #include <QWidget>
7 #include <QItemSelection>
8 #include <QAdvancedTreeView.h>
9 #include <QMetaObject>
10 #include <CrySerialization/IArchive.h>
11 #include <CrySerialization/NameGeneration.h>
12 #include "Serialization/QPropertyTree/QPropertyTree.h"
13 #include "Explorer.h"
15 class QToolButton;
16 class QLineEdit;
17 class QPushButton;
18 class QString;
19 class QItemSelection;
20 class QModelIndex;
21 class QAbstractItemModel;
22 class QMenu;
23 class QDockWidget;
24 class QMainWindow;
25 class QSearchBox;
27 namespace Explorer
30 class EDITOR_COMMON_API ExplorerTreeView : public QAdvancedTreeView
32 Q_OBJECT
33 public:
34 ExplorerTreeView();
36 void setModel(QAbstractItemModel* model);
37 void mousePressEvent(QMouseEvent* ev) override;
39 signals:
40 void SignalClickOnSelectedItem(const QModelIndex& index);
41 void SignalStartDrag(const QModelIndex& index);
43 protected:
44 void mouseMoveEvent(QMouseEvent* event) override;
45 void startDrag(Qt::DropActions supportedActions) override;
47 private:
48 QMetaObject::Connection m_selectionHandler;
49 bool m_dragging;
50 bool m_treeSelectionChanged;
53 class ExplorerData;
54 class ExplorerModel;
55 class ExplorerFilterProxyModel;
56 struct FilterOptions;
58 class EDITOR_COMMON_API ExplorerPanel : public QWidget
60 Q_OBJECT
62 public:
63 ExplorerPanel(QWidget* parent, ExplorerData* explorerData);
64 ~ExplorerPanel();
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);
78 public slots:
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();
106 signals:
107 void SignalSelectionChanged();
108 void SignalActivated(const ExplorerEntry* entry);
109 void SignalStartDrag(const ExplorerEntry* entry);
110 void SignalFocusIn();
111 protected:
112 bool eventFilter(QObject* sender, QEvent* ev) override;
113 private:
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;
129 QMenu* m_rootMenu;
131 vector<QAction*> m_rootMenuActions;
132 int m_explorerRootIndex;
133 bool m_filterMode;
134 uint m_batchChangesRunning;
135 QPropertyTree* m_filterOptionsTree;