summaryrefslogtreecommitdiffstats
path: root/api/logic/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'api/logic/tasks')
-rw-r--r--api/logic/tasks/Task.cpp2
-rw-r--r--api/logic/tasks/Task.h19
-rw-r--r--api/logic/tasks/ThreadTask.cpp41
-rw-r--r--api/logic/tasks/ThreadTask.h26
4 files changed, 7 insertions, 81 deletions
diff --git a/api/logic/tasks/Task.cpp b/api/logic/tasks/Task.cpp
index 23ee08e4..94a4d428 100644
--- a/api/logic/tasks/Task.cpp
+++ b/api/logic/tasks/Task.cpp
@@ -76,7 +76,7 @@ bool Task::isFinished() const
return m_finished;
}
-bool Task::successful() const
+bool Task::wasSuccessful() const
{
return m_succeeded;
}
diff --git a/api/logic/tasks/Task.h b/api/logic/tasks/Task.h
index 47c4a13e..3654ed24 100644
--- a/api/logic/tasks/Task.h
+++ b/api/logic/tasks/Task.h
@@ -27,21 +27,15 @@ public:
explicit Task(QObject *parent = 0);
virtual ~Task() {};
- virtual bool isRunning() const;
-
- virtual bool isFinished() const;
-
- /*!
- * True if this task was successful.
- * If the task failed or is still running, returns false.
- */
- virtual bool successful() const;
+ bool isRunning() const;
+ bool isFinished() const;
+ bool wasSuccessful() const;
/*!
* Returns the string that was passed to emitFailed as the error message when the task failed.
* If the task hasn't failed, returns an empty string.
*/
- virtual QString failReason() const;
+ QString failReason() const;
virtual bool canAbort() const { return false; }
@@ -68,8 +62,7 @@ signals:
void failed(QString reason);
void status(QString status);
-public
-slots:
+public slots:
virtual void start();
virtual bool abort() { return false; };
@@ -84,7 +77,7 @@ public slots:
void setStatus(const QString &status);
void setProgress(qint64 current, qint64 total);
-protected:
+private:
bool m_running = false;
bool m_finished = false;
bool m_succeeded = false;
diff --git a/api/logic/tasks/ThreadTask.cpp b/api/logic/tasks/ThreadTask.cpp
deleted file mode 100644
index ddd1dee5..00000000
--- a/api/logic/tasks/ThreadTask.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-#include "ThreadTask.h"
-#include <QtConcurrentRun>
-ThreadTask::ThreadTask(Task * internal, QObject *parent) : Task(parent), m_internal(internal)
-{
-}
-
-void ThreadTask::start()
-{
- connect(m_internal, SIGNAL(failed(QString)), SLOT(iternal_failed(QString)));
- connect(m_internal, SIGNAL(progress(qint64,qint64)), SLOT(iternal_progress(qint64,qint64)));
- connect(m_internal, SIGNAL(started()), SLOT(iternal_started()));
- connect(m_internal, SIGNAL(status(QString)), SLOT(iternal_status(QString)));
- connect(m_internal, SIGNAL(succeeded()), SLOT(iternal_succeeded()));
- m_running = true;
- QtConcurrent::run(m_internal, &Task::start);
-}
-
-void ThreadTask::iternal_failed(QString reason)
-{
- emitFailed(reason);
-}
-
-void ThreadTask::iternal_progress(qint64 current, qint64 total)
-{
- progress(current, total);
-}
-
-void ThreadTask::iternal_started()
-{
- emit started();
-}
-
-void ThreadTask::iternal_status(QString status)
-{
- setStatus(status);
-}
-
-void ThreadTask::iternal_succeeded()
-{
- emitSucceeded();
-}
diff --git a/api/logic/tasks/ThreadTask.h b/api/logic/tasks/ThreadTask.h
deleted file mode 100644
index 46ce3a36..00000000
--- a/api/logic/tasks/ThreadTask.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#pragma once
-
-#include "Task.h"
-#include "multimc_logic_export.h"
-
-class MULTIMC_LOGIC_EXPORT ThreadTask : public Task
-{
- Q_OBJECT
-public:
- explicit ThreadTask(Task * internal, QObject * parent = nullptr);
-
-protected:
- void executeTask() {};
-
-public slots:
- virtual void start();
-
-private slots:
- void iternal_started();
- void iternal_progress(qint64 current, qint64 total);
- void iternal_succeeded();
- void iternal_failed(QString reason);
- void iternal_status(QString status);
-private:
- Task * m_internal;
-}; \ No newline at end of file