┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/statusbar/mountpointobservercache.h
blob: 92e1b6be3733be8670c623841dae286852223632 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
 * SPDX-FileCopyrightText: 2014 Frank Reininghaus <[email protected]>
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#ifndef MOUNTPOINTOBSERVERCACHE_H
#define MOUNTPOINTOBSERVERCACHE_H

#include <QHash>
#include <QObject>

class MountPointObserver;
class QTimer;

class MountPointObserverCache : public QObject
{
    Q_OBJECT

    MountPointObserverCache();
    ~MountPointObserverCache() override;

public:
    static MountPointObserverCache *instance();

    /**
     * Returns a MountPointObserver for the given \a url. A new observer is created if necessary.
     */
    MountPointObserver *observerForUrl(const QUrl &url);

private Q_SLOTS:
    /**
     * Removes the given \a observer from the cache.
     */
    void slotObserverDestroyed(QObject *observer);

private:
    QHash<QUrl, MountPointObserver *> m_observerForMountPoint;
    QHash<QObject *, QUrl> m_mountPointForObserver;
    QTimer *m_updateTimer;

    friend class MountPointObserverCacheSingleton;
};

#endif