OSDN Git Service

ReadMe更新
[gefu/Gefu.git] / iworker.h
1 #ifndef IWORKER_H\r
2 #define IWORKER_H\r
3 \r
4 #include <QLabel>\r
5 #include <QMutex>\r
6 #include <QObject>\r
7 \r
8 class IWorker : public QObject\r
9 {\r
10     Q_OBJECT\r
11 public:\r
12     explicit IWorker(QObject *parent = 0);\r
13 \r
14     void setProgressText(QLabel *label) {\r
15         m_progressText = label;\r
16     }\r
17 \r
18     void requestStop() {\r
19         QMutexLocker lock(&m_Mutex);\r
20         m_stopRequested = true;\r
21     }\r
22 \r
23 protected:\r
24     QLabel *m_progressText;\r
25 \r
26     bool isStopRequested() {\r
27         QMutexLocker lock(&m_Mutex);\r
28         return m_stopRequested;\r
29     }\r
30 \r
31 signals:\r
32     void canceled();\r
33     void finished();\r
34     void operation(const QString &msg);\r
35     void success(const QString &msg);\r
36     void error(const QString &msg);\r
37 \r
38 public slots:\r
39     virtual void operate() = 0;\r
40 \r
41 private:\r
42     QMutex m_Mutex;\r
43     bool m_stopRequested;\r
44 };\r
45 \r
46 #endif // IWORKER_H\r