Skip to content

Commit

Permalink
fix: [workspace]show hidden files issue
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Lighto-Ku authored and deepin-bot[bot] committed Aug 30, 2023
1 parent 99cd94b commit 74a28d3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down

0 comments on commit 74a28d3

Please sign in to comment.