summaryrefslogtreecommitdiff
path: root/src/filetreemodel.cpp
diff options
context:
space:
mode:
authorJonathan Feenstra <26406078+JonathanFeenstra@users.noreply.github.com>2024-10-10 13:49:31 +0200
committerGitHub <noreply@github.com>2024-10-10 13:49:31 +0200
commitbafc058b7f84d5133d166cf322d0b7e07c170f49 (patch)
treef6fd2215f22d114e4182b3af2c908d4d5a16162a /src/filetreemodel.cpp
parent71434efaa98eff5bf6182b5151a367be61522474 (diff)
Add filter checkbox to data tab to show/hide hidden files (#2136)
Diffstat (limited to 'src/filetreemodel.cpp')
-rw-r--r--src/filetreemodel.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/filetreemodel.cpp b/src/filetreemodel.cpp
index 9d63a782..1fd6d2ab 100644
--- a/src/filetreemodel.cpp
+++ b/src/filetreemodel.cpp
@@ -182,8 +182,8 @@ void* makeInternalPointer(FileTreeItem* item)
FileTreeModel::FileTreeModel(OrganizerCore& core, QObject* parent)
: QAbstractItemModel(parent), m_core(core), m_enabled(true),
- m_root(FileTreeItem::createDirectory(this, nullptr, L"", L"")), m_flags(NoFlags),
- m_fullyLoaded(false), m_sortingEnabled(true)
+ m_root(FileTreeItem::createDirectory(this, nullptr, L"", L"")),
+ m_flags(HiddenFiles), m_fullyLoaded(false), m_sortingEnabled(true)
{
m_root->setExpanded(true);
m_sortTimer.setSingleShot(true);
@@ -269,6 +269,11 @@ bool FileTreeModel::showArchives() const
return (m_flags.testFlag(Archives) && m_core.settings().archiveParsing());
}
+bool FileTreeModel::showHiddenFiles() const
+{
+ return m_flags.testAnyFlag(HiddenFiles);
+}
+
QModelIndex FileTreeModel::index(int row, int col, const QModelIndex& parentIndex) const
{
if (auto* parentItem = itemFromIndex(parentIndex)) {
@@ -974,6 +979,11 @@ bool FileTreeModel::shouldShowFile(const FileEntry& file) const
return false;
}
+ if (!showHiddenFiles() && file.getName().ends_with(L".mohidden")) {
+ // hidden files shouldn't be shown, but this file is hidden
+ return false;
+ }
+
return true;
}