tasks: added elapsed/remaining time displays for all tasks
This commit is contained in:
+20
-4
@@ -22,6 +22,7 @@
|
||||
#define TASK_H
|
||||
|
||||
#include <memory>
|
||||
#include <QDateTime>
|
||||
#include <QObject>
|
||||
|
||||
#include "common/cancelableobject.h"
|
||||
@@ -54,14 +55,15 @@ public:
|
||||
*/
|
||||
Task() :
|
||||
title_(tr("Task")),
|
||||
error_(tr("Unknown error"))
|
||||
error_(tr("Unknown error")),
|
||||
start_time_(0)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Retrieve the current title of this Task
|
||||
*/
|
||||
const QString& GetTitle()
|
||||
const QString& GetTitle() const
|
||||
{
|
||||
return title_;
|
||||
}
|
||||
@@ -69,11 +71,16 @@ public:
|
||||
/**
|
||||
* @brief Returns the error that occurred if Run() returns false
|
||||
*/
|
||||
const QString& GetError()
|
||||
const QString& GetError() const
|
||||
{
|
||||
return error_;
|
||||
}
|
||||
|
||||
const qint64& GetStartTime() const
|
||||
{
|
||||
return start_time_;
|
||||
}
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* @brief Run this task
|
||||
@@ -82,7 +89,12 @@ public slots:
|
||||
*
|
||||
* \see GetError() if this returns false.
|
||||
*/
|
||||
virtual bool Run() = 0;
|
||||
bool Start()
|
||||
{
|
||||
start_time_ = QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
return Run();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reset state so that Run() can be called again.
|
||||
@@ -104,6 +116,8 @@ public slots:
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool Run() = 0;
|
||||
|
||||
/**
|
||||
* @brief Set the error message
|
||||
*
|
||||
@@ -144,6 +158,8 @@ private:
|
||||
|
||||
QString error_;
|
||||
|
||||
qint64 start_time_;
|
||||
|
||||
};
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
Reference in New Issue
Block a user