NOISSUE remove some bad code in various Task related classes

This commit is contained in:
Petr Mrázek 2017-06-27 04:32:53 +02:00
parent 89d3a66658
commit 36f3e24cf3
7 changed files with 10 additions and 31 deletions

View File

@ -28,7 +28,7 @@ void JavaCheckerJob::partFinished(JavaCheckResult result)
if (num_finished == javacheckers.size()) if (num_finished == javacheckers.size())
{ {
emit finished(javaresults); emitSucceeded();
} }
} }

View File

@ -22,6 +22,7 @@
class JavaCheckerJob; class JavaCheckerJob;
typedef std::shared_ptr<JavaCheckerJob> JavaCheckerJobPtr; typedef std::shared_ptr<JavaCheckerJob> JavaCheckerJobPtr;
// FIXME: this just seems horribly redundant
class JavaCheckerJob : public Task class JavaCheckerJob : public Task
{ {
Q_OBJECT Q_OBJECT
@ -31,37 +32,19 @@ public:
bool addJavaCheckerAction(JavaCheckerPtr base) bool addJavaCheckerAction(JavaCheckerPtr base)
{ {
javacheckers.append(base); javacheckers.append(base);
total_progress++;
// if this is already running, the action needs to be started right away! // if this is already running, the action needs to be started right away!
if (isRunning()) if (isRunning())
{ {
setProgress(current_progress, total_progress); setProgress(num_finished, javacheckers.size());
connect(base.get(), SIGNAL(checkFinished(JavaCheckResult)), SLOT(partFinished(JavaCheckResult))); connect(base.get(), &JavaChecker::checkFinished, this, &JavaCheckerJob::partFinished);
base->performCheck(); base->performCheck();
} }
return true; return true;
} }
QList<JavaCheckResult> getResults()
JavaCheckerPtr operator[](int index)
{ {
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<JavaCheckResult>);
private slots: private slots:
void partFinished(JavaCheckResult result); void partFinished(JavaCheckResult result);
@ -73,7 +56,5 @@ private:
QString m_job_name; QString m_job_name;
QList<JavaCheckerPtr> javacheckers; QList<JavaCheckerPtr> javacheckers;
QList<JavaCheckResult> javaresults; QList<JavaCheckResult> javaresults;
qint64 current_progress = 0;
qint64 total_progress = 0;
int num_finished = 0; int num_finished = 0;
}; };

View File

@ -150,7 +150,7 @@ void JavaListLoadTask::executeTask()
QList<QString> candidate_paths = ju.FindJavaPaths(); QList<QString> candidate_paths = ju.FindJavaPaths();
m_job = std::shared_ptr<JavaCheckerJob>(new JavaCheckerJob("Java detection")); m_job = std::shared_ptr<JavaCheckerJob>(new JavaCheckerJob("Java detection"));
connect(m_job.get(), SIGNAL(finished(QList<JavaCheckResult>)), this, SLOT(javaCheckerFinished(QList<JavaCheckResult>))); connect(m_job.get(), &Task::finished, this, &JavaListLoadTask::javaCheckerFinished);
connect(m_job.get(), &Task::progress, this, &Task::setProgress); connect(m_job.get(), &Task::progress, this, &Task::setProgress);
qDebug() << "Probing the following Java paths: "; qDebug() << "Probing the following Java paths: ";
@ -170,9 +170,10 @@ void JavaListLoadTask::executeTask()
m_job->start(); m_job->start();
} }
void JavaListLoadTask::javaCheckerFinished(QList<JavaCheckResult> results) void JavaListLoadTask::javaCheckerFinished()
{ {
QList<JavaInstallPtr> candidates; QList<JavaInstallPtr> candidates;
auto results = m_job->getResults();
qDebug() << "Found the following valid Java installations:"; qDebug() << "Found the following valid Java installations:";
for(JavaCheckResult result : results) for(JavaCheckResult result : results)

View File

@ -72,7 +72,7 @@ public:
void executeTask() override; void executeTask() override;
public slots: public slots:
void javaCheckerFinished(QList<JavaCheckResult> results); void javaCheckerFinished();
protected: protected:
std::shared_ptr<JavaCheckerJob> m_job; std::shared_ptr<JavaCheckerJob> m_job;

View File

@ -22,7 +22,6 @@
#include <QDebug> #include <QDebug>
#include "java/JavaUtils.h" #include "java/JavaUtils.h"
#include "java/JavaCheckerJob.h"
#include "java/JavaInstallList.h" #include "java/JavaInstallList.h"
#include "FileSystem.h" #include "FileSystem.h"

View File

@ -17,7 +17,6 @@
#include <QStringList> #include <QStringList>
#include "JavaCheckerJob.h"
#include "JavaChecker.h" #include "JavaChecker.h"
#include "JavaInstallList.h" #include "JavaInstallList.h"

View File

@ -76,7 +76,6 @@ private:
qint64 current_progress = 0; qint64 current_progress = 0;
qint64 total_progress = 1; qint64 total_progress = 1;
int failures = 0; int failures = 0;
bool connected = false;
}; };
QString m_job_name; QString m_job_name;
QList<NetActionPtr> downloads; QList<NetActionPtr> downloads;