From f8650e3965582a57c3d0ccb5f234e6229051b16a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 26 Apr 2015 23:04:50 +0200 Subject: NOISSUE eliminate ProgressProvider --- logic/tasks/ProgressProvider.h | 41 ----------------------------------------- logic/tasks/SequentialTask.cpp | 6 +++--- logic/tasks/SequentialTask.h | 4 ++-- logic/tasks/Task.cpp | 2 +- logic/tasks/Task.h | 10 ++++++++-- 5 files changed, 14 insertions(+), 49 deletions(-) delete mode 100644 logic/tasks/ProgressProvider.h (limited to 'logic/tasks') 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 - -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 task) +void SequentialTask::addTask(std::shared_ptr task) { m_queue.append(task); } @@ -19,7 +19,7 @@ void SequentialTask::startNext() { if (m_currentIndex != -1) { - std::shared_ptr previous = m_queue[m_currentIndex]; + std::shared_ptr 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 next = m_queue[m_currentIndex]; + std::shared_ptr 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 task); + void addTask(std::shared_ptr task); protected: void executeTask(); @@ -24,6 +24,6 @@ slots: void subTaskProgress(qint64 current, qint64 total); private: - QQueue > m_queue; + QQueue > 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 -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 #include -#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(); -- cgit v1.2.3