X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/d380d27f47a67e6e682a4b980c66585f13a3d7b5..94e08f04f4524fc4993b921a1ae1dd8cc6f8725c:/src/statusbar/mountpointobservercache.cpp diff --git a/src/statusbar/mountpointobservercache.cpp b/src/statusbar/mountpointobservercache.cpp index 5be2a9f95..348df4a07 100644 --- a/src/statusbar/mountpointobservercache.cpp +++ b/src/statusbar/mountpointobservercache.cpp @@ -1,27 +1,13 @@ -/*************************************************************************** - * Copyright (C) 2014 by Frank Reininghaus * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ +/* + * SPDX-FileCopyrightText: 2014 Frank Reininghaus + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ #include "mountpointobservercache.h" #include "mountpointobserver.h" -#include #include #include @@ -31,13 +17,12 @@ class MountPointObserverCacheSingleton public: MountPointObserverCache instance; }; -K_GLOBAL_STATIC(MountPointObserverCacheSingleton, s_MountPointObserverCache) +Q_GLOBAL_STATIC(MountPointObserverCacheSingleton, s_MountPointObserverCache) - -MountPointObserverCache::MountPointObserverCache() : - m_observerForMountPoint(), - m_mountPointForObserver(), - m_updateTimer(0) +MountPointObserverCache::MountPointObserverCache() + : m_observerForMountPoint() + , m_mountPointForObserver() + , m_updateTimer(nullptr) { m_updateTimer = new QTimer(this); } @@ -46,12 +31,12 @@ MountPointObserverCache::~MountPointObserverCache() { } -MountPointObserverCache* MountPointObserverCache::instance() +MountPointObserverCache *MountPointObserverCache::instance() { return &s_MountPointObserverCache->instance; } -MountPointObserver* MountPointObserverCache::observerForUrl(const QUrl& url) +MountPointObserver *MountPointObserverCache::observerForUrl(const QUrl &url) { QUrl cachedObserverUrl; // If the url is a local path we can extract the root dir by checking the mount points. @@ -63,13 +48,13 @@ MountPointObserver* MountPointObserverCache::observerForUrl(const QUrl& url) } else { // Even if determining the mount point failed, the observer might still // be able to retrieve information about the url. - cachedObserverUrl = url.toLocalFile(); + cachedObserverUrl = url; } } else { - cachedObserverUrl = url.url(); + cachedObserverUrl = url; } - MountPointObserver* observer = m_observerForMountPoint.value(cachedObserverUrl); + MountPointObserver *observer = m_observerForMountPoint.value(cachedObserverUrl); if (!observer) { observer = new MountPointObserver(cachedObserverUrl, this); m_observerForMountPoint.insert(cachedObserverUrl, observer); @@ -79,7 +64,7 @@ MountPointObserver* MountPointObserverCache::observerForUrl(const QUrl& url) connect(observer, &MountPointObserver::destroyed, this, &MountPointObserverCache::slotObserverDestroyed); if (!m_updateTimer->isActive()) { - m_updateTimer->start(10000); + m_updateTimer->start(60000); // 1 minute } connect(m_updateTimer, &QTimer::timeout, observer, &MountPointObserver::update); @@ -88,10 +73,10 @@ MountPointObserver* MountPointObserverCache::observerForUrl(const QUrl& url) return observer; } -void MountPointObserverCache::slotObserverDestroyed(QObject* observer) +void MountPointObserverCache::slotObserverDestroyed(QObject *observer) { Q_ASSERT(m_mountPointForObserver.contains(observer)); - const QUrl& url = m_mountPointForObserver.value(observer); + const QUrl &url = m_mountPointForObserver.value(observer); Q_ASSERT(m_observerForMountPoint.contains(url)); m_observerForMountPoint.remove(url); m_mountPointForObserver.remove(observer); @@ -102,3 +87,5 @@ void MountPointObserverCache::slotObserverDestroyed(QObject* observer) m_updateTimer->stop(); } } + +#include "moc_mountpointobservercache.cpp"