From 36f3e24cf31cfe6fad413d70ab8ad187a5251fb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Tue, 27 Jun 2017 04:32:53 +0200 Subject: [PATCH] NOISSUE remove some bad code in various Task related classes --- api/logic/java/JavaCheckerJob.cpp | 2 +- api/logic/java/JavaCheckerJob.h | 29 +++++------------------------ api/logic/java/JavaInstallList.cpp | 5 +++-- api/logic/java/JavaInstallList.h | 2 +- api/logic/java/JavaUtils.cpp | 1 - api/logic/java/JavaUtils.h | 1 - api/logic/net/NetJob.h | 1 - 7 files changed, 10 insertions(+), 31 deletions(-) diff --git a/api/logic/java/JavaCheckerJob.cpp b/api/logic/java/JavaCheckerJob.cpp index a111af20..c787233c 100644 --- a/api/logic/java/JavaCheckerJob.cpp +++ b/api/logic/java/JavaCheckerJob.cpp @@ -28,7 +28,7 @@ void JavaCheckerJob::partFinished(JavaCheckResult result) if (num_finished == javacheckers.size()) { - emit finished(javaresults); + emitSucceeded(); } } diff --git a/api/logic/java/JavaCheckerJob.h b/api/logic/java/JavaCheckerJob.h index c27a50c3..dc035cb2 100644 --- a/api/logic/java/JavaCheckerJob.h +++ b/api/logic/java/JavaCheckerJob.h @@ -22,6 +22,7 @@ class JavaCheckerJob; typedef std::shared_ptr JavaCheckerJobPtr; +// FIXME: this just seems horribly redundant class JavaCheckerJob : public Task { Q_OBJECT @@ -31,37 +32,19 @@ public: bool addJavaCheckerAction(JavaCheckerPtr base) { javacheckers.append(base); - total_progress++; // if this is already running, the action needs to be started right away! if (isRunning()) { - setProgress(current_progress, total_progress); - connect(base.get(), SIGNAL(checkFinished(JavaCheckResult)), SLOT(partFinished(JavaCheckResult))); - + setProgress(num_finished, javacheckers.size()); + connect(base.get(), &JavaChecker::checkFinished, this, &JavaCheckerJob::partFinished); base->performCheck(); } return true; } - - JavaCheckerPtr operator[](int index) + QList getResults() { - return javacheckers[index]; + return javaresults; } - ; - JavaCheckerPtr first() - { - if (javacheckers.size()) - return javacheckers[0]; - return JavaCheckerPtr(); - } - int size() const - { - return javacheckers.size(); - } - -signals: - void started(); - void finished(QList); private slots: void partFinished(JavaCheckResult result); @@ -73,7 +56,5 @@ private: QString m_job_name; QList javacheckers; QList javaresults; - qint64 current_progress = 0; - qint64 total_progress = 0; int num_finished = 0; }; diff --git a/api/logic/java/JavaInstallList.cpp b/api/logic/java/JavaInstallList.cpp index 44ac861d..39657f40 100644 --- a/api/logic/java/JavaInstallList.cpp +++ b/api/logic/java/JavaInstallList.cpp @@ -150,7 +150,7 @@ void JavaListLoadTask::executeTask() QList candidate_paths = ju.FindJavaPaths(); m_job = std::shared_ptr(new JavaCheckerJob("Java detection")); - connect(m_job.get(), SIGNAL(finished(QList)), this, SLOT(javaCheckerFinished(QList))); + connect(m_job.get(), &Task::finished, this, &JavaListLoadTask::javaCheckerFinished); connect(m_job.get(), &Task::progress, this, &Task::setProgress); qDebug() << "Probing the following Java paths: "; @@ -170,9 +170,10 @@ void JavaListLoadTask::executeTask() m_job->start(); } -void JavaListLoadTask::javaCheckerFinished(QList results) +void JavaListLoadTask::javaCheckerFinished() { QList candidates; + auto results = m_job->getResults(); qDebug() << "Found the following valid Java installations:"; for(JavaCheckResult result : results) diff --git a/api/logic/java/JavaInstallList.h b/api/logic/java/JavaInstallList.h index 934e588b..e0fa842e 100644 --- a/api/logic/java/JavaInstallList.h +++ b/api/logic/java/JavaInstallList.h @@ -72,7 +72,7 @@ public: void executeTask() override; public slots: - void javaCheckerFinished(QList results); + void javaCheckerFinished(); protected: std::shared_ptr m_job; diff --git a/api/logic/java/JavaUtils.cpp b/api/logic/java/JavaUtils.cpp index 0c2e72d7..fd28cca9 100644 --- a/api/logic/java/JavaUtils.cpp +++ b/api/logic/java/JavaUtils.cpp @@ -22,7 +22,6 @@ #include #include "java/JavaUtils.h" -#include "java/JavaCheckerJob.h" #include "java/JavaInstallList.h" #include "FileSystem.h" diff --git a/api/logic/java/JavaUtils.h b/api/logic/java/JavaUtils.h index 4418ac26..25fd57f5 100644 --- a/api/logic/java/JavaUtils.h +++ b/api/logic/java/JavaUtils.h @@ -17,7 +17,6 @@ #include -#include "JavaCheckerJob.h" #include "JavaChecker.h" #include "JavaInstallList.h" diff --git a/api/logic/net/NetJob.h b/api/logic/net/NetJob.h index cd576664..a7577246 100644 --- a/api/logic/net/NetJob.h +++ b/api/logic/net/NetJob.h @@ -76,7 +76,6 @@ private: qint64 current_progress = 0; qint64 total_progress = 1; int failures = 0; - bool connected = false; }; QString m_job_name; QList downloads;