Plasma Engine  2.0
Loading...
Searching...
No Matches
AssetBrowserFolderView.moc.h
1#pragma once
2
3#include <EditorFramework/EditorFrameworkDLL.h>
4#include <ToolsFoundation/FileSystem/FileSystemModel.h>
5#include <ToolsFoundation/Project/ToolsProject.h>
6
7#include <QItemDelegate>
8#include <QTreeWidget>
9#include <QValidator>
10
12
14class plFileNameValidator : public QValidator
15{
16public:
20 plFileNameValidator(QObject* pParent, plStringView sParentFolder, plStringView sCurrentName);
21 virtual QValidator::State validate(QString& ref_sInput, int& ref_iPos) const override;
22
23private:
24 plString m_sParentFolder;
25 plString m_sCurrentName;
26};
27
29class plFolderNameDelegate : public QItemDelegate
30{
31 Q_OBJECT
32
33public:
34 plFolderNameDelegate(QObject* pParent = nullptr);
35
36 virtual QWidget* createEditor(QWidget* pParent, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
37 virtual void setModelData(QWidget* pEditor, QAbstractItemModel* pModel, const QModelIndex& index) const override;
38
39signals:
40 void editingFinished(const QString& sAbsPath, const QString& sNewName) const;
41};
42
47class plQtAssetBrowserFolderView : public QTreeWidget
48{
49 Q_OBJECT
50public:
51 plQtAssetBrowserFolderView(QWidget* pParent);
53
55 void SetFilter(plQtAssetBrowserFilter* pFilter);
57 void SetDialogMode(bool bDialogMode);
58
59 virtual void mouseDoubleClickEvent(QMouseEvent* e) override;
60 virtual void mousePressEvent(QMouseEvent* e) override;
61
62public Q_SLOTS:
64 void NewFolder();
66 void TreeOpenExplorer();
68 void DeleteFolder();
69
70private Q_SLOTS:
71 void OnFolderEditingFinished(const QString& sAbsPath, const QString& sNewName);
72 void OnFlushFileSystemEvents();
73 void OnItemSelectionChanged();
74 void OnPathFilterChanged();
75
76protected:
77 virtual void dragMoveEvent(QDragMoveEvent* e) override;
78 virtual void mouseMoveEvent(QMouseEvent* e) override;
79 virtual void dropEvent(QDropEvent* event) override;
80 virtual Qt::DropActions supportedDropActions() const override;
81 plStatus canDrop(QDropEvent* e, plDynamicArray<plString>& out_files, plString& out_sTargetFolder);
82 virtual QStringList mimeTypes() const override;
83 virtual QMimeData* mimeData(const QList<QTreeWidgetItem*>& items) const override;
84 virtual void keyPressEvent(QKeyEvent* e) override;
85
86private:
87 bool SelectPathFilter(QTreeWidgetItem* pParent, const QString& sPath);
88 void UpdateDirectoryTree();
89 void ClearDirectoryTree();
90 void BuildDirectoryTree(const plDataDirPath& path, plStringView sCurPath, QTreeWidgetItem* pParent, plStringView sCurPathToItem, bool bIsHidden);
91 void RemoveDirectoryTreeItem(plStringView sCurPath, QTreeWidgetItem* pParent, plStringView sCurPathToItem);
92 QTreeWidgetItem* FindDirectoryTreeItem(plStringView sCurPath, QTreeWidgetItem* pParent, plStringView sCurPathToItem);
93 void FileSystemModelFolderEventHandler(const plFolderChangedEvent& e);
94 void ProjectEventHandler(const plToolsProjectEvent& e);
95
96private:
97 bool m_bDialogMode = false;
98 plUInt32 m_uiKnownAssetFolderCount = 0;
99 bool m_bTreeSelectionChangeInProgress = false;
100
101 plQtAssetBrowserFilter* m_pFilter = nullptr;
102
103 plMutex m_FolderStructureMutex;
104 plHybridArray<plFolderChangedEvent, 2> m_QueuedFolderEvents;
105};
Definition EditorApp.moc.h:27
A reference to a file or folder inside a data directory.
Definition DataDirPath.h:18
Definition DynamicArray.h:81
Basic file name validator. Makes sure that under a given parent folder, the new file name is valid an...
Definition AssetBrowserFolderView.moc.h:15
plFileNameValidator(QObject *pParent, plStringView sParentFolder, plStringView sCurrentName)
Constructor. Validator requires the current location and name of the file.
Definition AssetBrowserFolderView.cpp:12
Custom delegate for the eqQtAssetBrowserFolderView to enable renaming folders. Does not do any model ...
Definition AssetBrowserFolderView.moc.h:30
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
Provides a simple mechanism for mutual exclusion to prevent multiple threads from accessing a shared ...
Definition Mutex.h:13
Definition AssetBrowserFilter.moc.h:8
Folder tree of the asset browser to allow filtering by folder.
Definition AssetBrowserFolderView.moc.h:48
void SetDialogMode(bool bDialogMode)
In dialog mode, any modifications (folder movement, creation and deletion) are disabled.
Definition AssetBrowserFolderView.cpp:102
void TreeOpenExplorer()
Opens the current selected item in the windows explorer or OS equivalent.
Definition AssetBrowserFolderView.cpp:495
void NewFolder()
Creates a new folder under the current selected item and enters edit mode to allow the user to rename...
Definition AssetBrowserFolderView.cpp:120
void DeleteFolder()
Deletes the currently selected folder after confirmation.
Definition AssetBrowserFolderView.cpp:386
void SetFilter(plQtAssetBrowserFilter *pFilter)
Required to be set right after the ctor. This class will call plQtAssetBrowserFilter::SetPathFilter w...
Definition AssetBrowserFolderView.cpp:95
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
An plResult with an additional message for the reason of failure.
Definition Status.h:12
Definition ToolsProject.h:13