class EE::UI::Models::FileSystemModel¶
Overview¶
#include <filesystemmodel.hpp> class FileSystemModel: public EE::UI::Models::Model { public: // enums enum Column; enum Mode; // structs struct DisplayConfig; struct Node; // construction ~FileSystemModel(); // methods static std::shared_ptr<FileSystemModel> New(const std::string& rootPath, const Mode& mode = Mode::FilesAndDirectories, const DisplayConfig& displayConfig = DisplayConfig(), Translator* translator = nullptr, std::shared_ptr<ThreadPool> threadPool = {}); const Mode& getMode() const; const std::string& getRootPath() const; void setRootPath(const std::string& rootPath); Node* getNodeFromPath(std::string path, bool folderNode = false, bool invalidateTree = true); std::string_view getNodeRelativePath(const Node*) const; void reload(); void refresh(); virtual void update(); const Node& node(const ModelIndex& index) const; const Node* nodePtr(const ModelIndex& index) const; virtual size_t treeColumn() const; virtual size_t rowCount(const ModelIndex& = ModelIndex()) const; virtual size_t columnCount(const ModelIndex& = ModelIndex()) const; virtual bool hasChildren(const ModelIndex& = ModelIndex()) const; virtual std::string columnName(const size_t& column) const; virtual Variant data(const ModelIndex&, ModelRole role = ModelRole::Display) const; virtual ModelIndex parentIndex(const ModelIndex&) const; virtual ModelIndex index(int row, int column = 0, const ModelIndex& parent = ModelIndex()) const; virtual UIIcon* iconFor(const Node& node, const ModelIndex& index) const; void setMode(const Mode& mode); const DisplayConfig& getDisplayConfig() const; void setDisplayConfig(const DisplayConfig& displayConfig); const ModelIndex& getPreviouslySelectedIndex() const; void setPreviouslySelectedIndex(const ModelIndex& previouslySelectedIndex); bool handleFileEvent(const FileEvent& event); bool handleFileEvent(const FileEvent& event, const FileInfo& file); virtual bool isValid(const ModelIndex& index) const; virtual bool classModelRoleEnabled(); };
Inherited Members¶
public: // typedefs typedef std::function<Variant(const ModelIndex&, const void*data)> ModelStyler; // enums enum UpdateFlag; // structs struct Operation; // classes class Client; // methods virtual bool hasChildren(const ModelIndex& modelIndex = ModelIndex()) const; virtual size_t rowCount(const ModelIndex& = ModelIndex()) const = 0; virtual size_t columnCount(const ModelIndex& = ModelIndex()) const = 0; virtual std::string columnName(const size_t&) const; virtual std::string rowName(const size_t&) const; virtual Variant data(const ModelIndex&, ModelRole = ModelRole::Display) const = 0; virtual void update(); virtual ModelIndex parentIndex(const ModelIndex&) const; virtual ModelIndex index(int row, int column = 0, const ModelIndex& = ModelIndex()) const; virtual ModelIndex sibling(int row, int column, const ModelIndex& parent) const; virtual void setData(const ModelIndex&, const Variant&); virtual size_t treeColumn() const; virtual bool acceptsDrag(const ModelIndex&, const std::string& dataType); virtual bool isColumnSortable(const size_t&) const; virtual std::string dragDataType() const; virtual bool isEditable(const ModelIndex&) const; virtual bool isValid(const ModelIndex& index) const; virtual int keyColumn() const; virtual SortOrder sortOrder() const; virtual bool isSortable(); virtual void sort(const size_t&, const SortOrder&); virtual bool classModelRoleEnabled(); virtual bool tooltipModelRoleEnabled(); void registerView(UIAbstractView*); void unregisterView(UIAbstractView*); void registerClient(Client*); void unregisterClient(Client*); void refreshView() const; void setOnUpdate(const std::function<void()>& onUpdate); virtual void invalidate(unsigned int flags = Model::UpdateFlag::InvalidateAllIndexes); std::weak_ptr<PersistentHandle> registerPersistentIndex(ModelIndex const&); void beginInsertRows(ModelIndex const& parent, int first, int last); void beginInsertColumns(ModelIndex const& parent, int first, int last); void beginMoveRows(ModelIndex const& sourceParent, int first, int last, ModelIndex const& targetParent, int target_index); void beginMoveColumns(ModelIndex const& sourceParent, int first, int last, ModelIndex const& targetParent, int target_index); bool beginDeleteRows(ModelIndex const& parent, int first, int last); bool beginDeleteRows(ModelIndex const& index); bool beginDeleteColumns(ModelIndex const& parent, int first, int last); void endInsertRows(); void endInsertColumns(); void endMoveRows(); void endMoveColumns(); void endDeleteRows(); void endDeleteColumns(); Mutex& resourceMutex(); void acquireResourceMutex(); void releaseResourceMutex(); Uint32 subscribeModelStyler(const ModelStyler& styler); void unsubscribeModelStyler(Uint32 id);
Detailed Documentation¶
Methods¶
const Node* nodePtr(const ModelIndex& index) const
Returns the node for a valid index, or nullptr for a stale index (node deleted by a background refresh). An invalid index resolves to the root.
bool handleFileEvent(const FileEvent& event)
Processes a filesystem event (add/delete/move/modified).
Must be called from the main thread when views are attached: the method mutates view selections and metadata. ecode’s FileSystemListener dispatches watcher events to the main thread before calling this; direct callers are responsible for the same requirement.
bool handleFileEvent(const FileEvent& event, const FileInfo& file)
Processes a filesystem event using metadata captured when the event was received.
This avoids querying the filesystem from the main thread and preserves the state observed by an asynchronous listener even if a later event changes the path before this event is applied.