diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-12-19 19:01:13 -0500 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2020-02-04 03:33:18 -0500 |
| commit | a7051df5da4139661169f227861b712453e7b8b0 (patch) | |
| tree | 43b0bf72d4bf1be6d6f1d12880a92545a5fa433f /src/filetreeitem.h | |
| parent | e0c605be1d32b74b14da18cc7de4a66a4f6f3ecb (diff) | |
split item and model
Diffstat (limited to 'src/filetreeitem.h')
| -rw-r--r-- | src/filetreeitem.h | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/filetreeitem.h b/src/filetreeitem.h new file mode 100644 index 00000000..516319ac --- /dev/null +++ b/src/filetreeitem.h @@ -0,0 +1,78 @@ +#ifndef MODORGANIZER_FILETREEITEM_INCLUDED +#define MODORGANIZER_FILETREEITEM_INCLUDED + +#include <QFileIconProvider> + +class FileTreeItem +{ +public: + enum Flag + { + NoFlags = 0x00, + Directory = 0x01, + FromArchive = 0x02, + Conflicted = 0x04 + }; + + Q_DECLARE_FLAGS(Flags, Flag); + + FileTreeItem(); + FileTreeItem( + FileTreeItem* parent, int originID, + std::wstring dataRelativeParentPath, std::wstring realPath, Flags flags, + std::wstring file, std::wstring mod); + + FileTreeItem(const FileTreeItem&) = delete; + FileTreeItem& operator=(const FileTreeItem&) = delete; + FileTreeItem(FileTreeItem&&) = default; + FileTreeItem& operator=(FileTreeItem&&) = default; + + void add(std::unique_ptr<FileTreeItem> child); + void insert(std::unique_ptr<FileTreeItem> child, std::size_t at); + void remove(std::size_t i); + const std::vector<std::unique_ptr<FileTreeItem>>& children() const; + + FileTreeItem* parent(); + int originID() const; + const QString& virtualParentPath() const; + QString virtualPath() const; + const QString& filename() const; + const QString& mod() const; + QFont font() const; + + const QString& realPath() const; + QString dataRelativeParentPath() const; + QString dataRelativeFilePath() const; + + QFileIconProvider::IconType icon() const; + + bool isDirectory() const; + bool isFromArchive() const; + bool isConflicted() const; + bool isHidden() const; + bool hasChildren() const; + + void setLoaded(bool b); + bool isLoaded() const; + void unload(); + + void setExpanded(bool b); + bool isStrictlyExpanded() const; + bool areChildrenVisible() const; + + QString debugName() const; + +private: + FileTreeItem* m_parent; + int m_originID; + QString m_virtualParentPath; + QString m_realPath; + Flags m_flags; + QString m_file; + QString m_mod; + bool m_loaded; + bool m_expanded; + std::vector<std::unique_ptr<FileTreeItem>> m_children; +}; + +#endif // MODORGANIZER_FILETREEITEM_INCLUDED |
