┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views/draganddrophelper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/views/draganddrophelper.cpp')
-rw-r--r--src/views/draganddrophelper.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/views/draganddrophelper.cpp b/src/views/draganddrophelper.cpp
index 831a9d43e..4d76992ca 100644
--- a/src/views/draganddrophelper.cpp
+++ b/src/views/draganddrophelper.cpp
@@ -29,12 +29,21 @@
#include <KIO/DropJob>
#include <KJobWidgets>
+QHash<QUrl, bool> DragAndDropHelper::m_urlListMatchesUrlCache;
bool DragAndDropHelper::urlListMatchesUrl(const QList<QUrl>& urls, const QUrl& destUrl)
{
- return std::find_if(urls.constBegin(), urls.constEnd(), [destUrl](const QUrl& url) {
- return url.matches(destUrl, QUrl::StripTrailingSlash);
- }) != urls.constEnd();
+ auto iteratorResult = m_urlListMatchesUrlCache.constFind(destUrl);
+ if (iteratorResult != m_urlListMatchesUrlCache.constEnd()) {
+ return *iteratorResult;
+ }
+
+ const bool destUrlMatches =
+ std::find_if(urls.constBegin(), urls.constEnd(), [destUrl](const QUrl& url) {
+ return url.matches(destUrl, QUrl::StripTrailingSlash);
+ }) != urls.constEnd();
+
+ return *m_urlListMatchesUrlCache.insert(destUrl, destUrlMatches);
}
KIO::DropJob* DragAndDropHelper::dropUrls(const QUrl& destUrl, QDropEvent* event, QWidget* window)
@@ -60,6 +69,11 @@ KIO::DropJob* DragAndDropHelper::dropUrls(const QUrl& destUrl, QDropEvent* event
return job;
}
- return 0;
+ return nullptr;
+}
+
+void DragAndDropHelper::clearUrlListMatchesUrlCache()
+{
+ DragAndDropHelper::m_urlListMatchesUrlCache.clear();
}