blob: 550436010967f7d89ab84f59495be8d1c46958b9 (
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
46
47
48
49
50
|
/*
* SPDX-FileCopyrightText: 2009 Peter Penz <[email protected]>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef UPDATEITEMSTATESTHREAD_H
#define UPDATEITEMSTATESTHREAD_H
#include "dolphin_export.h"
#include "views/versioncontrol/versioncontrolobserver.h"
#include <QMutex>
#include <QPointer>
#include <QThread>
/**
* The performance of updating the version state of items depends
* on the used plugin. To prevent that Dolphin gets blocked by a
* slow plugin, the updating is delegated to a thread.
*/
class DOLPHIN_EXPORT UpdateItemStatesThread : public QThread
{
Q_OBJECT
public:
/**
* @param plugin Version control plugin that is used to update the
* state of the items. Whenever the plugin is accessed
* from the thread creator after starting the thread,
* UpdateItemStatesThread::lockPlugin() and
* UpdateItemStatesThread::unlockPlugin() must be used.
* @param itemStates List of items, where the states get updated.
*/
UpdateItemStatesThread(KVersionControlPlugin *plugin, const QMap<QString, QVector<VersionControlObserver::ItemState>> &itemStates);
~UpdateItemStatesThread() override;
QMap<QString, QVector<VersionControlObserver::ItemState>> itemStates() const;
protected:
void run() override;
private:
QMutex *m_globalPluginMutex; // Protects the m_plugin globally
QPointer<KVersionControlPlugin> m_plugin;
QMap<QString, QVector<VersionControlObserver::ItemState>> m_itemStates;
};
#endif // UPDATEITEMSTATESTHREAD_H
|