From 74a28d344deb95325772bd151dfc41d92e9d23f3 Mon Sep 17 00:00:00 2001 From: liuyangming Date: Wed, 30 Aug 2023 11:42:49 +0800 Subject: [PATCH] fix: [workspace]show hidden files issue save the show hidden settings in the model when it changed. Log: fix hidden files display issue Bug: https://pms.uniontech.com/bug-view-216609.html --- .../dfmplugin-workspace/models/fileviewmodel.cpp | 13 ++++++++++++- .../core/dfmplugin-workspace/models/fileviewmodel.h | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/plugins/filemanager/core/dfmplugin-workspace/models/fileviewmodel.cpp b/src/plugins/filemanager/core/dfmplugin-workspace/models/fileviewmodel.cpp index b570002e5b..6bad260eeb 100644 --- a/src/plugins/filemanager/core/dfmplugin-workspace/models/fileviewmodel.cpp +++ b/src/plugins/filemanager/core/dfmplugin-workspace/models/fileviewmodel.cpp @@ -44,6 +44,7 @@ FileViewModel::FileViewModel(QAbstractItemView *parent) itemRootData = new FileItemData(dirRootUrl); connect(ThumbnailFactory::instance(), &ThumbnailFactory::produceFinished, this, &FileViewModel::onFileThumbUpdated); connect(Application::instance(), &Application::genericAttributeChanged, this, &FileViewModel::onGenericAttributeChanged); + connect(Application::instance(), &Application::showedHiddenFilesChanged, this, &FileViewModel::onHiddenSettingChanged); connect(DConfigManager::instance(), &DConfigManager::valueChanged, this, &FileViewModel::onDConfigChanged); connect(&waitTimer, &QTimer::timeout, this, &FileViewModel::onSetCursorWait); waitTimer.setInterval(50); @@ -749,6 +750,16 @@ void FileViewModel::onSetCursorWait() QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); } +void FileViewModel::onHiddenSettingChanged(bool value) +{ + if (value) { + currentFilters |= QDir::Hidden; + } else { + currentFilters &= ~QDir::Hidden; + } + Q_EMIT requestShowHiddenChanged(value); +} + void FileViewModel::initFilterSortWork() { discardFilterSortObjects(); @@ -800,8 +811,8 @@ void FileViewModel::initFilterSortWork() connect(this, &FileViewModel::requestGetSourceData, filterSortWorker.data(), &FileSortWorker::handleModelGetSourceData, Qt::QueuedConnection); connect(this, &FileViewModel::requestRefreshAllChildren, filterSortWorker.data(), &FileSortWorker::handleRefresh, Qt::QueuedConnection); connect(this, &FileViewModel::requestClearThumbnail, filterSortWorker.data(), &FileSortWorker::handleClearThumbnail, Qt::QueuedConnection); + connect(this, &FileViewModel::requestShowHiddenChanged, filterSortWorker.data(), &FileSortWorker::onShowHiddenFileChanged, Qt::QueuedConnection); connect(filterSortWorker.data(), &FileSortWorker::requestUpdateView, this, &FileViewModel::onUpdateView, Qt::QueuedConnection); - connect(Application::instance(), &Application::showedHiddenFilesChanged, filterSortWorker.data(), &FileSortWorker::onShowHiddenFileChanged, Qt::QueuedConnection); connect(Application::instance(), &Application::appAttributeChanged, filterSortWorker.data(), &FileSortWorker::onAppAttributeChanged, Qt::QueuedConnection); filterSortThread->start(); diff --git a/src/plugins/filemanager/core/dfmplugin-workspace/models/fileviewmodel.h b/src/plugins/filemanager/core/dfmplugin-workspace/models/fileviewmodel.h index 39e5019348..37ed69021b 100644 --- a/src/plugins/filemanager/core/dfmplugin-workspace/models/fileviewmodel.h +++ b/src/plugins/filemanager/core/dfmplugin-workspace/models/fileviewmodel.h @@ -109,6 +109,7 @@ class FileViewModel : public QAbstractItemModel void requestSortChildren(Qt::SortOrder order, DFMGLOBAL_NAMESPACE::ItemRoles role, const bool isMixAndFile); void requestSetFilterData(const QVariant &data); void requestSetFilterCallback(FileViewFilterCallback callback); + void requestShowHiddenChanged(bool value); public Q_SLOTS: void onFileThumbUpdated(const QUrl &url, const QString &thumb); @@ -121,6 +122,7 @@ public Q_SLOTS: void onGenericAttributeChanged(DFMBASE_NAMESPACE::Application::GenericAttribute ga, const QVariant &value); void onDConfigChanged(const QString &config, const QString &key); void onSetCursorWait(); + void onHiddenSettingChanged(bool value); private: void initFilterSortWork();