diff options
author | Petr Mrázek <peterix@gmail.com> | 2014-09-06 18:16:56 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2014-09-06 19:03:05 +0200 |
commit | 20cb97a35af5097e9d3b2062c0dfcb5f2e5fff5c (patch) | |
tree | 56bf51e681f2e73590a549499bd83d7b505c39f8 /logic/tasks/SequentialTask.cpp | |
parent | 36efcf8d3c0cbd7823fc65569cfc2b011435db2c (diff) | |
download | MultiMC-20cb97a35af5097e9d3b2062c0dfcb5f2e5fff5c.tar MultiMC-20cb97a35af5097e9d3b2062c0dfcb5f2e5fff5c.tar.gz MultiMC-20cb97a35af5097e9d3b2062c0dfcb5f2e5fff5c.tar.lz MultiMC-20cb97a35af5097e9d3b2062c0dfcb5f2e5fff5c.tar.xz MultiMC-20cb97a35af5097e9d3b2062c0dfcb5f2e5fff5c.zip |
Sync from quickmods
Diffstat (limited to 'logic/tasks/SequentialTask.cpp')
-rw-r--r-- | logic/tasks/SequentialTask.cpp | 45 |
1 files changed, 10 insertions, 35 deletions
diff --git a/logic/tasks/SequentialTask.cpp b/logic/tasks/SequentialTask.cpp index e0f8fcdd..e08206f8 100644 --- a/logic/tasks/SequentialTask.cpp +++ b/logic/tasks/SequentialTask.cpp @@ -1,31 +1,7 @@ #include "SequentialTask.h" -SequentialTask::SequentialTask(QObject *parent) : - Task(parent), m_currentIndex(-1) +SequentialTask::SequentialTask(QObject *parent) : Task(parent), m_currentIndex(-1) { - -} - -QString SequentialTask::getStatus() const -{ - if (m_queue.isEmpty() || m_currentIndex >= m_queue.size()) - { - return QString(); - } - return m_queue.at(m_currentIndex)->getStatus(); -} - -void SequentialTask::getProgress(qint64 ¤t, qint64 &total) -{ - current = 0; - total = 0; - for (int i = 0; i < m_queue.size(); ++i) - { - qint64 subCurrent, subTotal; - m_queue.at(i)->getProgress(subCurrent, subTotal); - current += subCurrent; - total += subTotal; - } } void SequentialTask::addTask(std::shared_ptr<ProgressProvider> task) @@ -55,10 +31,9 @@ void SequentialTask::startNext() std::shared_ptr<ProgressProvider> 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())); + connect(next.get(), SIGNAL(progress(qint64, qint64)), this, SLOT(subTaskProgress(qint64, qint64))); connect(next.get(), SIGNAL(succeeded()), this, SLOT(startNext())); next->start(); - emit status(getStatus()); } void SequentialTask::subTaskFailed(const QString &msg) @@ -69,16 +44,16 @@ void SequentialTask::subTaskStatus(const QString &msg) { setStatus(msg); } -void SequentialTask::subTaskProgress() +void SequentialTask::subTaskProgress(qint64 current, qint64 total) { - qint64 current, total; - getProgress(current, total); - if (total == 0) + if(total == 0) { setProgress(0); + return; } - else - { - setProgress(100 * current / total); - } + auto dcurrent = (double) current; + auto dtotal = (double) total; + auto partial = ((dcurrent / dtotal) * 100.0f)/* / double(m_queue.size())*/; + // auto bigpartial = double(m_currentIndex) * 100.0f / double(m_queue.size()); + setProgress(partial); } |