-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuture.cpp
More file actions
107 lines (85 loc) · 1.68 KB
/
future.cpp
File metadata and controls
107 lines (85 loc) · 1.68 KB
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
#include "future.h"
Future::Future(QObject *parent) : QObject(parent)
{
op_run = false;
op_done = false;
op_cancel = false;
op_progress_min = 0;
op_progress_max = 100;
op_progress = 0;
}
/*Future::Future(const Future &future)
{
op_run = future.op_run;
op_done = future.op_done;
op_cancel = future.op_cancel;
op_progress_min = future.op_progress_min;
op_progress_max = future.op_progress_max;
op_progress = future.op_progress;
}*/
Future::~Future()
{
}
bool Future::isRunning() const
{
return op_run;
}
bool Future::isDone() const
{
return op_done;
}
bool Future::needCancel() const
{
return op_cancel;
}
int Future::progress() const
{
return op_progress;
}
void Future::wait() const
{
while(!op_done);
}
void Future::start()
{
op_done = false;
op_run = true;
op_cancel = false;
emit started();
}
void Future::setProgressMinimum(int progress_min)
{
op_progress_min = progress_min;
emit progressMinimumChanged(op_progress_min);
}
void Future::setProgressMaximum(int progress_max)
{
op_progress_max = progress_max;
emit progressMaximumChanged(op_progress_max);
}
void Future::setProgressRange(int progress_min, int progress_max)
{
setProgressMinimum(progress_min);
setProgressMaximum(progress_max);
emit progressRangeChanged(op_progress_min, op_progress_max);
}
void Future::setProgress(int progress_val)
{
op_progress = progress_val;
emit progressChanged(op_progress);
}
void Future::finish()
{
op_done = true;
op_run = false;
emit finished();
}
void Future::finish(const QVariant &res)
{
op_res = res;
finish();
}
void Future::cancel()
{
op_cancel = true;
}