summaryrefslogtreecommitdiffstats
path: root/logic/tasks/SequentialTask.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'logic/tasks/SequentialTask.cpp')
-rw-r--r--logic/tasks/SequentialTask.cpp45
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 &current, 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);
}