NOISSUE more refactoring
This commit is contained in:
parent
69213b1206
commit
9fc677c2a4
@ -143,7 +143,7 @@ public:
|
|||||||
virtual SettingsObjectPtr settings() const;
|
virtual SettingsObjectPtr settings() const;
|
||||||
|
|
||||||
/// returns a valid update task
|
/// returns a valid update task
|
||||||
virtual shared_qobject_ptr<Task> createUpdateTask(Net::Mode mode) = 0;
|
virtual Task::Ptr createUpdateTask(Net::Mode mode) = 0;
|
||||||
|
|
||||||
/// returns a valid launcher (task container)
|
/// returns a valid launcher (task container)
|
||||||
virtual shared_qobject_ptr<LaunchTask> createLaunchTask(
|
virtual shared_qobject_ptr<LaunchTask> createLaunchTask(
|
||||||
|
@ -63,7 +63,7 @@ public:
|
|||||||
* The task returned by this function should reset the model when it's done.
|
* The task returned by this function should reset the model when it's done.
|
||||||
* \return A pointer to a task that reloads the version list.
|
* \return A pointer to a task that reloads the version list.
|
||||||
*/
|
*/
|
||||||
virtual shared_qobject_ptr<Task> getLoadTask() = 0;
|
virtual Task::Ptr getLoadTask() = 0;
|
||||||
|
|
||||||
//! Checks whether or not the list is loaded. If this returns false, the list should be
|
//! Checks whether or not the list is loaded. If this returns false, the list should be
|
||||||
//loaded.
|
//loaded.
|
||||||
|
@ -133,7 +133,7 @@ AboutDialog::~AboutDialog()
|
|||||||
|
|
||||||
void AboutDialog::loadPatronList()
|
void AboutDialog::loadPatronList()
|
||||||
{
|
{
|
||||||
netJob.reset(new NetJob("Patreon Patron List"));
|
netJob = new NetJob("Patreon Patron List");
|
||||||
netJob->addNetAction(Net::Download::makeByteArray(QUrl("https://files.multimc.org/patrons.txt"), &dataSink));
|
netJob->addNetAction(Net::Download::makeByteArray(QUrl("https://files.multimc.org/patrons.txt"), &dataSink));
|
||||||
connect(netJob.get(), &NetJob::succeeded, this, &AboutDialog::patronListLoaded);
|
connect(netJob.get(), &NetJob::succeeded, this, &AboutDialog::patronListLoaded);
|
||||||
netJob->start(APPLICATION->network());
|
netJob->start(APPLICATION->network());
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <QtCore/QEventLoop>
|
#include <QtCore/QEventLoop>
|
||||||
|
|
||||||
#include "minecraft/auth/MinecraftAccount.h"
|
#include "minecraft/auth/MinecraftAccount.h"
|
||||||
|
#include "tasks/Task.h"
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
@ -54,5 +55,5 @@ slots:
|
|||||||
private:
|
private:
|
||||||
Ui::LoginDialog *ui;
|
Ui::LoginDialog *ui;
|
||||||
MinecraftAccountPtr m_account;
|
MinecraftAccountPtr m_account;
|
||||||
shared_qobject_ptr<Task> m_loginTask;
|
Task::Ptr m_loginTask;
|
||||||
};
|
};
|
||||||
|
@ -29,13 +29,13 @@ JavaInstallList::JavaInstallList(QObject *parent) : BaseVersionList(parent)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_qobject_ptr<Task> JavaInstallList::getLoadTask()
|
Task::Ptr JavaInstallList::getLoadTask()
|
||||||
{
|
{
|
||||||
load();
|
load();
|
||||||
return getCurrentTask();
|
return getCurrentTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_qobject_ptr<Task> JavaInstallList::getCurrentTask()
|
Task::Ptr JavaInstallList::getCurrentTask()
|
||||||
{
|
{
|
||||||
if(m_status == Status::InProgress)
|
if(m_status == Status::InProgress)
|
||||||
{
|
{
|
||||||
|
@ -40,7 +40,7 @@ class JavaInstallList : public BaseVersionList
|
|||||||
public:
|
public:
|
||||||
explicit JavaInstallList(QObject *parent = 0);
|
explicit JavaInstallList(QObject *parent = 0);
|
||||||
|
|
||||||
shared_qobject_ptr<Task> getLoadTask() override;
|
Task::Ptr getLoadTask() override;
|
||||||
bool isLoaded() override;
|
bool isLoaded() override;
|
||||||
const BaseVersionPtr at(int i) const override;
|
const BaseVersionPtr at(int i) const override;
|
||||||
int count() const override;
|
int count() const override;
|
||||||
@ -54,7 +54,7 @@ public slots:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void load();
|
void load();
|
||||||
shared_qobject_ptr<Task> getCurrentTask();
|
Task::Ptr getCurrentTask();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Status m_status = Status::NotDone;
|
Status m_status = Status::NotDone;
|
||||||
|
@ -39,7 +39,7 @@ private slots:
|
|||||||
void updateFinished();
|
void updateFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
shared_qobject_ptr<Task> m_updateTask;
|
Task::Ptr m_updateTask;
|
||||||
bool m_aborted = false;
|
bool m_aborted = false;
|
||||||
Net::Mode m_mode = Net::Mode::Offline;
|
Net::Mode m_mode = Net::Mode::Offline;
|
||||||
};
|
};
|
||||||
|
@ -154,7 +154,7 @@ bool Meta::BaseEntity::shouldStartRemoteUpdate() const
|
|||||||
return m_updateStatus != UpdateStatus::InProgress;
|
return m_updateStatus != UpdateStatus::InProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_qobject_ptr<Task> Meta::BaseEntity::getCurrentTask()
|
Task::Ptr Meta::BaseEntity::getCurrentTask()
|
||||||
{
|
{
|
||||||
if(m_updateStatus == UpdateStatus::InProgress)
|
if(m_updateStatus == UpdateStatus::InProgress)
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,7 @@ VersionList::VersionList(const QString &uid, QObject *parent)
|
|||||||
setObjectName("Version list: " + uid);
|
setObjectName("Version list: " + uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_qobject_ptr<Task> VersionList::getLoadTask()
|
Task::Ptr VersionList::getLoadTask()
|
||||||
{
|
{
|
||||||
load(Net::Mode::Online);
|
load(Net::Mode::Online);
|
||||||
return getCurrentTask();
|
return getCurrentTask();
|
||||||
|
@ -41,7 +41,7 @@ public:
|
|||||||
VersionPtrRole
|
VersionPtrRole
|
||||||
};
|
};
|
||||||
|
|
||||||
shared_qobject_ptr<Task> getLoadTask() override;
|
Task::Ptr getLoadTask() override;
|
||||||
bool isLoaded() override;
|
bool isLoaded() override;
|
||||||
const BaseVersionPtr at(int i) const override;
|
const BaseVersionPtr at(int i) const override;
|
||||||
int count() const override;
|
int count() const override;
|
||||||
|
@ -69,7 +69,7 @@ LoadResult composeLoadResult(LoadResult a, LoadResult b)
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LoadResult loadComponent(ComponentPtr component, shared_qobject_ptr<Task>& loadTask, Net::Mode netmode)
|
static LoadResult loadComponent(ComponentPtr component, Task::Ptr& loadTask, Net::Mode netmode)
|
||||||
{
|
{
|
||||||
if(component->m_loaded)
|
if(component->m_loaded)
|
||||||
{
|
{
|
||||||
@ -127,7 +127,7 @@ static LoadResult loadComponent(ComponentPtr component, shared_qobject_ptr<Task>
|
|||||||
|
|
||||||
// FIXME: dead code. determine if this can still be useful?
|
// FIXME: dead code. determine if this can still be useful?
|
||||||
/*
|
/*
|
||||||
static LoadResult loadPackProfile(ComponentPtr component, shared_qobject_ptr<Task>& loadTask, Net::Mode netmode)
|
static LoadResult loadPackProfile(ComponentPtr component, Task::Ptr& loadTask, Net::Mode netmode)
|
||||||
{
|
{
|
||||||
if(component->m_loaded)
|
if(component->m_loaded)
|
||||||
{
|
{
|
||||||
@ -152,7 +152,7 @@ static LoadResult loadPackProfile(ComponentPtr component, shared_qobject_ptr<Tas
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static LoadResult loadIndex(shared_qobject_ptr<Task>& loadTask, Net::Mode netmode)
|
static LoadResult loadIndex(Task::Ptr& loadTask, Net::Mode netmode)
|
||||||
{
|
{
|
||||||
// FIXME: DECIDE. do we want to run the update task anyway?
|
// FIXME: DECIDE. do we want to run the update task anyway?
|
||||||
if(APPLICATION->metadataIndex()->isLoaded())
|
if(APPLICATION->metadataIndex()->isLoaded())
|
||||||
@ -180,7 +180,7 @@ void ComponentUpdateTask::loadComponents()
|
|||||||
// load the main index (it is needed to determine if components can revert)
|
// load the main index (it is needed to determine if components can revert)
|
||||||
{
|
{
|
||||||
// FIXME: tear out as a method? or lambda?
|
// FIXME: tear out as a method? or lambda?
|
||||||
shared_qobject_ptr<Task> indexLoadTask;
|
Task::Ptr indexLoadTask;
|
||||||
auto singleResult = loadIndex(indexLoadTask, d->netmode);
|
auto singleResult = loadIndex(indexLoadTask, d->netmode);
|
||||||
result = composeLoadResult(result, singleResult);
|
result = composeLoadResult(result, singleResult);
|
||||||
if(indexLoadTask)
|
if(indexLoadTask)
|
||||||
@ -203,7 +203,7 @@ void ComponentUpdateTask::loadComponents()
|
|||||||
// load all the components OR their lists...
|
// load all the components OR their lists...
|
||||||
for (auto component: d->m_list->d->components)
|
for (auto component: d->m_list->d->components)
|
||||||
{
|
{
|
||||||
shared_qobject_ptr<Task> loadTask;
|
Task::Ptr loadTask;
|
||||||
LoadResult singleResult;
|
LoadResult singleResult;
|
||||||
RemoteLoadStatus::Type loadType;
|
RemoteLoadStatus::Type loadType;
|
||||||
// FIXME: to do this right, we need to load the lists and decide on which versions to use during dependency resolution. For now, ignore all that...
|
// FIXME: to do this right, we need to load the lists and decide on which versions to use during dependency resolution. For now, ignore all that...
|
||||||
|
@ -798,17 +798,17 @@ QString MinecraftInstance::getStatusbarDescription()
|
|||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_qobject_ptr<Task> MinecraftInstance::createUpdateTask(Net::Mode mode)
|
Task::Ptr MinecraftInstance::createUpdateTask(Net::Mode mode)
|
||||||
{
|
{
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case Net::Mode::Offline:
|
case Net::Mode::Offline:
|
||||||
{
|
{
|
||||||
return shared_qobject_ptr<Task>(new MinecraftLoadAndCheck(this));
|
return Task::Ptr(new MinecraftLoadAndCheck(this));
|
||||||
}
|
}
|
||||||
case Net::Mode::Online:
|
case Net::Mode::Online:
|
||||||
{
|
{
|
||||||
return shared_qobject_ptr<Task>(new MinecraftUpdate(this));
|
return Task::Ptr(new MinecraftUpdate(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -77,7 +77,7 @@ public:
|
|||||||
std::shared_ptr<GameOptions> gameOptionsModel() const;
|
std::shared_ptr<GameOptions> gameOptionsModel() const;
|
||||||
|
|
||||||
////// Launch stuff //////
|
////// Launch stuff //////
|
||||||
shared_qobject_ptr<Task> createUpdateTask(Net::Mode mode) override;
|
Task::Ptr createUpdateTask(Net::Mode mode) override;
|
||||||
shared_qobject_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account, MinecraftServerTargetPtr serverToJoin) override;
|
shared_qobject_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account, MinecraftServerTargetPtr serverToJoin) override;
|
||||||
QStringList extraArguments() const override;
|
QStringList extraArguments() const override;
|
||||||
QStringList verboseDescription(AuthSessionPtr session, MinecraftServerTargetPtr serverToJoin) override;
|
QStringList verboseDescription(AuthSessionPtr session, MinecraftServerTargetPtr serverToJoin) override;
|
||||||
|
@ -41,7 +41,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
MinecraftInstance *m_inst = nullptr;
|
MinecraftInstance *m_inst = nullptr;
|
||||||
shared_qobject_ptr<Task> m_task;
|
Task::Ptr m_task;
|
||||||
QString m_preFailure;
|
QString m_preFailure;
|
||||||
QString m_fail_reason;
|
QString m_fail_reason;
|
||||||
};
|
};
|
||||||
|
@ -340,7 +340,7 @@ void PackProfile::reload(Net::Mode netmode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_qobject_ptr<Task> PackProfile::getCurrentTask()
|
Task::Ptr PackProfile::getCurrentTask()
|
||||||
{
|
{
|
||||||
return d->m_updateTask;
|
return d->m_updateTask;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ public:
|
|||||||
void resolve(Net::Mode netmode);
|
void resolve(Net::Mode netmode);
|
||||||
|
|
||||||
/// get current running task...
|
/// get current running task...
|
||||||
shared_qobject_ptr<Task> getCurrentTask();
|
Task::Ptr getCurrentTask();
|
||||||
|
|
||||||
std::shared_ptr<LaunchProfile> getProfile() const;
|
std::shared_ptr<LaunchProfile> getProfile() const;
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ struct PackProfileData
|
|||||||
ComponentIndex componentIndex;
|
ComponentIndex componentIndex;
|
||||||
bool dirty = false;
|
bool dirty = false;
|
||||||
QTimer m_saveTimer;
|
QTimer m_saveTimer;
|
||||||
shared_qobject_ptr<Task> m_updateTask;
|
Task::Ptr m_updateTask;
|
||||||
bool loaded = false;
|
bool loaded = false;
|
||||||
bool interactionDisabled = true;
|
bool interactionDisabled = true;
|
||||||
};
|
};
|
||||||
|
@ -90,7 +90,7 @@ bool LegacyInstance::shouldUseCustomBaseJar() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
shared_qobject_ptr<Task> LegacyInstance::createUpdateTask(Net::Mode)
|
Task::Ptr LegacyInstance::createUpdateTask(Net::Mode)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
virtual bool shouldUpdate() const;
|
virtual bool shouldUpdate() const;
|
||||||
virtual shared_qobject_ptr<Task> createUpdateTask(Net::Mode mode) override;
|
virtual Task::Ptr createUpdateTask(Net::Mode mode) override;
|
||||||
|
|
||||||
virtual QString typeName() const override;
|
virtual QString typeName() const override;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ SequentialTask::SequentialTask(QObject *parent) : Task(parent), m_currentIndex(-
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SequentialTask::addTask(shared_qobject_ptr<Task> task)
|
void SequentialTask::addTask(Task::Ptr task)
|
||||||
{
|
{
|
||||||
m_queue.append(task);
|
m_queue.append(task);
|
||||||
}
|
}
|
||||||
@ -19,7 +19,7 @@ void SequentialTask::startNext()
|
|||||||
{
|
{
|
||||||
if (m_currentIndex != -1)
|
if (m_currentIndex != -1)
|
||||||
{
|
{
|
||||||
shared_qobject_ptr<Task> previous = m_queue[m_currentIndex];
|
Task::Ptr previous = m_queue[m_currentIndex];
|
||||||
disconnect(previous.get(), 0, this, 0);
|
disconnect(previous.get(), 0, this, 0);
|
||||||
}
|
}
|
||||||
m_currentIndex++;
|
m_currentIndex++;
|
||||||
@ -28,7 +28,7 @@ void SequentialTask::startNext()
|
|||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
shared_qobject_ptr<Task> next = m_queue[m_currentIndex];
|
Task::Ptr next = m_queue[m_currentIndex];
|
||||||
connect(next.get(), SIGNAL(failed(QString)), this, SLOT(subTaskFailed(QString)));
|
connect(next.get(), SIGNAL(failed(QString)), this, SLOT(subTaskFailed(QString)));
|
||||||
connect(next.get(), SIGNAL(status(QString)), this, SLOT(subTaskStatus(QString)));
|
connect(next.get(), SIGNAL(status(QString)), this, SLOT(subTaskStatus(QString)));
|
||||||
connect(next.get(), SIGNAL(progress(qint64, qint64)), this, SLOT(subTaskProgress(qint64, qint64)));
|
connect(next.get(), SIGNAL(progress(qint64, qint64)), this, SLOT(subTaskProgress(qint64, qint64)));
|
||||||
|
@ -12,7 +12,7 @@ public:
|
|||||||
explicit SequentialTask(QObject *parent = 0);
|
explicit SequentialTask(QObject *parent = 0);
|
||||||
virtual ~SequentialTask() {};
|
virtual ~SequentialTask() {};
|
||||||
|
|
||||||
void addTask(shared_qobject_ptr<Task> task);
|
void addTask(Task::Ptr task);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void executeTask();
|
void executeTask();
|
||||||
@ -25,6 +25,6 @@ slots:
|
|||||||
void subTaskProgress(qint64 current, qint64 total);
|
void subTaskProgress(qint64 current, qint64 total);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QQueue<shared_qobject_ptr<Task> > m_queue;
|
QQueue<Task::Ptr > m_queue;
|
||||||
int m_currentIndex;
|
int m_currentIndex;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user