From d6bbf7c08f51352718ca91aa584cbe7fbf3f34a5 Mon Sep 17 00:00:00 2001 From: kateleet Date: Sun, 26 Dec 2021 21:18:02 +0800 Subject: [PATCH] fix(trash): update folder --- model/foldermodel.cpp | 22 ++++++++++------------ qml/FolderPage.qml | 1 + 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/model/foldermodel.cpp b/model/foldermodel.cpp index b9522fb..afe34ab 100644 --- a/model/foldermodel.cpp +++ b/model/foldermodel.cpp @@ -89,6 +89,7 @@ static bool isDropBetweenSharedViews(const QList &urls, const QUrl &folder FolderModel::FolderModel(QObject *parent) : QSortFilterProxyModel(parent) , m_dirWatch(nullptr) + , m_status(None) , m_sortMode(0) , m_sortDesc(false) , m_sortDirsFirst(true) @@ -111,6 +112,7 @@ FolderModel::FolderModel(QObject *parent) m_dirLister = new DirLister(this); m_dirLister->setDelayedMimeTypes(true); m_dirLister->setAutoErrorHandlingEnabled(false, nullptr); + m_dirLister->setAutoUpdate(true); m_dirLister->setShowingDotFiles(m_showHiddenFiles); // connect(dirLister, &DirLister::error, this, &FolderModel::notification); @@ -381,31 +383,27 @@ void FolderModel::setUrl(const QString &url) // Refresh this directory. if (url == m_url) { - m_dirModel->dirLister()->updateDirectory(resolvedNewUrl); + refresh(); return; } + setStatus(Status::Listing); + m_pathHistory.append(resolvedNewUrl); beginResetModel(); m_url = resolvedNewUrl.toString(QUrl::PreferLocalFile); - m_dirModel->dirLister()->openUrl(resolvedNewUrl); + m_dirModel->dirLister()->openUrl(isTrash ? QUrl(QStringLiteral("trash:/")) : resolvedNewUrl); clearDragImages(); m_dragIndexes.clear(); endResetModel(); + if (isTrash) { + refresh(); + } + emit urlChanged(); emit resolvedUrlChanged(); - -// if (m_dirWatch) { -// delete m_dirWatch; -// m_dirWatch = nullptr; -// } - -// if (resolvedNewUrl.isValid()) { -// m_dirWatch = new KDirWatch(this); -// m_dirWatch->addFile(resolvedNewUrl.toLocalFile() + QLatin1String("/.directory")); -// } } QUrl FolderModel::resolvedUrl() const diff --git a/qml/FolderPage.qml b/qml/FolderPage.qml index 821d859..2b45ed6 100644 --- a/qml/FolderPage.qml +++ b/qml/FolderPage.qml @@ -148,6 +148,7 @@ Item { font.pointSize: 15 anchors.centerIn: parent visible: dirModel.status === FM.FolderModel.Ready + && _viewLoader.status === Loader.Ready && _viewLoader.item.count === 0 }