-
Notifications
You must be signed in to change notification settings - Fork 4
/
userthread.h
121 lines (95 loc) · 2.33 KB
/
userthread.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#ifndef USERTHREAD_H
#define USERTHREAD_H
#include <QThread>
#include <QFile>
#include <QMutex>
#include <QMutexLocker>
class QProgressDialog;
class UserThread : public QThread
{
Q_OBJECT
public:
UserThread( QObject *parent ) : QThread( parent ) {
setup();
};
~UserThread( void ) {
mutex.lock();
m_abort = true;
mutex.unlock();
wait();
};
virtual void setup( void );
void execute( QProgressDialog * );
bool isCanceled() const;
void setName( const QString& name );
void setLabel( const QString& label );
void setWindowTitle( const QString& title );
const QString& getLabel( void ) const;
const QString& getWindowTitle( void ) const;
void setMinimum( int min );
void setMaximum( int max );
int getMinimum( void ) const;
int getMaximum( void ) const;
signals:
void minimum( int );
void maximum( int );
void windowTitle( const QString& );
void labelText( const QString& );
void valueChanged( int );
void success( int );
void parseError( QString, QFile::FileError );
void documentError( QString, QString, int );
//void rateChanged( int, int, int );
public slots:
void cancel( void );
protected:
virtual void run( void ) {};
private:
bool m_abort;
mutable QMutex mutex;
int m_minimum;
int m_maximum;
QString m_name;
QString m_labelText;
QString m_windowTitle;
friend class ItemThread;
friend class SpriteThread;
friend class PictureThread;
friend class LibraryThread;
friend class ExportThread;
friend class ImportThread;
friend class DropFileThread;
};
class ItemThread : public UserThread
{
Q_OBJECT
public:
ItemThread( QObject *parent ) : UserThread( parent ) {};
protected:
virtual void run( void );
};
class SpriteThread : public UserThread
{
Q_OBJECT
public:
SpriteThread( QObject *parent ) : UserThread( parent ) {};
protected:
virtual void run( void );
};
class PictureThread : public UserThread
{
Q_OBJECT
public:
PictureThread( QObject *parent ) : UserThread( parent ) {};
protected:
virtual void run( void );
};
class LibraryThread : public UserThread
{
Q_OBJECT
public:
LibraryThread( QObject *parent ) : UserThread( parent ) {};
protected:
virtual void run( void );
};
#endif // SAVETHREAD_H