From f4a1d1b0222eeec4391d307820e8f56bc2d30038 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Tue, 27 Aug 2019 13:26:26 +0200 Subject: [PATCH] Always periodically dispatch pending items "Local" URLs can also be slow. This might jeopardize loading large local directories where a resorting could take place but imho it's better than leaving the user wondering when files will finally show up. However, it takes some time for KDirLister to initially signal items having been added, and only then our 2 second timer starts. Also, stop the timer when loading has completed. Differential Revision: https://phabricator.kde.org/D23460 --- src/kitemviews/kfileitemmodel.cpp | 8 ++------ src/kitemviews/kfileitemmodel.h | 2 -- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index de974e7e97..49c96ec37f 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -917,6 +917,7 @@ void KFileItemModel::resortAllItems() void KFileItemModel::slotCompleted() { + m_maximumUpdateIntervalTimer->stop(); dispatchPendingItemsToInsert(); if (!m_urlsToExpand.isEmpty()) { @@ -1007,7 +1008,7 @@ void KFileItemModel::slotItemsAdded(const QUrl &directoryUrl, const KFileItemLis } } - if (useMaximumUpdateInterval() && !m_maximumUpdateIntervalTimer->isActive()) { + if (!m_maximumUpdateIntervalTimer->isActive()) { // Assure that items get dispatched if no completed() or canceled() signal is // emitted during the maximum update interval. m_maximumUpdateIntervalTimer->start(); @@ -1875,11 +1876,6 @@ int KFileItemModel::stringCompare(const QString& a, const QString& b, const QCol return QString::compare(a, b, Qt::CaseSensitive); } -bool KFileItemModel::useMaximumUpdateInterval() const -{ - return !m_dirLister->url().isLocalFile(); -} - QList > KFileItemModel::nameRoleGroups() const { Q_ASSERT(!m_itemData.isEmpty()); diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h index 0f7926aae1..c2dfd01670 100644 --- a/src/kitemviews/kfileitemmodel.h +++ b/src/kitemviews/kfileitemmodel.h @@ -382,8 +382,6 @@ private: int stringCompare(const QString& a, const QString& b, const QCollator& collator) const; - bool useMaximumUpdateInterval() const; - QList > nameRoleGroups() const; QList > sizeRoleGroups() const; QList > timeRoleGroups(const std::function &fileTimeCb) const;