]> cloud.milkyroute.net Git - dolphin.git/blob - src/statusbar/mountpointobservercache.h
74cef0674b646c94d6a60c7de8d62d4a74fa49e8
[dolphin.git] / src / statusbar / mountpointobservercache.h
1 /***************************************************************************
2 * Copyright (C) 2014 by Frank Reininghaus <frank78ac@googlemail.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #ifndef MOUNTPOINTOBSERVERCACHE_H
21 #define MOUNTPOINTOBSERVERCACHE_H
22
23 #include <QHash>
24 #include <QObject>
25
26 class MountPointObserver;
27 class QTimer;
28
29 class MountPointObserverCache : public QObject
30 {
31 Q_OBJECT
32
33 MountPointObserverCache();
34 ~MountPointObserverCache() override;
35
36 public:
37 static MountPointObserverCache* instance();
38
39 /**
40 * Returns a MountPointObserver for the given \a url. A new observer is created if necessary.
41 */
42 MountPointObserver* observerForUrl(const QUrl& url);
43
44 private slots:
45 /**
46 * Removes the given \a observer from the cache.
47 */
48 void slotObserverDestroyed(QObject* observer);
49
50 private:
51 QHash<QUrl, MountPointObserver*> m_observerForMountPoint;
52 QHash<QObject*, QUrl> m_mountPointForObserver;
53 QTimer* m_updateTimer;
54
55 friend class MountPointObserverCacheSingleton;
56 };
57
58 #endif