diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -29,6 +29,7 @@ target_link_libraries( dolphinvcs PUBLIC Qt5::Widgets + Qt5::Concurrent ) set_target_properties(dolphinvcs PROPERTIES diff --git a/src/views/draganddrophelper.cpp b/src/views/draganddrophelper.cpp --- a/src/views/draganddrophelper.cpp +++ b/src/views/draganddrophelper.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -32,9 +33,18 @@ bool DragAndDropHelper::urlListMatchesUrl(const QList& urls, const QUrl& destUrl) { - return std::find_if(urls.constBegin(), urls.constEnd(), [destUrl](const QUrl& url) { - return url.matches(destUrl, QUrl::StripTrailingSlash); - }) != urls.constEnd(); + // This method is quite expensive and is called several times when the mouse is + // moved from the drag origin to the drop destination. + const QUrl& adjustedDestUrl = destUrl.adjusted(QUrl::StripTrailingSlash); + + // Use all the cpu availables to do the matches + std::function stripEqualFilter = [&](const QUrl &url) -> bool { + return adjustedDestUrl == url.adjusted(QUrl::StripTrailingSlash); + }; + // Creates a new QList with only the ones that are equal to destUrl + return QtConcurrent::blockingFiltered> + (urls.constBegin(), urls.constEnd(), stripEqualFilter) + .count() > 0; } KIO::DropJob* DragAndDropHelper::dropUrls(const QUrl& destUrl, QDropEvent* event, QWidget* window)