huge nit: added const refs, everywhere
Signed-off-by: timoreo <contact@timoreo.fr>
This commit is contained in:
parent
4f6d964217
commit
9ff364b0d3
@ -535,7 +535,7 @@ InstancePtr InstanceList::getInstanceById(QString instId) const
|
|||||||
return InstancePtr();
|
return InstancePtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
InstancePtr InstanceList::getInstanceByManagedName(QString managed_name) const
|
InstancePtr InstanceList::getInstanceByManagedName(const QString& managed_name) const
|
||||||
{
|
{
|
||||||
if (managed_name.isEmpty())
|
if (managed_name.isEmpty())
|
||||||
return {};
|
return {};
|
||||||
@ -880,7 +880,7 @@ QString InstanceList::getStagedInstancePath()
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InstanceList::commitStagedInstance(QString path, InstanceName const& instanceName, 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;
|
||||||
|
@ -104,7 +104,7 @@ public:
|
|||||||
/* O(n) */
|
/* O(n) */
|
||||||
InstancePtr getInstanceById(QString id) const;
|
InstancePtr getInstanceById(QString id) const;
|
||||||
/* O(n) */
|
/* O(n) */
|
||||||
InstancePtr getInstanceByManagedName(QString managed_name) const;
|
InstancePtr getInstanceByManagedName(const QString& managed_name) const;
|
||||||
QModelIndex getInstanceIndexById(const QString &id) const;
|
QModelIndex getInstanceIndexById(const QString &id) const;
|
||||||
QStringList getGroups();
|
QStringList getGroups();
|
||||||
bool isGroupCollapsed(const QString &groupName);
|
bool isGroupCollapsed(const QString &groupName);
|
||||||
@ -133,7 +133,7 @@ public:
|
|||||||
* should_override is used when another similar instance already exists, and we want to override it
|
* should_override is used when another similar instance already exists, and we want to override it
|
||||||
* - for instance, when updating it.
|
* - for instance, when updating it.
|
||||||
*/
|
*/
|
||||||
bool commitStagedInstance(QString keyPath, const InstanceName& instanceName, QString groupName, bool should_override);
|
bool commitStagedInstance(const QString& keyPath, const InstanceName& instanceName, const QString& groupName, bool should_override);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy a previously created staging area given by @keyPath - used when creation fails.
|
* Destroy a previously created staging area given by @keyPath - used when creation fails.
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "ui/dialogs/CustomMessageBox.h"
|
#include "ui/dialogs/CustomMessageBox.h"
|
||||||
|
|
||||||
InstanceNameChange askForChangingInstanceName(QWidget* parent, QString old_name, QString new_name)
|
InstanceNameChange askForChangingInstanceName(QWidget* parent, const QString& old_name, const QString& new_name)
|
||||||
{
|
{
|
||||||
auto dialog =
|
auto dialog =
|
||||||
CustomMessageBox::selectable(parent, QObject::tr("Change instance name"),
|
CustomMessageBox::selectable(parent, QObject::tr("Change instance name"),
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
/* Helpers */
|
/* Helpers */
|
||||||
enum class InstanceNameChange { ShouldChange, ShouldKeep };
|
enum class InstanceNameChange { ShouldChange, ShouldKeep };
|
||||||
[[nodiscard]] InstanceNameChange askForChangingInstanceName(QWidget* parent, QString old_name, QString new_name);
|
[[nodiscard]] InstanceNameChange askForChangingInstanceName(QWidget* parent, const QString& old_name, const QString& new_name);
|
||||||
|
|
||||||
struct InstanceName {
|
struct InstanceName {
|
||||||
public:
|
public:
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
#include "VanillaInstanceCreationTask.h"
|
#include "VanillaInstanceCreationTask.h"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
#include "minecraft/MinecraftInstance.h"
|
#include "minecraft/MinecraftInstance.h"
|
||||||
#include "minecraft/PackProfile.h"
|
#include "minecraft/PackProfile.h"
|
||||||
#include "settings/INISettingsObject.h"
|
#include "settings/INISettingsObject.h"
|
||||||
|
|
||||||
VanillaCreationTask::VanillaCreationTask(BaseVersionPtr version, QString loader, BaseVersionPtr loader_version)
|
VanillaCreationTask::VanillaCreationTask(BaseVersionPtr version, QString loader, BaseVersionPtr loader_version)
|
||||||
: InstanceCreationTask(), m_version(version), m_using_loader(true), m_loader(loader), m_loader_version(loader_version)
|
: InstanceCreationTask(), m_version(std::move(version)), m_using_loader(true), m_loader(std::move(loader)), m_loader_version(std::move(loader_version))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool VanillaCreationTask::createInstance()
|
bool VanillaCreationTask::createInstance()
|
||||||
|
@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
#include "InstanceCreationTask.h"
|
#include "InstanceCreationTask.h"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
class VanillaCreationTask final : public InstanceCreationTask {
|
class VanillaCreationTask final : public InstanceCreationTask {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VanillaCreationTask(BaseVersionPtr version) : InstanceCreationTask(), m_version(version) {}
|
VanillaCreationTask(BaseVersionPtr version) : InstanceCreationTask(), m_version(std::move(version)) {}
|
||||||
VanillaCreationTask(BaseVersionPtr version, QString loader, BaseVersionPtr loader_version);
|
VanillaCreationTask(BaseVersionPtr version, QString loader, BaseVersionPtr loader_version);
|
||||||
|
|
||||||
bool createInstance() override;
|
bool createInstance() override;
|
||||||
|
@ -184,7 +184,7 @@ auto FlameAPI::getProjects(QStringList addonIds, QByteArray* response) const ->
|
|||||||
return netJob;
|
return netJob;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto FlameAPI::getFiles(QStringList fileIds, QByteArray* response) const -> NetJob*
|
auto FlameAPI::getFiles(const QStringList& fileIds, QByteArray* response) const -> NetJob*
|
||||||
{
|
{
|
||||||
auto* netJob = new NetJob(QString("Flame::GetFiles"), APPLICATION->network());
|
auto* netJob = new NetJob(QString("Flame::GetFiles"), APPLICATION->network());
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ class FlameAPI : public NetworkModAPI {
|
|||||||
auto getLatestVersion(VersionSearchArgs&& args) -> ModPlatform::IndexedVersion;
|
auto getLatestVersion(VersionSearchArgs&& args) -> ModPlatform::IndexedVersion;
|
||||||
|
|
||||||
auto getProjects(QStringList addonIds, QByteArray* response) const -> NetJob* override;
|
auto getProjects(QStringList addonIds, QByteArray* response) const -> NetJob* override;
|
||||||
auto getFiles(QStringList fileIds, QByteArray* response) const -> NetJob*;
|
auto getFiles(const QStringList& fileIds, QByteArray* response) const -> NetJob*;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline auto getSortFieldInt(QString sortString) const -> int
|
inline auto getSortFieldInt(QString sortString) const -> int
|
||||||
|
@ -126,7 +126,7 @@ bool FlameCreationTask::updateInstance()
|
|||||||
// TODO: Currently 'overrides' will always override the stuff on update. How do we preserve unchanged overrides?
|
// TODO: Currently 'overrides' will always override the stuff on update. How do we preserve unchanged overrides?
|
||||||
// FIXME: We may want to do something about disabled mods.
|
// FIXME: We may want to do something about disabled mods.
|
||||||
auto old_overrides = Override::readOverrides("overrides", old_index_folder);
|
auto old_overrides = Override::readOverrides("overrides", old_index_folder);
|
||||||
for (auto entry : old_overrides) {
|
for (const auto& entry : old_overrides) {
|
||||||
if (entry.isEmpty())
|
if (entry.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
qDebug() << "Scheduling" << entry << "for removal";
|
qDebug() << "Scheduling" << entry << "for removal";
|
||||||
@ -320,7 +320,7 @@ bool FlameCreationTask::createInstance()
|
|||||||
qDebug() << "Found jarmods:";
|
qDebug() << "Found jarmods:";
|
||||||
QDir jarmodsDir(jarmodsPath);
|
QDir jarmodsDir(jarmodsPath);
|
||||||
QStringList jarMods;
|
QStringList jarMods;
|
||||||
for (auto info : jarmodsDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files)) {
|
for (const auto& info : jarmodsDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files)) {
|
||||||
qDebug() << info.fileName();
|
qDebug() << info.fileName();
|
||||||
jarMods.push_back(info.absoluteFilePath());
|
jarMods.push_back(info.absoluteFilePath());
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ class FlameCreationTask final : public InstanceCreationTask {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FlameCreationTask(QString staging_path, SettingsObjectPtr global_settings, QWidget* parent)
|
FlameCreationTask(const QString& staging_path, SettingsObjectPtr global_settings, QWidget* parent)
|
||||||
: InstanceCreationTask(), m_parent(parent)
|
: InstanceCreationTask(), m_parent(parent)
|
||||||
{
|
{
|
||||||
setStagingPath(staging_path);
|
setStagingPath(staging_path);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
namespace Override {
|
namespace Override {
|
||||||
|
|
||||||
void createOverrides(QString name, QString parent_folder, QString override_path)
|
void createOverrides(const QString& name, const QString& parent_folder, const QString& override_path)
|
||||||
{
|
{
|
||||||
QString file_path(FS::PathCombine(parent_folder, name + ".txt"));
|
QString file_path(FS::PathCombine(parent_folder, name + ".txt"));
|
||||||
if (QFile::exists(file_path))
|
if (QFile::exists(file_path))
|
||||||
@ -33,7 +33,7 @@ void createOverrides(QString name, QString parent_folder, QString override_path)
|
|||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList readOverrides(QString name, QString parent_folder)
|
QStringList readOverrides(const QString& name, const QString& parent_folder)
|
||||||
{
|
{
|
||||||
QString file_path(FS::PathCombine(parent_folder, name + ".txt"));
|
QString file_path(FS::PathCombine(parent_folder, name + ".txt"));
|
||||||
|
|
||||||
|
@ -9,12 +9,12 @@ namespace Override {
|
|||||||
*
|
*
|
||||||
* If there's already an existing such file, it will be ovewritten.
|
* If there's already an existing such file, it will be ovewritten.
|
||||||
*/
|
*/
|
||||||
void createOverrides(QString name, QString parent_folder, QString override_path);
|
void createOverrides(const QString& name, const QString& parent_folder, const QString& override_path);
|
||||||
|
|
||||||
/** This reads an existing overrides archive, returning a list of overrides.
|
/** This reads an existing overrides archive, returning a list of overrides.
|
||||||
*
|
*
|
||||||
* If there's no such file in `parent_folder`, it will return an empty list.
|
* If there's no such file in `parent_folder`, it will return an empty list.
|
||||||
*/
|
*/
|
||||||
QStringList readOverrides(QString name, QString parent_folder);
|
QStringList readOverrides(const QString& name, const QString& parent_folder);
|
||||||
|
|
||||||
} // namespace Override
|
} // namespace Override
|
||||||
|
@ -121,7 +121,7 @@ bool ModrinthCreationTask::updateInstance()
|
|||||||
// TODO: Currently 'overrides' will always override the stuff on update. How do we preserve unchanged overrides?
|
// TODO: Currently 'overrides' will always override the stuff on update. How do we preserve unchanged overrides?
|
||||||
// FIXME: We may want to do something about disabled mods.
|
// FIXME: We may want to do something about disabled mods.
|
||||||
auto old_overrides = Override::readOverrides("overrides", old_index_folder);
|
auto old_overrides = Override::readOverrides("overrides", old_index_folder);
|
||||||
for (auto entry : old_overrides) {
|
for (const auto& entry : old_overrides) {
|
||||||
if (entry.isEmpty())
|
if (entry.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
qDebug() << "Scheduling" << entry << "for removal";
|
qDebug() << "Scheduling" << entry << "for removal";
|
||||||
@ -129,7 +129,7 @@ bool ModrinthCreationTask::updateInstance()
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto old_client_overrides = Override::readOverrides("client-overrides", old_index_folder);
|
auto old_client_overrides = Override::readOverrides("client-overrides", old_index_folder);
|
||||||
for (auto entry : old_overrides) {
|
for (const auto& entry : old_overrides) {
|
||||||
if (entry.isEmpty())
|
if (entry.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
qDebug() << "Scheduling" << entry << "for removal";
|
qDebug() << "Scheduling" << entry << "for removal";
|
||||||
@ -235,7 +235,7 @@ bool ModrinthCreationTask::createInstance()
|
|||||||
dl->addValidator(new Net::ChecksumValidator(file.hashAlgorithm, file.hash));
|
dl->addValidator(new Net::ChecksumValidator(file.hashAlgorithm, file.hash));
|
||||||
m_files_job->addNetAction(dl);
|
m_files_job->addNetAction(dl);
|
||||||
|
|
||||||
if (file.downloads.size() > 0) {
|
if (!file.downloads.empty()) {
|
||||||
// FIXME: This really needs to be put into a ConcurrentTask of
|
// FIXME: This really needs to be put into a ConcurrentTask of
|
||||||
// MultipleOptionsTask's , once those exist :)
|
// MultipleOptionsTask's , once those exist :)
|
||||||
connect(dl.get(), &NetAction::failed, [this, &file, path, dl] {
|
connect(dl.get(), &NetAction::failed, [this, &file, path, dl] {
|
||||||
@ -281,7 +281,7 @@ bool ModrinthCreationTask::createInstance()
|
|||||||
return ended_well;
|
return ended_well;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModrinthCreationTask::parseManifest(QString index_path, std::vector<Modrinth::File>& files, bool set_managed_info, bool show_optional_dialog)
|
bool ModrinthCreationTask::parseManifest(const QString& index_path, std::vector<Modrinth::File>& files, bool set_managed_info, bool show_optional_dialog)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
auto doc = Json::requireDocument(index_path);
|
auto doc = Json::requireDocument(index_path);
|
||||||
@ -300,7 +300,7 @@ bool ModrinthCreationTask::parseManifest(QString index_path, std::vector<Modrint
|
|||||||
|
|
||||||
auto jsonFiles = Json::requireIsArrayOf<QJsonObject>(obj, "files", "modrinth.index.json");
|
auto jsonFiles = Json::requireIsArrayOf<QJsonObject>(obj, "files", "modrinth.index.json");
|
||||||
bool had_optional = false;
|
bool had_optional = false;
|
||||||
for (auto modInfo : jsonFiles) {
|
for (const auto& modInfo : jsonFiles) {
|
||||||
Modrinth::File file;
|
Modrinth::File file;
|
||||||
file.path = Json::requireString(modInfo, "path");
|
file.path = Json::requireString(modInfo, "path");
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ class ModrinthCreationTask final : public InstanceCreationTask {
|
|||||||
bool createInstance() override;
|
bool createInstance() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool parseManifest(QString, std::vector<Modrinth::File>&, bool set_managed_info = true, bool show_optional_dialog = true);
|
bool parseManifest(const QString&, std::vector<Modrinth::File>&, bool set_managed_info = true, bool show_optional_dialog = true);
|
||||||
QString getManagedPackID() const;
|
QString getManagedPackID() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QValidator>
|
#include <QValidator>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include "ui/widgets/PageContainer.h"
|
#include "ui/widgets/PageContainer.h"
|
||||||
#include "ui/pages/modplatform/VanillaPage.h"
|
#include "ui/pages/modplatform/VanillaPage.h"
|
||||||
@ -177,7 +178,7 @@ NewInstanceDialog::~NewInstanceDialog()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewInstanceDialog::setSuggestedPack(QString name, InstanceTask* task)
|
void NewInstanceDialog::setSuggestedPack(const QString& name, InstanceTask* task)
|
||||||
{
|
{
|
||||||
creationTask.reset(task);
|
creationTask.reset(task);
|
||||||
|
|
||||||
@ -193,12 +194,12 @@ void NewInstanceDialog::setSuggestedPack(QString name, InstanceTask* task)
|
|||||||
m_buttons->button(QDialogButtonBox::Ok)->setEnabled(allowOK);
|
m_buttons->button(QDialogButtonBox::Ok)->setEnabled(allowOK);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewInstanceDialog::setSuggestedPack(QString name, QString version, InstanceTask* task)
|
void NewInstanceDialog::setSuggestedPack(const QString& name, QString version, InstanceTask* task)
|
||||||
{
|
{
|
||||||
creationTask.reset(task);
|
creationTask.reset(task);
|
||||||
|
|
||||||
ui->instNameTextBox->setPlaceholderText(name);
|
ui->instNameTextBox->setPlaceholderText(name);
|
||||||
importVersion = version;
|
importVersion = std::move(version);
|
||||||
|
|
||||||
if (!task) {
|
if (!task) {
|
||||||
ui->iconButton->setIcon(APPLICATION->icons()->getIcon("default"));
|
ui->iconButton->setIcon(APPLICATION->icons()->getIcon("default"));
|
||||||
|
@ -60,8 +60,8 @@ public:
|
|||||||
|
|
||||||
void updateDialogState();
|
void updateDialogState();
|
||||||
|
|
||||||
void setSuggestedPack(QString name = QString(), InstanceTask * task = nullptr);
|
void setSuggestedPack(const QString& name = QString(), InstanceTask * task = nullptr);
|
||||||
void setSuggestedPack(QString name, QString version, InstanceTask * task = nullptr);
|
void setSuggestedPack(const QString& name, QString version, InstanceTask * task = nullptr);
|
||||||
void setSuggestedIconFromFile(const QString &path, const QString &name);
|
void setSuggestedIconFromFile(const QString &path, const QString &name);
|
||||||
void setSuggestedIcon(const QString &key);
|
void setSuggestedIcon(const QString &key);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user