File indexing completed on 2024-05-12 09:51:08
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Frank Reininghaus <frank78ac@googlemail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef MOUNTPOINTOBSERVERCACHE_H 0008 #define MOUNTPOINTOBSERVERCACHE_H 0009 0010 #include <QHash> 0011 #include <QObject> 0012 0013 class MountPointObserver; 0014 class QTimer; 0015 0016 class MountPointObserverCache : public QObject 0017 { 0018 Q_OBJECT 0019 0020 MountPointObserverCache(); 0021 ~MountPointObserverCache() override; 0022 0023 public: 0024 static MountPointObserverCache *instance(); 0025 0026 /** 0027 * Returns a MountPointObserver for the given \a url. A new observer is created if necessary. 0028 */ 0029 MountPointObserver *observerForUrl(const QUrl &url); 0030 0031 private Q_SLOTS: 0032 /** 0033 * Removes the given \a observer from the cache. 0034 */ 0035 void slotObserverDestroyed(QObject *observer); 0036 0037 private: 0038 QHash<QUrl, MountPointObserver *> m_observerForMountPoint; 0039 QHash<QObject *, QUrl> m_mountPointForObserver; 0040 QTimer *m_updateTimer; 0041 0042 friend class MountPointObserverCacheSingleton; 0043 }; 0044 0045 #endif