From d380d27f47a67e6e682a4b980c66585f13a3d7b5 Mon Sep 17 00:00:00 2001 From: Mathias Tillman Date: Sun, 14 Sep 2014 18:53:05 +0200 Subject: Make the statusbar space info use the new KIO::fileSystemFreeSpace job. REVIEW: 120137 BUG: 245226 --- src/statusbar/mountpointobservercache.cpp | 41 +++++++++++++++++-------------- 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'src/statusbar/mountpointobservercache.cpp') diff --git a/src/statusbar/mountpointobservercache.cpp b/src/statusbar/mountpointobservercache.cpp index aff0c8e2f..5be2a9f95 100644 --- a/src/statusbar/mountpointobservercache.cpp +++ b/src/statusbar/mountpointobservercache.cpp @@ -51,33 +51,38 @@ MountPointObserverCache* MountPointObserverCache::instance() return &s_MountPointObserverCache->instance; } -MountPointObserver* MountPointObserverCache::observerForPath(const QString& path) +MountPointObserver* MountPointObserverCache::observerForUrl(const QUrl& url) { - // Try to share the observer with other paths that have the same mount point. - QString mountPointPath; - KMountPoint::Ptr mountPoint = KMountPoint::currentMountPoints().findByPath(path); - if (mountPoint) { - mountPointPath = mountPoint->mountPoint(); + QUrl cachedObserverUrl; + // If the url is a local path we can extract the root dir by checking the mount points. + if (url.isLocalFile()) { + // Try to share the observer with other paths that have the same mount point. + KMountPoint::Ptr mountPoint = KMountPoint::currentMountPoints().findByPath(url.toLocalFile()); + if (mountPoint) { + cachedObserverUrl = QUrl::fromLocalFile(mountPoint->mountPoint()); + } else { + // Even if determining the mount point failed, the observer might still + // be able to retrieve information about the url. + cachedObserverUrl = url.toLocalFile(); + } } else { - // Even if determining the mount point failed, KDiskFreeSpaceInfo might still - // be able to retrieve information about the path. - mountPointPath = path; + cachedObserverUrl = url.url(); } - MountPointObserver* observer = m_observerForMountPoint.value(mountPointPath); + MountPointObserver* observer = m_observerForMountPoint.value(cachedObserverUrl); if (!observer) { - observer = new MountPointObserver(mountPointPath, this); - m_observerForMountPoint.insert(mountPointPath, observer); - m_mountPointForObserver.insert(observer, mountPointPath); + observer = new MountPointObserver(cachedObserverUrl, this); + m_observerForMountPoint.insert(cachedObserverUrl, observer); + m_mountPointForObserver.insert(observer, cachedObserverUrl); Q_ASSERT(m_observerForMountPoint.count() == m_mountPointForObserver.count()); - connect(observer, SIGNAL(destroyed(QObject*)), this, SLOT(slotObserverDestroyed(QObject*))); + connect(observer, &MountPointObserver::destroyed, this, &MountPointObserverCache::slotObserverDestroyed); if (!m_updateTimer->isActive()) { m_updateTimer->start(10000); } - connect(m_updateTimer, SIGNAL(timeout()), observer, SLOT(update())); + connect(m_updateTimer, &QTimer::timeout, observer, &MountPointObserver::update); } return observer; @@ -86,9 +91,9 @@ MountPointObserver* MountPointObserverCache::observerForPath(const QString& path void MountPointObserverCache::slotObserverDestroyed(QObject* observer) { Q_ASSERT(m_mountPointForObserver.contains(observer)); - const QString& path = m_mountPointForObserver.value(observer); - Q_ASSERT(m_observerForMountPoint.contains(path)); - m_observerForMountPoint.remove(path); + const QUrl& url = m_mountPointForObserver.value(observer); + Q_ASSERT(m_observerForMountPoint.contains(url)); + m_observerForMountPoint.remove(url); m_mountPointForObserver.remove(observer); Q_ASSERT(m_observerForMountPoint.count() == m_mountPointForObserver.count()); -- cgit v1.3 From f67bdd0fb70520b83f6428619c02a996724543b5 Mon Sep 17 00:00:00 2001 From: Montel Laurent Date: Fri, 6 Feb 2015 13:21:27 +0100 Subject: kdelibs4support-- --- src/kitemviews/kfileitemlistwidget.cpp | 1 - src/kitemviews/private/kbaloorolesprovider.cpp | 2 +- src/panels/places/placesitemlistwidget.cpp | 2 -- src/settings/general/previewssettingspage.cpp | 2 +- src/settings/kcm/kcmdolphinnavigation.cpp | 3 --- src/settings/kcm/kcmdolphinservices.cpp | 3 --- src/settings/kcm/kcmdolphinviewmodes.cpp | 3 --- src/statusbar/mountpointobservercache.cpp | 3 +-- src/statusbar/statusbarspaceinfo.h | 2 +- src/views/dolphinnewfilemenuobserver.cpp | 3 +-- src/views/renamedialog.cpp | 3 +-- 11 files changed, 6 insertions(+), 21 deletions(-) (limited to 'src/statusbar/mountpointobservercache.cpp') diff --git a/src/kitemviews/kfileitemlistwidget.cpp b/src/kitemviews/kfileitemlistwidget.cpp index e88f0e5a8..5b5ae4d7e 100644 --- a/src/kitemviews/kfileitemlistwidget.cpp +++ b/src/kitemviews/kfileitemlistwidget.cpp @@ -21,7 +21,6 @@ #include "kfileitemmodel.h" #include "kitemlistview.h" -#include #include #include #include diff --git a/src/kitemviews/private/kbaloorolesprovider.cpp b/src/kitemviews/private/kbaloorolesprovider.cpp index 98e867582..e7d18a81a 100644 --- a/src/kitemviews/private/kbaloorolesprovider.cpp +++ b/src/kitemviews/private/kbaloorolesprovider.cpp @@ -35,7 +35,7 @@ struct KBalooRolesProviderSingleton { KBalooRolesProvider instance; }; -K_GLOBAL_STATIC(KBalooRolesProviderSingleton, s_balooRolesProvider) +Q_GLOBAL_STATIC(KBalooRolesProviderSingleton, s_balooRolesProvider) KBalooRolesProvider& KBalooRolesProvider::instance() diff --git a/src/panels/places/placesitemlistwidget.cpp b/src/panels/places/placesitemlistwidget.cpp index 83b00d798..18e561864 100644 --- a/src/panels/places/placesitemlistwidget.cpp +++ b/src/panels/places/placesitemlistwidget.cpp @@ -19,8 +19,6 @@ #include "placesitemlistwidget.h" -#include "kdebug.h" - PlacesItemListWidget::PlacesItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent) : KStandardItemListWidget(informant, parent) { diff --git a/src/settings/general/previewssettingspage.cpp b/src/settings/general/previewssettingspage.cpp index 9e5f18cc7..431722b62 100644 --- a/src/settings/general/previewssettingspage.cpp +++ b/src/settings/general/previewssettingspage.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include @@ -41,6 +40,7 @@ #include #include #include +#include #include #include diff --git a/src/settings/kcm/kcmdolphinnavigation.cpp b/src/settings/kcm/kcmdolphinnavigation.cpp index b56ce40c1..0b2729c33 100644 --- a/src/settings/kcm/kcmdolphinnavigation.cpp +++ b/src/settings/kcm/kcmdolphinnavigation.cpp @@ -35,9 +35,6 @@ DolphinNavigationConfigModule::DolphinNavigationConfigModule(QWidget* parent, co { Q_UNUSED(args); - //KF5 port: remove this line and define TRANSLATION_DOMAIN in CMakeLists.txt instead -//KLocale::global()->insertCatalog("dolphin"); - setButtons(KCModule::Default | KCModule::Help); QVBoxLayout* topLayout = new QVBoxLayout(this); diff --git a/src/settings/kcm/kcmdolphinservices.cpp b/src/settings/kcm/kcmdolphinservices.cpp index 619e44cc5..8bfdefebb 100644 --- a/src/settings/kcm/kcmdolphinservices.cpp +++ b/src/settings/kcm/kcmdolphinservices.cpp @@ -35,9 +35,6 @@ DolphinServicesConfigModule::DolphinServicesConfigModule(QWidget* parent, const { Q_UNUSED(args); - //KF5 port: remove this line and define TRANSLATION_DOMAIN in CMakeLists.txt instead -//KLocale::global()->insertCatalog("dolphin"); - setButtons(KCModule::Default | KCModule::Help); QVBoxLayout* topLayout = new QVBoxLayout(this); diff --git a/src/settings/kcm/kcmdolphinviewmodes.cpp b/src/settings/kcm/kcmdolphinviewmodes.cpp index f013180ad..0859e568a 100644 --- a/src/settings/kcm/kcmdolphinviewmodes.cpp +++ b/src/settings/kcm/kcmdolphinviewmodes.cpp @@ -41,9 +41,6 @@ DolphinViewModesConfigModule::DolphinViewModesConfigModule(QWidget* parent, cons { Q_UNUSED(args); - //KF5 port: remove this line and define TRANSLATION_DOMAIN in CMakeLists.txt instead -//KLocale::global()->insertCatalog("dolphin"); - setButtons(KCModule::Default | KCModule::Help); QVBoxLayout* topLayout = new QVBoxLayout(this); diff --git a/src/statusbar/mountpointobservercache.cpp b/src/statusbar/mountpointobservercache.cpp index 5be2a9f95..ab3744eac 100644 --- a/src/statusbar/mountpointobservercache.cpp +++ b/src/statusbar/mountpointobservercache.cpp @@ -21,7 +21,6 @@ #include "mountpointobserver.h" -#include #include #include @@ -31,7 +30,7 @@ class MountPointObserverCacheSingleton public: MountPointObserverCache instance; }; -K_GLOBAL_STATIC(MountPointObserverCacheSingleton, s_MountPointObserverCache) +Q_GLOBAL_STATIC(MountPointObserverCacheSingleton, s_MountPointObserverCache) MountPointObserverCache::MountPointObserverCache() : diff --git a/src/statusbar/statusbarspaceinfo.h b/src/statusbar/statusbarspaceinfo.h index 2ba7cbf0b..326c419ab 100644 --- a/src/statusbar/statusbarspaceinfo.h +++ b/src/statusbar/statusbarspaceinfo.h @@ -23,7 +23,7 @@ #include -#include +#include class QHideEvent; class QShowEvent; diff --git a/src/views/dolphinnewfilemenuobserver.cpp b/src/views/dolphinnewfilemenuobserver.cpp index 855f2675a..275e1c4fb 100644 --- a/src/views/dolphinnewfilemenuobserver.cpp +++ b/src/views/dolphinnewfilemenuobserver.cpp @@ -19,7 +19,6 @@ #include "dolphinnewfilemenuobserver.h" -#include #include "dolphinnewfilemenu.h" class DolphinNewFileMenuObserverSingleton @@ -27,7 +26,7 @@ class DolphinNewFileMenuObserverSingleton public: DolphinNewFileMenuObserver instance; }; -K_GLOBAL_STATIC(DolphinNewFileMenuObserverSingleton, s_DolphinNewFileMenuObserver) +Q_GLOBAL_STATIC(DolphinNewFileMenuObserverSingleton, s_DolphinNewFileMenuObserver) DolphinNewFileMenuObserver& DolphinNewFileMenuObserver::instance() { diff --git a/src/views/renamedialog.cpp b/src/views/renamedialog.cpp index f558f3c5f..6d009ba9a 100644 --- a/src/views/renamedialog.cpp +++ b/src/views/renamedialog.cpp @@ -24,8 +24,6 @@ #include #include #include //TODO port to QCollator -#include -#include #include #include @@ -35,6 +33,7 @@ #include #include #include +#include #include RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) : -- cgit v1.3