]> cloud.milkyroute.net Git - dolphin.git/blob - src/views/versioncontrol/updateitemstatesthread.h
Merge branch 'master' into kf6
[dolphin.git] / src / views / versioncontrol / updateitemstatesthread.h
1 /*
2 * SPDX-FileCopyrightText: 2009 Peter Penz <peter.penz19@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #ifndef UPDATEITEMSTATESTHREAD_H
8 #define UPDATEITEMSTATESTHREAD_H
9
10 #include "dolphin_export.h"
11 #include "views/versioncontrol/versioncontrolobserver.h"
12
13 #include <QMutex>
14 #include <QThread>
15
16 /**
17 * The performance of updating the version state of items depends
18 * on the used plugin. To prevent that Dolphin gets blocked by a
19 * slow plugin, the updating is delegated to a thread.
20 */
21 class DOLPHIN_EXPORT UpdateItemStatesThread : public QThread
22 {
23 Q_OBJECT
24
25 public:
26 /**
27 * @param plugin Version control plugin that is used to update the
28 * state of the items. Whenever the plugin is accessed
29 * from the thread creator after starting the thread,
30 * UpdateItemStatesThread::lockPlugin() and
31 * UpdateItemStatesThread::unlockPlugin() must be used.
32 * @param itemStates List of items, where the states get updated.
33 */
34 UpdateItemStatesThread(KVersionControlPlugin *plugin, const QMap<QString, QVector<VersionControlObserver::ItemState>> &itemStates);
35 ~UpdateItemStatesThread() override;
36
37 QMap<QString, QVector<VersionControlObserver::ItemState>> itemStates() const;
38
39 protected:
40 void run() override;
41
42 private:
43 QMutex *m_globalPluginMutex; // Protects the m_plugin globally
44 KVersionControlPlugin *m_plugin;
45
46 QMap<QString, QVector<VersionControlObserver::ItemState>> m_itemStates;
47 };
48
49 #endif // UPDATEITEMSTATESTHREAD_H