diff --git a/src/datatab.cpp b/src/datatab.cpp index e531c1e0..dc8419cf 100644 --- a/src/datatab.cpp +++ b/src/datatab.cpp @@ -22,7 +22,8 @@ DataTab::DataTab(OrganizerCore& core, PluginContainer& pc, QWidget* parent, mwui->dataTabRefresh, mwui->dataTree, mwui->dataTabShowOnlyConflicts, - mwui->dataTabShowFromArchives}, + mwui->dataTabShowFromArchives, + mwui->dataTabShowHiddenFiles}, m_needUpdate(true) { m_filetree.reset(new FileTree(core, m_pluginContainer, ui.tree)); @@ -52,6 +53,10 @@ DataTab::DataTab(OrganizerCore& core, PluginContainer& pc, QWidget* parent, onArchives(); }); + connect(ui.hiddenFiles, &QCheckBox::toggled, [&] { + onHiddenFiles(); + }); + connect(m_filetree.get(), &FileTree::executablesChanged, this, &DataTab::executablesChanged); @@ -66,6 +71,7 @@ void DataTab::saveState(Settings& s) const s.geometry().saveState(ui.tree->header()); s.widgets().saveChecked(ui.conflicts); s.widgets().saveChecked(ui.archives); + s.widgets().saveChecked(ui.hiddenFiles); } void DataTab::restoreState(const Settings& s) @@ -78,6 +84,7 @@ void DataTab::restoreState(const Settings& s) s.widgets().restoreChecked(ui.conflicts); s.widgets().restoreChecked(ui.archives); + s.widgets().restoreChecked(ui.hiddenFiles); } void DataTab::activated() @@ -146,6 +153,11 @@ void DataTab::onArchives() updateOptions(); } +void DataTab::onHiddenFiles() +{ + updateOptions(); +} + void DataTab::updateOptions() { using M = FileTreeModel; @@ -160,6 +172,10 @@ void DataTab::updateOptions() flags |= M::Archives; } + if (ui.hiddenFiles->isChecked()) { + flags |= M::HiddenFiles; + } + m_filetree->model()->setFlags(flags); updateTree(); } diff --git a/src/datatab.h b/src/datatab.h index 3eb91681..0bc0d83e 100644 --- a/src/datatab.h +++ b/src/datatab.h @@ -54,6 +54,7 @@ class DataTab : public QObject QTreeView* tree; QCheckBox* conflicts; QCheckBox* archives; + QCheckBox* hiddenFiles; }; OrganizerCore& m_core; @@ -69,6 +70,7 @@ class DataTab : public QObject void onItemExpanded(QTreeWidgetItem* item); void onConflicts(); void onArchives(); + void onHiddenFiles(); void updateOptions(); void ensureFullyLoaded(); bool isActive() const; 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; } diff --git a/src/filetreemodel.h b/src/filetreemodel.h index fbb70c7a..da0d2d3f 100644 --- a/src/filetreemodel.h +++ b/src/filetreemodel.h @@ -18,7 +18,8 @@ class FileTreeModel : public QAbstractItemModel NoFlags = 0x00, ConflictsOnly = 0x01, Archives = 0x02, - PruneDirectories = 0x04 + PruneDirectories = 0x04, + HiddenFiles = 0x08 }; enum Columns @@ -102,6 +103,8 @@ class FileTreeModel : public QAbstractItemModel bool showArchives() const; + bool showHiddenFiles() const; + // for `forFetching`, see top of filetreemodel.cpp void update(FileTreeItem& parentItem, const MOShared::DirectoryEntry& parentEntry, const std::wstring& parentPath, bool forFetching); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index c2ce37b3..c9e5db12 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1180,6 +1180,25 @@ + + + + Filter the list so that hidden files are shown. + + + + + + Filter the list so that hidden files are shown. + + + Hidden Files + + + true + + +