base task and taskmanager class

This commit is contained in:
itsmattkc
2019-06-27 11:03:08 -07:00
parent e435f6ee83
commit 8117e13c15
8 changed files with 173 additions and 6 deletions
+46 -1
View File
@@ -20,7 +20,52 @@
#include "task.h"
Task::Task()
Task::Task() :
status_(kWaiting),
thread_(this)
{
connect(&thread_, SIGNAL(finished()), this, SLOT(ThreadComplete()));
}
void Task::Start()
{
set_status(kWorking);
thread_.start();
}
bool Task::Action()
{
return true;
}
const Task::Status &Task::status()
{
return status_;
}
const QString &Task::error()
{
return error_;
}
void Task::SetError(const QString &s)
{
error_ = s;
}
void Task::set_status(const Task::Status &status)
{
status_ = status;
emit StatusChanged(status_);
}
void Task::ThreadComplete()
{
if (thread_.result()) {
set_status(kFinished);
} else {
set_status(kError);
}
}