-
Notifications
You must be signed in to change notification settings - Fork 1
/
worker.h
57 lines (42 loc) · 1.05 KB
/
worker.h
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
51
52
53
54
55
56
57
#ifndef WORKER_H
#define WORKER_H
#include <QObject>
#include <QElapsedTimer>
class QString;
class QThread;
class QAtomicInt;
namespace Farman
{
class Worker : public QObject
{
Q_OBJECT
public:
explicit Worker(QObject *parent = Q_NULLPTR);
virtual ~Worker() = default;
void exec();
void abort();
bool isAborted();
bool isError(int result);
Q_SIGNALS:
void start(int min, int max);
void process(const QString& description);
void progress(int value);
void outputConsole(const QString& consoleString);
void finished(int result);
void error(const QString& err);
public Q_SLOTS:
virtual void run() = 0;
protected:
void emitStart(int min, int max);
void emitProcess(const QString& description);
void emitProgress(int value);
void emitOutputConsole(const QString& consoleString);
void emitFinished(int result);
void emitError(const QString& err);
QElapsedTimer m_timer;
private:
QAtomicInt m_abort;
QThread* m_thread;
};
} // namespace Farman
#endif // WORKER_H