]> cloud.milkyroute.net Git - dolphin.git/blob - src/views/versioncontrol/updateitemstatesthread.h
GIT_SILENT Upgrade release service version to 25.11.70.
[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 <QPointer>
15 #include <QThread>
16
17 /**
18 * The performance of updating the version state of items depends
19 * on the used plugin. To prevent that Dolphin gets blocked by a
20 * slow plugin, the updating is delegated to a thread.
21 */
22 class DOLPHIN_EXPORT UpdateItemStatesThread : public QThread
23 {
24 Q_OBJECT
25
26 public:
27 /**
28 * @param plugin Version control plugin that is used to update the
29 * state of the items. Whenever the plugin is accessed
30 * from the thread creator after starting the thread,
31 * UpdateItemStatesThread::lockPlugin() and
32 * UpdateItemStatesThread::unlockPlugin() must be used.
33 * @param itemStates List of items, where the states get updated.
34 */
35 UpdateItemStatesThread(KVersionControlPlugin *plugin, const QMap<QString, QVector<VersionControlObserver::ItemState>> &itemStates);
36 ~UpdateItemStatesThread() override;
37
38 QMap<QString, QVector<VersionControlObserver::ItemState>> itemStates() const;
39
40 protected:
41 void run() override;
42
43 private:
44 QMutex *m_globalPluginMutex; // Protects the m_plugin globally
45 QPointer<KVersionControlPlugin> m_plugin;
46
47 QMap<QString, QVector<VersionControlObserver::ItemState>> m_itemStates;
48 };
49
50 #endif // UPDATEITEMSTATESTHREAD_H