chore: reformat code
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
parent
65b960f904
commit
ff7e984198
@ -40,8 +40,8 @@
|
|||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QSet>
|
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
|
#include <QSet>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
@ -51,11 +51,11 @@
|
|||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
#include "InstanceList.h"
|
#include "InstanceList.h"
|
||||||
#include "InstanceTask.h"
|
#include "InstanceTask.h"
|
||||||
|
#include "MMCTime.h"
|
||||||
#include "NullInstance.h"
|
#include "NullInstance.h"
|
||||||
#include "WatchLock.h"
|
#include "WatchLock.h"
|
||||||
#include "minecraft/MinecraftInstance.h"
|
#include "minecraft/MinecraftInstance.h"
|
||||||
#include "settings/INISettingsObject.h"
|
#include "settings/INISettingsObject.h"
|
||||||
#include "MMCTime.h"
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
@ -366,11 +366,13 @@ bool InstanceList::trashInstance(const InstanceId& id)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InstanceList::trashedSomething() {
|
bool InstanceList::trashedSomething()
|
||||||
|
{
|
||||||
return !m_trashHistory.empty();
|
return !m_trashHistory.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceList::undoTrashInstance() {
|
void InstanceList::undoTrashInstance()
|
||||||
|
{
|
||||||
if (m_trashHistory.empty()) {
|
if (m_trashHistory.empty()) {
|
||||||
qWarning() << "Nothing to recover from trash.";
|
qWarning() << "Nothing to recover from trash.";
|
||||||
return;
|
return;
|
||||||
@ -638,13 +640,11 @@ InstancePtr InstanceList::loadInstance(const InstanceId& id)
|
|||||||
|
|
||||||
QString inst_type = instanceSettings->get("InstanceType").toString();
|
QString inst_type = instanceSettings->get("InstanceType").toString();
|
||||||
|
|
||||||
// NOTE: Some PolyMC versions didn't save the InstanceType properly. We will just bank on the probability that this is probably a OneSix instance
|
// NOTE: Some PolyMC versions didn't save the InstanceType properly. We will just bank on the probability that this is probably a OneSix
|
||||||
if (inst_type == "OneSix" || inst_type.isEmpty())
|
// instance
|
||||||
{
|
if (inst_type == "OneSix" || inst_type.isEmpty()) {
|
||||||
inst.reset(new MinecraftInstance(m_globalSettings, instanceSettings, instanceRoot));
|
inst.reset(new MinecraftInstance(m_globalSettings, instanceSettings, instanceRoot));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
inst.reset(new NullInstance(m_globalSettings, instanceSettings, instanceRoot));
|
inst.reset(new NullInstance(m_globalSettings, instanceSettings, instanceRoot));
|
||||||
}
|
}
|
||||||
qDebug() << "Loaded instance " << inst->name() << " from " << inst->instanceRoot();
|
qDebug() << "Loaded instance " << inst->name() << " from " << inst->instanceRoot();
|
||||||
@ -828,9 +828,14 @@ class InstanceStaging : public Task {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
const unsigned minBackoff = 1;
|
const unsigned minBackoff = 1;
|
||||||
const unsigned maxBackoff = 16;
|
const unsigned maxBackoff = 16;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InstanceStaging(InstanceList* parent, InstanceTask* child, QString stagingPath, InstanceName const& instanceName, QString groupName)
|
InstanceStaging(InstanceList* parent, InstanceTask* child, QString stagingPath, InstanceName const& instanceName, QString groupName)
|
||||||
: m_parent(parent), backoff(minBackoff, maxBackoff), m_stagingPath(std::move(stagingPath)), m_instance_name(std::move(instanceName)), m_groupName(std::move(groupName))
|
: m_parent(parent)
|
||||||
|
, backoff(minBackoff, maxBackoff)
|
||||||
|
, m_stagingPath(std::move(stagingPath))
|
||||||
|
, m_instance_name(std::move(instanceName))
|
||||||
|
, m_groupName(std::move(groupName))
|
||||||
{
|
{
|
||||||
m_child.reset(child);
|
m_child.reset(child);
|
||||||
connect(child, &Task::succeeded, this, &InstanceStaging::childSucceded);
|
connect(child, &Task::succeeded, this, &InstanceStaging::childSucceded);
|
||||||
@ -854,10 +859,7 @@ class InstanceStaging : public Task {
|
|||||||
|
|
||||||
return Task::abort();
|
return Task::abort();
|
||||||
}
|
}
|
||||||
bool canAbort() const override
|
bool canAbort() const override { return (m_child && m_child->canAbort()); }
|
||||||
{
|
|
||||||
return (m_child && m_child->canAbort());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void executeTask() override { m_child->start(); }
|
virtual void executeTask() override { m_child->start(); }
|
||||||
@ -867,8 +869,7 @@ class InstanceStaging : public Task {
|
|||||||
void childSucceded()
|
void childSucceded()
|
||||||
{
|
{
|
||||||
unsigned sleepTime = backoff();
|
unsigned sleepTime = backoff();
|
||||||
if (m_parent->commitStagedInstance(m_stagingPath, m_instance_name, m_groupName, m_child->shouldOverride()))
|
if (m_parent->commitStagedInstance(m_stagingPath, m_instance_name, m_groupName, m_child->shouldOverride())) {
|
||||||
{
|
|
||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -886,10 +887,7 @@ class InstanceStaging : public Task {
|
|||||||
emitFailed(reason);
|
emitFailed(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
void childAborted()
|
void childAborted() { emitAborted(); }
|
||||||
{
|
|
||||||
emitAborted();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
InstanceList* m_parent;
|
InstanceList* m_parent;
|
||||||
@ -931,7 +929,10 @@ QString InstanceList::getStagedInstancePath()
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InstanceList::commitStagedInstance(const QString& path, InstanceName const& instanceName, const QString& groupName, bool should_override)
|
bool InstanceList::commitStagedInstance(const QString& path,
|
||||||
|
InstanceName const& instanceName,
|
||||||
|
const QString& groupName,
|
||||||
|
bool should_override)
|
||||||
{
|
{
|
||||||
QDir dir;
|
QDir dir;
|
||||||
QString instID;
|
QString instID;
|
||||||
|
@ -15,12 +15,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QAbstractTableModel>
|
#include <QAbstractTableModel>
|
||||||
#include <QSet>
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QStack>
|
#include <QObject>
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
|
#include <QSet>
|
||||||
|
#include <QStack>
|
||||||
|
|
||||||
#include "BaseInstance.h"
|
#include "BaseInstance.h"
|
||||||
|
|
||||||
@ -32,21 +32,9 @@ using InstanceId = QString;
|
|||||||
using GroupId = QString;
|
using GroupId = QString;
|
||||||
using InstanceLocator = std::pair<InstancePtr, int>;
|
using InstanceLocator = std::pair<InstancePtr, int>;
|
||||||
|
|
||||||
enum class InstCreateError
|
enum class InstCreateError { NoCreateError = 0, NoSuchVersion, UnknownCreateError, InstExists, CantCreateDir };
|
||||||
{
|
|
||||||
NoCreateError = 0,
|
|
||||||
NoSuchVersion,
|
|
||||||
UnknownCreateError,
|
|
||||||
InstExists,
|
|
||||||
CantCreateDir
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class GroupsState
|
enum class GroupsState { NotLoaded, Steady, Dirty };
|
||||||
{
|
|
||||||
NotLoaded,
|
|
||||||
Steady,
|
|
||||||
Dirty
|
|
||||||
};
|
|
||||||
|
|
||||||
struct TrashHistoryItem {
|
struct TrashHistoryItem {
|
||||||
QString id;
|
QString id;
|
||||||
@ -55,8 +43,7 @@ struct TrashHistoryItem {
|
|||||||
QString groupName;
|
QString groupName;
|
||||||
};
|
};
|
||||||
|
|
||||||
class InstanceList : public QAbstractTableModel
|
class InstanceList : public QAbstractTableModel {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -73,8 +60,7 @@ public:
|
|||||||
|
|
||||||
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
|
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||||
|
|
||||||
enum Column
|
enum Column {
|
||||||
{
|
|
||||||
IconColumn = 0,
|
IconColumn = 0,
|
||||||
NameColumn,
|
NameColumn,
|
||||||
GameVersionColumn,
|
GameVersionColumn,
|
||||||
@ -84,32 +70,17 @@ public:
|
|||||||
ColumnCount
|
ColumnCount
|
||||||
};
|
};
|
||||||
|
|
||||||
enum AdditionalRoles
|
enum AdditionalRoles { SortRole = Qt::UserRole + 1, GroupRole, InstanceIDRole };
|
||||||
{
|
|
||||||
SortRole = Qt::UserRole + 1,
|
|
||||||
GroupRole,
|
|
||||||
InstanceIDRole
|
|
||||||
};
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Error codes returned by functions in the InstanceList class.
|
* \brief Error codes returned by functions in the InstanceList class.
|
||||||
* NoError Indicates that no error occurred.
|
* NoError Indicates that no error occurred.
|
||||||
* UnknownError indicates that an unspecified error occurred.
|
* UnknownError indicates that an unspecified error occurred.
|
||||||
*/
|
*/
|
||||||
enum InstListError
|
enum InstListError { NoError = 0, UnknownError };
|
||||||
{
|
|
||||||
NoError = 0,
|
|
||||||
UnknownError
|
|
||||||
};
|
|
||||||
|
|
||||||
InstancePtr at(int i) const
|
InstancePtr at(int i) const { return m_instances.at(i); }
|
||||||
{
|
|
||||||
return m_instances.at(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
int count() const
|
int count() const { return m_instances.count(); }
|
||||||
{
|
|
||||||
return m_instances.count();
|
|
||||||
}
|
|
||||||
|
|
||||||
InstListError loadList();
|
InstListError loadList();
|
||||||
void saveNow();
|
void saveNow();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user