diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-04-06 23:45:24 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-04-06 23:45:24 (GMT) |
| commit | bbfbb81086897d50b67bf1494ac150eb607add72 (patch) | |
| tree | 80bab3ddb1f62f847f12947bc81fac2c091669b8 /src/tasks/Task.cpp | |
| parent | 8f8de875c6f7a68a3e47252a8653abb72fd398c1 (diff) | |
| download | powder-bbfbb81086897d50b67bf1494ac150eb607add72.zip powder-bbfbb81086897d50b67bf1494ac150eb607add72.tar.gz | |
Confirmation Dialogue, Save selection and multi-delete
Diffstat (limited to 'src/tasks/Task.cpp')
| -rw-r--r-- | src/tasks/Task.cpp | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/src/tasks/Task.cpp b/src/tasks/Task.cpp new file mode 100644 index 0000000..c20a0ea --- /dev/null +++ b/src/tasks/Task.cpp @@ -0,0 +1,84 @@ +/* + * Task.cpp + * + * Created on: Apr 6, 2012 + * Author: Simon + */ + + +#include <unistd.h> +#include "Task.h" +#include "TaskListener.h" + +void Task::SetTaskListener(TaskListener * listener) +{ + this->listener = listener; +} + +void Task::Start() +{ + pthread_create(&doWorkThread, 0, &Task::doWork_helper, this); +} + +int Task::GetProgress() +{ + return progress; +} + +std::string Task::GetStatus() +{ + return status; +} + +bool Task::GetDone() +{ + return done; +} + +Task::~Task() +{ + +} + +void Task::doWork() +{ + notifyStatus("Fake progress"); + for(int i = 0; i < 100; i++) + { + notifyProgress(i); + usleep((100)*1000); + } +} + +void * Task::doWork_helper(void * ref) +{ + ((Task*)ref)->doWork(); + ((Task*)ref)->notifyDone(); + return NULL; +} + +void Task::notifyProgress(int progress) +{ + if(this->progress!=progress) { + this->progress = progress; + if(listener) + listener->NotifyProgress(this); + } +} + +void Task::notifyStatus(std::string status) +{ + if(this->status!=status) { + this->status = status; + if(listener) + listener->NotifyStatus(this); + } +} + +void Task::notifyDone() +{ + if(listener) + { + done = true; listener->NotifyDone(this); + } +} |
