NOISSUE eliminate ProgressProvider
This commit is contained in:
@ -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;
|
||||
};
|
@ -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)));
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "Task.h"
|
||||
#include <QDebug>
|
||||
|
||||
Task::Task(QObject *parent) : ProgressProvider(parent)
|
||||
Task::Task(QObject *parent) : QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
Reference in New Issue
Block a user