summaryrefslogtreecommitdiffstats
path: root/logic/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'logic/tasks')
-rw-r--r--logic/tasks/ProgressProvider.h41
-rw-r--r--logic/tasks/SequentialTask.cpp6
-rw-r--r--logic/tasks/SequentialTask.h4
-rw-r--r--logic/tasks/Task.cpp2
-rw-r--r--logic/tasks/Task.h10
5 files changed, 14 insertions, 49 deletions
diff --git a/logic/tasks/ProgressProvider.h b/logic/tasks/ProgressProvider.h
deleted file mode 100644
index 57bfd5c8..00000000
--- a/logic/tasks/ProgressProvider.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Copyright 2013-2015 MultiMC Contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <QObject>
-
-class ProgressProvider : public QObject
-{
- Q_OBJECT
-protected:
- explicit ProgressProvider(QObject *parent = 0) : QObject(parent)
- {
- }
-signals:
- void started();
- void progress(qint64 current, qint64 total);
- void succeeded();
- void failed(QString reason);
- void status(QString status);
-
-public:
- virtual ~ProgressProvider() {}
- virtual bool isRunning() const = 0;
-public
-slots:
- virtual void start() = 0;
- virtual void abort() = 0;
-};
diff --git a/logic/tasks/SequentialTask.cpp b/logic/tasks/SequentialTask.cpp
index e08206f8..f744d273 100644
--- a/logic/tasks/SequentialTask.cpp
+++ b/logic/tasks/SequentialTask.cpp
@@ -4,7 +4,7 @@ SequentialTask::SequentialTask(QObject *parent) : Task(parent), m_currentIndex(-
{
}
-void SequentialTask::addTask(std::shared_ptr<ProgressProvider> task)
+void SequentialTask::addTask(std::shared_ptr<Task> task)
{
m_queue.append(task);
}
@@ -19,7 +19,7 @@ void SequentialTask::startNext()
{
if (m_currentIndex != -1)
{
- std::shared_ptr<ProgressProvider> previous = m_queue[m_currentIndex];
+ std::shared_ptr<Task> previous = m_queue[m_currentIndex];
disconnect(previous.get(), 0, this, 0);
}
m_currentIndex++;
@@ -28,7 +28,7 @@ void SequentialTask::startNext()
emitSucceeded();
return;
}
- std::shared_ptr<ProgressProvider> next = m_queue[m_currentIndex];
+ std::shared_ptr<Task> next = m_queue[m_currentIndex];
connect(next.get(), SIGNAL(failed(QString)), this, SLOT(subTaskFailed(QString)));
connect(next.get(), SIGNAL(status(QString)), this, SLOT(subTaskStatus(QString)));
connect(next.get(), SIGNAL(progress(qint64, qint64)), this, SLOT(subTaskProgress(qint64, qint64)));
diff --git a/logic/tasks/SequentialTask.h b/logic/tasks/SequentialTask.h
index f1fe9c72..1c90765c 100644
--- a/logic/tasks/SequentialTask.h
+++ b/logic/tasks/SequentialTask.h
@@ -11,7 +11,7 @@ class SequentialTask : public Task
public:
explicit SequentialTask(QObject *parent = 0);
- void addTask(std::shared_ptr<ProgressProvider> task);
+ void addTask(std::shared_ptr<Task> task);
protected:
void executeTask();
@@ -24,6 +24,6 @@ slots:
void subTaskProgress(qint64 current, qint64 total);
private:
- QQueue<std::shared_ptr<ProgressProvider> > m_queue;
+ QQueue<std::shared_ptr<Task> > m_queue;
int m_currentIndex;
};
diff --git a/logic/tasks/Task.cpp b/logic/tasks/Task.cpp
index 56f8bf01..150ea48d 100644
--- a/logic/tasks/Task.cpp
+++ b/logic/tasks/Task.cpp
@@ -16,7 +16,7 @@
#include "Task.h"
#include <QDebug>
-Task::Task(QObject *parent) : ProgressProvider(parent)
+Task::Task(QObject *parent) : QObject(parent)
{
}
diff --git a/logic/tasks/Task.h b/logic/tasks/Task.h
index 089a110b..746a2b26 100644
--- a/logic/tasks/Task.h
+++ b/logic/tasks/Task.h
@@ -17,9 +17,8 @@
#include <QObject>
#include <QString>
-#include "ProgressProvider.h"
-class Task : public ProgressProvider
+class Task : public QObject
{
Q_OBJECT
public:
@@ -40,6 +39,13 @@ public:
*/
virtual QString failReason() const;
+signals:
+ void started();
+ void progress(qint64 current, qint64 total);
+ void succeeded();
+ void failed(QString reason);
+ void status(QString status);
+
public
slots:
virtual void start();