From 7cee23157f099837fffc22380b85ac33a2006a49 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Mon, 19 Mar 2018 09:57:24 +0100 Subject: Introduce singleton for KFilePlacesModel There are various places where Dolphin created a new KFilePlacesModel which would then query all storage devices and do other expensive work. Differential Revision: https://phabricator.kde.org/D11283 --- src/dolphinmainwindow.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/dolphinmainwindow.cpp') diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index b09d7deef..d112007bc 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -25,6 +25,7 @@ #include "dolphindockwidget.h" #include "dolphincontextmenu.h" #include "dolphinnewfilemenu.h" +#include "dolphinplacesmodelsingleton.h" #include "dolphinrecenttabsmenu.h" #include "dolphintabwidget.h" #include "dolphinviewcontainer.h" @@ -993,8 +994,6 @@ void DolphinMainWindow::tabCountChanged(int count) void DolphinMainWindow::setUrlAsCaption(const QUrl& url) { - static KFilePlacesModel s_placesModel; - QString schemePrefix; if (!url.isLocalFile()) { schemePrefix.append(url.scheme() + " - "); @@ -1009,10 +1008,11 @@ void DolphinMainWindow::setUrlAsCaption(const QUrl& url) return; } - const auto& matchedPlaces = s_placesModel.match(s_placesModel.index(0,0), KFilePlacesModel::UrlRole, url, 1, Qt::MatchExactly); + KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel(); + const auto& matchedPlaces = placesModel->match(placesModel->index(0,0), KFilePlacesModel::UrlRole, url, 1, Qt::MatchExactly); if (!matchedPlaces.isEmpty()) { - setWindowTitle(s_placesModel.text(matchedPlaces.first())); + setWindowTitle(placesModel->text(matchedPlaces.first())); return; } -- cgit v1.3