From bafc058b7f84d5133d166cf322d0b7e07c170f49 Mon Sep 17 00:00:00 2001 From: Jonathan Feenstra <26406078+JonathanFeenstra@users.noreply.github.com> Date: Thu, 10 Oct 2024 13:49:31 +0200 Subject: Add filter checkbox to data tab to show/hide hidden files (#2136) --- src/filetreemodel.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/filetreemodel.cpp') 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; } -- cgit v1.3.1