From bbb3b3e6f6e3c0f95873f22e6d0a4aaf350f49d9 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Sun, 15 Jul 2018 14:51:05 +0200 Subject: NOISSUE tabs -> spaces --- api/logic/BaseInstaller.cpp | 36 +- api/logic/BaseInstaller.h | 18 +- api/logic/BaseInstance.cpp | 240 +-- api/logic/BaseInstance.h | 398 ++-- api/logic/BaseInstanceProvider.h | 64 +- api/logic/BaseVersion.h | 54 +- api/logic/BaseVersionList.cpp | 86 +- api/logic/BaseVersionList.h | 134 +- api/logic/CMakeLists.txt | 748 ++++---- api/logic/Commandline.cpp | 730 ++++---- api/logic/Commandline.h | 324 ++-- api/logic/DefaultVariable.h | 54 +- api/logic/Env.cpp | 208 +-- api/logic/Env.h | 38 +- api/logic/Exception.h | 36 +- api/logic/FileSystem.cpp | 634 +++---- api/logic/FileSystem.h | 50 +- api/logic/FileSystem_test.cpp | 274 +-- api/logic/Filter.cpp | 16 +- api/logic/Filter.h | 30 +- api/logic/FolderInstanceProvider.cpp | 726 ++++---- api/logic/FolderInstanceProvider.h | 88 +- api/logic/GZip.cpp | 208 +-- api/logic/GZip.h | 4 +- api/logic/GZip_test.cpp | 74 +- api/logic/InstanceCopyTask.cpp | 64 +- api/logic/InstanceCopyTask.h | 20 +- api/logic/InstanceCreationTask.cpp | 34 +- api/logic/InstanceCreationTask.h | 10 +- api/logic/InstanceImportTask.cpp | 676 +++---- api/logic/InstanceImportTask.h | 52 +- api/logic/InstanceList.cpp | 460 ++--- api/logic/InstanceList.h | 118 +- api/logic/InstanceTask.h | 82 +- api/logic/Json.cpp | 268 +-- api/logic/Json.h | 160 +- api/logic/LoggedProcess.cpp | 214 +-- api/logic/LoggedProcess.h | 70 +- api/logic/MMCStrings.cpp | 126 +- api/logic/MMCStrings.h | 2 +- api/logic/MMCZip.cpp | 398 ++-- api/logic/MMCZip.h | 68 +- api/logic/MessageLevel.cpp | 54 +- api/logic/MessageLevel.h | 20 +- api/logic/NullInstance.h | 140 +- api/logic/ProblemProvider.h | 52 +- api/logic/QObjectPtr.h | 104 +- api/logic/RWStorage.h | 108 +- api/logic/RecursiveFileSystemWatcher.cpp | 142 +- api/logic/RecursiveFileSystemWatcher.h | 80 +- api/logic/SeparatorPrefixTree.h | 544 +++--- api/logic/Usable.h | 58 +- api/logic/Version.cpp | 94 +- api/logic/Version.h | 176 +- api/logic/Version_test.cpp | 96 +- api/logic/icons/IIconList.h | 24 +- api/logic/java/JavaChecker.cpp | 250 +-- api/logic/java/JavaChecker.h | 66 +- api/logic/java/JavaCheckerJob.cpp | 32 +- api/logic/java/JavaCheckerJob.h | 52 +- api/logic/java/JavaInstall.cpp | 28 +- api/logic/java/JavaInstall.h | 48 +- api/logic/java/JavaInstallList.cpp | 222 +-- api/logic/java/JavaInstallList.h | 58 +- api/logic/java/JavaUtils.cpp | 514 +++--- api/logic/java/JavaUtils.h | 12 +- api/logic/java/JavaVersion.cpp | 164 +- api/logic/java/JavaVersion.h | 68 +- api/logic/java/JavaVersion_test.cpp | 194 +- api/logic/java/launch/CheckJava.cpp | 194 +- api/logic/java/launch/CheckJava.h | 28 +- api/logic/launch/LaunchStep.cpp | 12 +- api/logic/launch/LaunchStep.h | 30 +- api/logic/launch/LaunchTask.cpp | 324 ++-- api/logic/launch/LaunchTask.h | 134 +- api/logic/launch/LogModel.cpp | 218 +-- api/logic/launch/LogModel.h | 70 +- api/logic/launch/steps/PostLaunchCommand.cpp | 94 +- api/logic/launch/steps/PostLaunchCommand.h | 26 +- api/logic/launch/steps/PreLaunchCommand.cpp | 96 +- api/logic/launch/steps/PreLaunchCommand.h | 26 +- api/logic/launch/steps/TextPrint.cpp | 18 +- api/logic/launch/steps/TextPrint.h | 18 +- api/logic/launch/steps/Update.cpp | 84 +- api/logic/launch/steps/Update.h | 22 +- api/logic/meta/BaseEntity.cpp | 200 +-- api/logic/meta/BaseEntity.h | 52 +- api/logic/meta/Index.cpp | 162 +- api/logic/meta/Index.h | 48 +- api/logic/meta/Index_test.cpp | 52 +- api/logic/meta/JsonFormat.cpp | 258 +-- api/logic/meta/JsonFormat.h | 42 +- api/logic/meta/Version.cpp | 104 +- api/logic/meta/Version.h | 136 +- api/logic/meta/VersionList.cpp | 276 +-- api/logic/meta/VersionList.h | 116 +- api/logic/minecraft/AssetsUtils.cpp | 340 ++-- api/logic/minecraft/AssetsUtils.h | 20 +- api/logic/minecraft/Component.cpp | 604 +++---- api/logic/minecraft/Component.h | 138 +- api/logic/minecraft/ComponentList.cpp | 1896 ++++++++++---------- api/logic/minecraft/ComponentList.h | 138 +- api/logic/minecraft/ComponentList_p.h | 44 +- api/logic/minecraft/ComponentUpdateTask.cpp | 1120 ++++++------ api/logic/minecraft/ComponentUpdateTask.h | 30 +- api/logic/minecraft/ComponentUpdateTask_p.h | 32 +- api/logic/minecraft/GradleSpecifier.h | 266 +-- api/logic/minecraft/GradleSpecifier_test.cpp | 126 +- api/logic/minecraft/LaunchProfile.cpp | 324 ++-- api/logic/minecraft/LaunchProfile.h | 140 +- api/logic/minecraft/Library.cpp | 538 +++--- api/logic/minecraft/Library.h | 330 ++-- api/logic/minecraft/Library_test.cpp | 498 ++--- api/logic/minecraft/MinecraftInstance.cpp | 1410 +++++++-------- api/logic/minecraft/MinecraftInstance.h | 174 +- api/logic/minecraft/MinecraftLoadAndCheck.cpp | 50 +- api/logic/minecraft/MinecraftLoadAndCheck.h | 20 +- api/logic/minecraft/MinecraftUpdate.cpp | 234 +-- api/logic/minecraft/MinecraftUpdate.h | 32 +- api/logic/minecraft/Mod.cpp | 572 +++--- api/logic/minecraft/Mod.h | 228 +-- api/logic/minecraft/ModsModel.cpp | 548 +++--- api/logic/minecraft/ModsModel.h | 152 +- api/logic/minecraft/MojangDownloadInfo.h | 110 +- api/logic/minecraft/MojangVersionFormat.cpp | 578 +++--- api/logic/minecraft/MojangVersionFormat.h | 20 +- api/logic/minecraft/MojangVersionFormat_test.cpp | 76 +- api/logic/minecraft/OneSixVersionFormat.cpp | 650 +++---- api/logic/minecraft/OneSixVersionFormat.h | 28 +- api/logic/minecraft/OpSys.cpp | 36 +- api/logic/minecraft/OpSys.h | 8 +- api/logic/minecraft/ParseUtils.cpp | 36 +- api/logic/minecraft/ParseUtils_test.cpp | 56 +- api/logic/minecraft/ProfileUtils.cpp | 264 +-- api/logic/minecraft/Rule.cpp | 106 +- api/logic/minecraft/Rule.h | 94 +- api/logic/minecraft/SimpleModList.cpp | 552 +++--- api/logic/minecraft/SimpleModList.h | 152 +- api/logic/minecraft/SimpleModList_test.cpp | 70 +- api/logic/minecraft/SkinUpload.cpp | 80 +- api/logic/minecraft/SkinUpload.h | 32 +- api/logic/minecraft/VersionFile.cpp | 68 +- api/logic/minecraft/VersionFile.h | 118 +- api/logic/minecraft/VersionFilterData.cpp | 104 +- api/logic/minecraft/VersionFilterData.h | 24 +- api/logic/minecraft/World.cpp | 560 +++--- api/logic/minecraft/World.h | 102 +- api/logic/minecraft/WorldList.cpp | 510 +++--- api/logic/minecraft/WorldList.h | 174 +- api/logic/minecraft/auth/AuthSession.cpp | 32 +- api/logic/minecraft/auth/AuthSession.h | 70 +- api/logic/minecraft/auth/MojangAccount.cpp | 442 ++--- api/logic/minecraft/auth/MojangAccount.h | 170 +- api/logic/minecraft/auth/MojangAccountList.cpp | 682 +++---- api/logic/minecraft/auth/MojangAccountList.h | 304 ++-- api/logic/minecraft/auth/YggdrasilTask.cpp | 356 ++-- api/logic/minecraft/auth/YggdrasilTask.h | 212 +-- .../minecraft/auth/flows/AuthenticateTask.cpp | 312 ++-- api/logic/minecraft/auth/flows/AuthenticateTask.h | 14 +- api/logic/minecraft/auth/flows/RefreshTask.cpp | 188 +- api/logic/minecraft/auth/flows/RefreshTask.h | 12 +- api/logic/minecraft/auth/flows/ValidateTask.cpp | 32 +- api/logic/minecraft/auth/flows/ValidateTask.h | 12 +- api/logic/minecraft/forge/ForgeXzDownload.cpp | 640 +++---- api/logic/minecraft/forge/ForgeXzDownload.h | 46 +- api/logic/minecraft/launch/ClaimAccount.cpp | 20 +- api/logic/minecraft/launch/ClaimAccount.h | 22 +- .../launch/CreateServerResourcePacksFolder.cpp | 14 +- .../launch/CreateServerResourcePacksFolder.h | 16 +- api/logic/minecraft/launch/DirectJavaLaunch.cpp | 196 +- api/logic/minecraft/launch/DirectJavaLaunch.h | 38 +- api/logic/minecraft/launch/ExtractNatives.cpp | 120 +- api/logic/minecraft/launch/ExtractNatives.h | 18 +- api/logic/minecraft/launch/LauncherPartLaunch.cpp | 292 +-- api/logic/minecraft/launch/LauncherPartLaunch.h | 42 +- api/logic/minecraft/launch/ModMinecraftJar.cpp | 90 +- api/logic/minecraft/launch/ModMinecraftJar.h | 20 +- api/logic/minecraft/launch/PrintInstanceInfo.h | 18 +- api/logic/minecraft/legacy/LegacyInstance.cpp | 226 +-- api/logic/minecraft/legacy/LegacyInstance.h | 216 +-- api/logic/minecraft/legacy/LegacyModList.cpp | 262 +-- api/logic/minecraft/legacy/LegacyModList.h | 28 +- api/logic/minecraft/legacy/LegacyUpgradeTask.cpp | 200 +-- api/logic/minecraft/legacy/LegacyUpgradeTask.h | 18 +- api/logic/minecraft/testdata/lib-native-arch.json | 88 +- api/logic/minecraft/testdata/lib-native.json | 100 +- api/logic/minecraft/testdata/lib-simple.json | 18 +- api/logic/minecraft/update/AssetUpdateTask.cpp | 124 +- api/logic/minecraft/update/AssetUpdateTask.h | 22 +- api/logic/minecraft/update/FMLLibrariesTask.cpp | 190 +- api/logic/minecraft/update/FMLLibrariesTask.h | 22 +- api/logic/minecraft/update/FoldersTask.cpp | 20 +- api/logic/minecraft/update/FoldersTask.h | 10 +- api/logic/minecraft/update/LibrariesTask.cpp | 124 +- api/logic/minecraft/update/LibrariesTask.h | 18 +- api/logic/modplatform/flame/FileResolvingTask.cpp | 202 +-- api/logic/modplatform/flame/FileResolvingTask.h | 24 +- api/logic/modplatform/flame/PackManifest.cpp | 88 +- api/logic/modplatform/flame/PackManifest.h | 64 +- api/logic/modplatform/ftb/FtbPackFetchTask.cpp | 168 +- api/logic/modplatform/ftb/FtbPackFetchTask.h | 28 +- api/logic/modplatform/ftb/FtbPackInstallTask.cpp | 280 +-- api/logic/modplatform/ftb/FtbPackInstallTask.h | 46 +- api/logic/modplatform/ftb/PackHelpers.h | 40 +- api/logic/net/ByteArraySink.h | 88 +- api/logic/net/ChecksumValidator.h | 76 +- api/logic/net/Download.cpp | 406 ++--- api/logic/net/Download.h | 60 +- api/logic/net/FileSink.cpp | 138 +- api/logic/net/FileSink.h | 24 +- api/logic/net/HttpMetaCache.cpp | 366 ++-- api/logic/net/HttpMetaCache.h | 152 +- api/logic/net/MetaCacheSink.cpp | 74 +- api/logic/net/MetaCacheSink.h | 14 +- api/logic/net/Mode.h | 4 +- api/logic/net/NetAction.h | 132 +- api/logic/net/NetJob.cpp | 312 ++-- api/logic/net/NetJob.h | 96 +- api/logic/net/PasteUpload.cpp | 128 +- api/logic/net/PasteUpload.h | 62 +- api/logic/net/Sink.h | 102 +- api/logic/net/URLConstants.cpp | 4 +- api/logic/net/Validator.h | 12 +- api/logic/news/NewsChecker.cpp | 144 +- api/logic/news/NewsChecker.h | 116 +- api/logic/news/NewsEntry.cpp | 72 +- api/logic/news/NewsEntry.h | 52 +- api/logic/notifications/NotificationChecker.cpp | 158 +- api/logic/notifications/NotificationChecker.h | 74 +- api/logic/pathmatcher/FSTreeMatcher.h | 18 +- api/logic/pathmatcher/IPathMatcher.h | 6 +- api/logic/pathmatcher/MultiMatcher.h | 42 +- api/logic/pathmatcher/RegexpMatcher.h | 66 +- api/logic/screenshots/ImgurAlbumCreation.cpp | 112 +- api/logic/screenshots/ImgurAlbumCreation.h | 46 +- api/logic/screenshots/ImgurUpload.cpp | 160 +- api/logic/screenshots/ImgurUpload.h | 28 +- api/logic/screenshots/Screenshot.h | 16 +- api/logic/settings/INIFile.cpp | 180 +- api/logic/settings/INIFile.h | 16 +- api/logic/settings/INIFile_test.cpp | 96 +- api/logic/settings/INISettingsObject.cpp | 108 +- api/logic/settings/INISettingsObject.h | 48 +- api/logic/settings/OverrideSetting.cpp | 28 +- api/logic/settings/OverrideSetting.h | 18 +- api/logic/settings/PassthroughSetting.cpp | 58 +- api/logic/settings/PassthroughSetting.h | 18 +- api/logic/settings/Setting.cpp | 32 +- api/logic/settings/Setting.h | 146 +- api/logic/settings/SettingsObject.cpp | 140 +- api/logic/settings/SettingsObject.h | 312 ++-- api/logic/status/StatusChecker.cpp | 166 +- api/logic/status/StatusChecker.h | 36 +- api/logic/tasks/SequentialTask.cpp | 56 +- api/logic/tasks/SequentialTask.h | 22 +- api/logic/tasks/Task.cpp | 144 +- api/logic/tasks/Task.h | 98 +- api/logic/tools/BaseExternalTool.cpp | 10 +- api/logic/tools/BaseExternalTool.h | 34 +- api/logic/tools/BaseProfiler.cpp | 24 +- api/logic/tools/BaseProfiler.h | 20 +- api/logic/tools/JProfiler.cpp | 114 +- api/logic/tools/JProfiler.h | 10 +- api/logic/tools/JVisualVM.cpp | 98 +- api/logic/tools/JVisualVM.h | 10 +- api/logic/tools/MCEditTool.cpp | 84 +- api/logic/tools/MCEditTool.h | 12 +- api/logic/translations/TranslationsModel.cpp | 458 ++--- api/logic/translations/TranslationsModel.h | 48 +- api/logic/updater/DownloadTask.cpp | 182 +- api/logic/updater/DownloadTask.h | 110 +- api/logic/updater/DownloadTask_test.cpp | 336 ++-- api/logic/updater/GoUpdate.cpp | 382 ++-- api/logic/updater/GoUpdate.h | 138 +- api/logic/updater/UpdateChecker.cpp | 398 ++-- api/logic/updater/UpdateChecker.h | 168 +- api/logic/updater/UpdateChecker_test.cpp | 242 +-- api/logic/updater/testdata/1.json | 82 +- api/logic/updater/testdata/2.json | 58 +- api/logic/updater/testdata/channels.json | 42 +- api/logic/updater/testdata/errorChannels.json | 42 +- api/logic/updater/testdata/garbageChannels.json | 40 +- api/logic/updater/testdata/index.json | 14 +- api/logic/updater/testdata/noChannels.json | 6 +- api/logic/updater/testdata/oneChannel.json | 18 +- 285 files changed, 22132 insertions(+), 22132 deletions(-) (limited to 'api/logic') diff --git a/api/logic/BaseInstaller.cpp b/api/logic/BaseInstaller.cpp index 51f66293..e25683a9 100644 --- a/api/logic/BaseInstaller.cpp +++ b/api/logic/BaseInstaller.cpp @@ -25,37 +25,37 @@ BaseInstaller::BaseInstaller() bool BaseInstaller::isApplied(MinecraftInstance *on) { - return QFile::exists(filename(on->instanceRoot())); + return QFile::exists(filename(on->instanceRoot())); } bool BaseInstaller::add(MinecraftInstance *to) { - if (!patchesDir(to->instanceRoot()).exists()) - { - QDir(to->instanceRoot()).mkdir("patches"); - } - - if (isApplied(to)) - { - if (!remove(to)) - { - return false; - } - } - - return true; + if (!patchesDir(to->instanceRoot()).exists()) + { + QDir(to->instanceRoot()).mkdir("patches"); + } + + if (isApplied(to)) + { + if (!remove(to)) + { + return false; + } + } + + return true; } bool BaseInstaller::remove(MinecraftInstance *from) { - return QFile::remove(filename(from->instanceRoot())); + return QFile::remove(filename(from->instanceRoot())); } QString BaseInstaller::filename(const QString &root) const { - return patchesDir(root).absoluteFilePath(id() + ".json"); + return patchesDir(root).absoluteFilePath(id() + ".json"); } QDir BaseInstaller::patchesDir(const QString &root) const { - return QDir(root + "/patches/"); + return QDir(root + "/patches/"); } diff --git a/api/logic/BaseInstaller.h b/api/logic/BaseInstaller.h index afe11d55..121d35ef 100644 --- a/api/logic/BaseInstaller.h +++ b/api/logic/BaseInstaller.h @@ -30,17 +30,17 @@ typedef std::shared_ptr BaseVersionPtr; class MULTIMC_LOGIC_EXPORT BaseInstaller { public: - BaseInstaller(); - virtual ~BaseInstaller(){}; - bool isApplied(MinecraftInstance *on); + BaseInstaller(); + virtual ~BaseInstaller(){}; + bool isApplied(MinecraftInstance *on); - virtual bool add(MinecraftInstance *to); - virtual bool remove(MinecraftInstance *from); + virtual bool add(MinecraftInstance *to); + virtual bool remove(MinecraftInstance *from); - virtual Task *createInstallTask(MinecraftInstance *instance, BaseVersionPtr version, QObject *parent) = 0; + virtual Task *createInstallTask(MinecraftInstance *instance, BaseVersionPtr version, QObject *parent) = 0; protected: - virtual QString id() const = 0; - QString filename(const QString &root) const; - QDir patchesDir(const QString &root) const; + virtual QString id() const = 0; + QString filename(const QString &root) const; + QDir patchesDir(const QString &root) const; }; diff --git a/api/logic/BaseInstance.cpp b/api/logic/BaseInstance.cpp index 7e652e0d..c81b70c6 100644 --- a/api/logic/BaseInstance.cpp +++ b/api/logic/BaseInstance.cpp @@ -27,281 +27,281 @@ #include "Commandline.h" BaseInstance::BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir) - : QObject() + : QObject() { - m_settings = settings; - m_rootDir = rootDir; + m_settings = settings; + m_rootDir = rootDir; - m_settings->registerSetting("name", "Unnamed Instance"); - m_settings->registerSetting("iconKey", "default"); - m_settings->registerSetting("notes", ""); - m_settings->registerSetting("lastLaunchTime", 0); - m_settings->registerSetting("totalTimePlayed", 0); + m_settings->registerSetting("name", "Unnamed Instance"); + m_settings->registerSetting("iconKey", "default"); + m_settings->registerSetting("notes", ""); + m_settings->registerSetting("lastLaunchTime", 0); + m_settings->registerSetting("totalTimePlayed", 0); - // Custom Commands - auto commandSetting = m_settings->registerSetting({"OverrideCommands","OverrideLaunchCmd"}, false); - m_settings->registerOverride(globalSettings->getSetting("PreLaunchCommand"), commandSetting); - m_settings->registerOverride(globalSettings->getSetting("WrapperCommand"), commandSetting); - m_settings->registerOverride(globalSettings->getSetting("PostExitCommand"), commandSetting); + // Custom Commands + auto commandSetting = m_settings->registerSetting({"OverrideCommands","OverrideLaunchCmd"}, false); + m_settings->registerOverride(globalSettings->getSetting("PreLaunchCommand"), commandSetting); + m_settings->registerOverride(globalSettings->getSetting("WrapperCommand"), commandSetting); + m_settings->registerOverride(globalSettings->getSetting("PostExitCommand"), commandSetting); - // Console - auto consoleSetting = m_settings->registerSetting("OverrideConsole", false); - m_settings->registerOverride(globalSettings->getSetting("ShowConsole"), consoleSetting); - m_settings->registerOverride(globalSettings->getSetting("AutoCloseConsole"), consoleSetting); - m_settings->registerOverride(globalSettings->getSetting("ShowConsoleOnError"), consoleSetting); - m_settings->registerOverride(globalSettings->getSetting("LogPrePostOutput"), consoleSetting); + // Console + auto consoleSetting = m_settings->registerSetting("OverrideConsole", false); + m_settings->registerOverride(globalSettings->getSetting("ShowConsole"), consoleSetting); + m_settings->registerOverride(globalSettings->getSetting("AutoCloseConsole"), consoleSetting); + m_settings->registerOverride(globalSettings->getSetting("ShowConsoleOnError"), consoleSetting); + m_settings->registerOverride(globalSettings->getSetting("LogPrePostOutput"), consoleSetting); - m_settings->registerPassthrough(globalSettings->getSetting("ConsoleMaxLines"), nullptr); - m_settings->registerPassthrough(globalSettings->getSetting("ConsoleOverflowStop"), nullptr); + m_settings->registerPassthrough(globalSettings->getSetting("ConsoleMaxLines"), nullptr); + m_settings->registerPassthrough(globalSettings->getSetting("ConsoleOverflowStop"), nullptr); } QString BaseInstance::getPreLaunchCommand() { - return settings()->get("PreLaunchCommand").toString(); + return settings()->get("PreLaunchCommand").toString(); } QString BaseInstance::getWrapperCommand() { - return settings()->get("WrapperCommand").toString(); + return settings()->get("WrapperCommand").toString(); } QString BaseInstance::getPostExitCommand() { - return settings()->get("PostExitCommand").toString(); + return settings()->get("PostExitCommand").toString(); } int BaseInstance::getConsoleMaxLines() const { - auto lineSetting = settings()->getSetting("ConsoleMaxLines"); - bool conversionOk = false; - int maxLines = lineSetting->get().toInt(&conversionOk); - if(!conversionOk) - { - maxLines = lineSetting->defValue().toInt(); - qWarning() << "ConsoleMaxLines has nonsensical value, defaulting to" << maxLines; - } - return maxLines; + auto lineSetting = settings()->getSetting("ConsoleMaxLines"); + bool conversionOk = false; + int maxLines = lineSetting->get().toInt(&conversionOk); + if(!conversionOk) + { + maxLines = lineSetting->defValue().toInt(); + qWarning() << "ConsoleMaxLines has nonsensical value, defaulting to" << maxLines; + } + return maxLines; } bool BaseInstance::shouldStopOnConsoleOverflow() const { - return settings()->get("ConsoleOverflowStop").toBool(); + return settings()->get("ConsoleOverflowStop").toBool(); } void BaseInstance::iconUpdated(QString key) { - if(iconKey() == key) - { - emit propertiesChanged(this); - } + if(iconKey() == key) + { + emit propertiesChanged(this); + } } void BaseInstance::invalidate() { - changeStatus(Status::Gone); - qDebug() << "Instance" << id() << "has been invalidated."; + changeStatus(Status::Gone); + qDebug() << "Instance" << id() << "has been invalidated."; } void BaseInstance::nuke() { - changeStatus(Status::Gone); - qDebug() << "Instance" << id() << "has been deleted by MultiMC."; - FS::deletePath(instanceRoot()); + changeStatus(Status::Gone); + qDebug() << "Instance" << id() << "has been deleted by MultiMC."; + FS::deletePath(instanceRoot()); } void BaseInstance::changeStatus(BaseInstance::Status newStatus) { - Status status = currentStatus(); - if(status != newStatus) - { - m_status = newStatus; - emit statusChanged(status, newStatus); - } + Status status = currentStatus(); + if(status != newStatus) + { + m_status = newStatus; + emit statusChanged(status, newStatus); + } } BaseInstance::Status BaseInstance::currentStatus() const { - return m_status; + return m_status; } QString BaseInstance::id() const { - return QFileInfo(instanceRoot()).fileName(); + return QFileInfo(instanceRoot()).fileName(); } bool BaseInstance::isRunning() const { - return m_isRunning; + return m_isRunning; } void BaseInstance::setRunning(bool running) { - if(running == m_isRunning) - return; + if(running == m_isRunning) + return; - m_isRunning = running; + m_isRunning = running; - if(running) - { - m_timeStarted = QDateTime::currentDateTime(); - } - else - { - qint64 current = settings()->get("totalTimePlayed").toLongLong(); - QDateTime timeEnded = QDateTime::currentDateTime(); - settings()->set("totalTimePlayed", current + m_timeStarted.secsTo(timeEnded)); - emit propertiesChanged(this); - } + if(running) + { + m_timeStarted = QDateTime::currentDateTime(); + } + else + { + qint64 current = settings()->get("totalTimePlayed").toLongLong(); + QDateTime timeEnded = QDateTime::currentDateTime(); + settings()->set("totalTimePlayed", current + m_timeStarted.secsTo(timeEnded)); + emit propertiesChanged(this); + } - emit runningStatusChanged(running); + emit runningStatusChanged(running); } int64_t BaseInstance::totalTimePlayed() const { - qint64 current = settings()->get("totalTimePlayed").toLongLong(); - if(m_isRunning) - { - QDateTime timeNow = QDateTime::currentDateTime(); - return current + m_timeStarted.secsTo(timeNow); - } - return current; + qint64 current = settings()->get("totalTimePlayed").toLongLong(); + if(m_isRunning) + { + QDateTime timeNow = QDateTime::currentDateTime(); + return current + m_timeStarted.secsTo(timeNow); + } + return current; } void BaseInstance::resetTimePlayed() { - settings()->reset("totalTimePlayed"); + settings()->reset("totalTimePlayed"); } QString BaseInstance::instanceType() const { - return m_settings->get("InstanceType").toString(); + return m_settings->get("InstanceType").toString(); } QString BaseInstance::instanceRoot() const { - return m_rootDir; + return m_rootDir; } InstancePtr BaseInstance::getSharedPtr() { - return shared_from_this(); + return shared_from_this(); } SettingsObjectPtr BaseInstance::settings() const { - return m_settings; + return m_settings; } bool BaseInstance::canLaunch() const { - return (!hasVersionBroken() && !isRunning()); + return (!hasVersionBroken() && !isRunning()); } bool BaseInstance::reloadSettings() { - return m_settings->reload(); + return m_settings->reload(); } qint64 BaseInstance::lastLaunch() const { - return m_settings->get("lastLaunchTime").value(); + return m_settings->get("lastLaunchTime").value(); } void BaseInstance::setLastLaunch(qint64 val) { - //FIXME: if no change, do not set. setting involves saving a file. - m_settings->set("lastLaunchTime", val); - emit propertiesChanged(this); + //FIXME: if no change, do not set. setting involves saving a file. + m_settings->set("lastLaunchTime", val); + emit propertiesChanged(this); } void BaseInstance::setGroupInitial(QString val) { - if(m_group == val) - { - return; - } - m_group = val; - emit propertiesChanged(this); + if(m_group == val) + { + return; + } + m_group = val; + emit propertiesChanged(this); } void BaseInstance::setGroupPost(QString val) { - if(m_group == val) - { - return; - } - setGroupInitial(val); - emit groupChanged(); + if(m_group == val) + { + return; + } + setGroupInitial(val); + emit groupChanged(); } QString BaseInstance::group() const { - return m_group; + return m_group; } void BaseInstance::setNotes(QString val) { - //FIXME: if no change, do not set. setting involves saving a file. - m_settings->set("notes", val); + //FIXME: if no change, do not set. setting involves saving a file. + m_settings->set("notes", val); } QString BaseInstance::notes() const { - return m_settings->get("notes").toString(); + return m_settings->get("notes").toString(); } void BaseInstance::setIconKey(QString val) { - //FIXME: if no change, do not set. setting involves saving a file. - m_settings->set("iconKey", val); - emit propertiesChanged(this); + //FIXME: if no change, do not set. setting involves saving a file. + m_settings->set("iconKey", val); + emit propertiesChanged(this); } QString BaseInstance::iconKey() const { - return m_settings->get("iconKey").toString(); + return m_settings->get("iconKey").toString(); } void BaseInstance::setName(QString val) { - //FIXME: if no change, do not set. setting involves saving a file. - m_settings->set("name", val); - emit propertiesChanged(this); + //FIXME: if no change, do not set. setting involves saving a file. + m_settings->set("name", val); + emit propertiesChanged(this); } QString BaseInstance::name() const { - return m_settings->get("name").toString(); + return m_settings->get("name").toString(); } QString BaseInstance::windowTitle() const { - return "MultiMC: " + name(); + return "MultiMC: " + name(); } // FIXME: why is this here? move it to MinecraftInstance!!! QStringList BaseInstance::extraArguments() const { - return Commandline::splitArgs(settings()->get("JvmArgs").toString()); + return Commandline::splitArgs(settings()->get("JvmArgs").toString()); } std::shared_ptr BaseInstance::getLaunchTask() { - return m_launchProcess; + return m_launchProcess; } void BaseInstance::setProvider(BaseInstanceProvider* provider) { - // only once. - assert(!m_provider); - if(m_provider) - { - qWarning() << "Provider set more than once for instance" << id(); - } - m_provider = provider; + // only once. + assert(!m_provider); + if(m_provider) + { + qWarning() << "Provider set more than once for instance" << id(); + } + m_provider = provider; } BaseInstanceProvider* BaseInstance::provider() const { - return m_provider; + return m_provider; } diff --git a/api/logic/BaseInstance.h b/api/logic/BaseInstance.h index 282bfb70..f3b15a20 100644 --- a/api/logic/BaseInstance.h +++ b/api/logic/BaseInstance.h @@ -53,229 +53,229 @@ typedef std::shared_ptr InstancePtr; */ class MULTIMC_LOGIC_EXPORT BaseInstance : public QObject, public std::enable_shared_from_this { - Q_OBJECT + Q_OBJECT protected: - /// no-touchy! - BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir); + /// no-touchy! + BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir); public: /* types */ - enum class Status - { - Present, - Gone // either nuked or invalidated - }; + enum class Status + { + Present, + Gone // either nuked or invalidated + }; public: - /// virtual destructor to make sure the destruction is COMPLETE - virtual ~BaseInstance() {}; + /// virtual destructor to make sure the destruction is COMPLETE + virtual ~BaseInstance() {}; - virtual void init() = 0; - virtual void saveNow() = 0; + virtual void init() = 0; + virtual void saveNow() = 0; - /// nuke thoroughly - deletes the instance contents, notifies the list/model which is - /// responsible of cleaning up the husk - void nuke(); + /// nuke thoroughly - deletes the instance contents, notifies the list/model which is + /// responsible of cleaning up the husk + void nuke(); - /*** - * the instance has been invalidated - it is no longer tracked by MultiMC for some reason, - * but it has not necessarily been deleted. - * - * Happens when the instance folder changes to some other location, or the instance is removed by external means. - */ - void invalidate(); + /*** + * the instance has been invalidated - it is no longer tracked by MultiMC for some reason, + * but it has not necessarily been deleted. + * + * Happens when the instance folder changes to some other location, or the instance is removed by external means. + */ + void invalidate(); - /// The instance's ID. The ID SHALL be determined by MMC internally. The ID IS guaranteed to - /// be unique. - virtual QString id() const; + /// The instance's ID. The ID SHALL be determined by MMC internally. The ID IS guaranteed to + /// be unique. + virtual QString id() const; - void setRunning(bool running); - bool isRunning() const; - int64_t totalTimePlayed() const; - void resetTimePlayed(); + void setRunning(bool running); + bool isRunning() const; + int64_t totalTimePlayed() const; + void resetTimePlayed(); - void setProvider(BaseInstanceProvider * provider); - BaseInstanceProvider * provider() const; - - /// get the type of this instance - QString instanceType() const; - - /// Path to the instance's root directory. - QString instanceRoot() const; - - QString name() const; - void setName(QString val); - - /// Value used for instance window titles - QString windowTitle() const; - - QString iconKey() const; - void setIconKey(QString val); - - QString notes() const; - void setNotes(QString val); - - QString group() const; - void setGroupInitial(QString val); - void setGroupPost(QString val); - - QString getPreLaunchCommand(); - QString getPostExitCommand(); - QString getWrapperCommand(); - - /// guess log level from a line of game log - virtual MessageLevel::Enum guessLevel(const QString &line, MessageLevel::Enum level) - { - return level; - }; - - virtual QStringList extraArguments() const; - - /// Traits. Normally inside the version, depends on instance implementation. - virtual QSet traits() const = 0; - - /** - * Gets the time that the instance was last launched. - * Stored in milliseconds since epoch. - */ - qint64 lastLaunch() const; - /// Sets the last launched time to 'val' milliseconds since epoch - void setLastLaunch(qint64 val = QDateTime::currentMSecsSinceEpoch()); - - InstancePtr getSharedPtr(); - - /*! - * \brief Gets this instance's settings object. - * This settings object stores instance-specific settings. - * \return A pointer to this instance's settings object. - */ - virtual SettingsObjectPtr settings() const; - - /// returns a valid update task - virtual shared_qobject_ptr createUpdateTask(Net::Mode mode) = 0; - - /// returns a valid launcher (task container) - virtual std::shared_ptr createLaunchTask(AuthSessionPtr account) = 0; - - /// returns the current launch task (if any) - std::shared_ptr getLaunchTask(); - - /*! - * Create envrironment variables for running the instance - */ - virtual QProcessEnvironment createEnvironment() = 0; - - /*! - * Returns a matcher that can maps relative paths within the instance to whether they are 'log files' - */ - virtual IPathMatcher::Ptr getLogFileMatcher() = 0; - - /*! - * Returns the root folder to use for looking up log files - */ - virtual QString getLogFileRoot() = 0; - - virtual QString getStatusbarDescription() = 0; - - /// FIXME: this really should be elsewhere... - virtual QString instanceConfigFolder() const = 0; - - /// get variables this instance exports - virtual QMap getVariables() const = 0; - - virtual QString typeName() const = 0; - - bool hasVersionBroken() const - { - return m_hasBrokenVersion; - } - void setVersionBroken(bool value) - { - if(m_hasBrokenVersion != value) - { - m_hasBrokenVersion = value; - emit propertiesChanged(this); - } - } - - bool hasUpdateAvailable() const - { - return m_hasUpdate; - } - void setUpdateAvailable(bool value) - { - if(m_hasUpdate != value) - { - m_hasUpdate = value; - emit propertiesChanged(this); - } - } - - bool hasCrashed() const - { - return m_crashed; - } - void setCrashed(bool value) - { - if(m_crashed != value) - { - m_crashed = value; - emit propertiesChanged(this); - } - } - - virtual bool canLaunch() const; - virtual bool canEdit() const = 0; - virtual bool canExport() const = 0; - - bool reloadSettings(); - - /** - * 'print' a verbose desription of the instance into a QStringList - */ - virtual QStringList verboseDescription(AuthSessionPtr session) = 0; - - Status currentStatus() const; - - int getConsoleMaxLines() const; - bool shouldStopOnConsoleOverflow() const; + void setProvider(BaseInstanceProvider * provider); + BaseInstanceProvider * provider() const; + + /// get the type of this instance + QString instanceType() const; + + /// Path to the instance's root directory. + QString instanceRoot() const; + + QString name() const; + void setName(QString val); + + /// Value used for instance window titles + QString windowTitle() const; + + QString iconKey() const; + void setIconKey(QString val); + + QString notes() const; + void setNotes(QString val); + + QString group() const; + void setGroupInitial(QString val); + void setGroupPost(QString val); + + QString getPreLaunchCommand(); + QString getPostExitCommand(); + QString getWrapperCommand(); + + /// guess log level from a line of game log + virtual MessageLevel::Enum guessLevel(const QString &line, MessageLevel::Enum level) + { + return level; + }; + + virtual QStringList extraArguments() const; + + /// Traits. Normally inside the version, depends on instance implementation. + virtual QSet traits() const = 0; + + /** + * Gets the time that the instance was last launched. + * Stored in milliseconds since epoch. + */ + qint64 lastLaunch() const; + /// Sets the last launched time to 'val' milliseconds since epoch + void setLastLaunch(qint64 val = QDateTime::currentMSecsSinceEpoch()); + + InstancePtr getSharedPtr(); + + /*! + * \brief Gets this instance's settings object. + * This settings object stores instance-specific settings. + * \return A pointer to this instance's settings object. + */ + virtual SettingsObjectPtr settings() const; + + /// returns a valid update task + virtual shared_qobject_ptr createUpdateTask(Net::Mode mode) = 0; + + /// returns a valid launcher (task container) + virtual std::shared_ptr createLaunchTask(AuthSessionPtr account) = 0; + + /// returns the current launch task (if any) + std::shared_ptr getLaunchTask(); + + /*! + * Create envrironment variables for running the instance + */ + virtual QProcessEnvironment createEnvironment() = 0; + + /*! + * Returns a matcher that can maps relative paths within the instance to whether they are 'log files' + */ + virtual IPathMatcher::Ptr getLogFileMatcher() = 0; + + /*! + * Returns the root folder to use for looking up log files + */ + virtual QString getLogFileRoot() = 0; + + virtual QString getStatusbarDescription() = 0; + + /// FIXME: this really should be elsewhere... + virtual QString instanceConfigFolder() const = 0; + + /// get variables this instance exports + virtual QMap getVariables() const = 0; + + virtual QString typeName() const = 0; + + bool hasVersionBroken() const + { + return m_hasBrokenVersion; + } + void setVersionBroken(bool value) + { + if(m_hasBrokenVersion != value) + { + m_hasBrokenVersion = value; + emit propertiesChanged(this); + } + } + + bool hasUpdateAvailable() const + { + return m_hasUpdate; + } + void setUpdateAvailable(bool value) + { + if(m_hasUpdate != value) + { + m_hasUpdate = value; + emit propertiesChanged(this); + } + } + + bool hasCrashed() const + { + return m_crashed; + } + void setCrashed(bool value) + { + if(m_crashed != value) + { + m_crashed = value; + emit propertiesChanged(this); + } + } + + virtual bool canLaunch() const; + virtual bool canEdit() const = 0; + virtual bool canExport() const = 0; + + bool reloadSettings(); + + /** + * 'print' a verbose desription of the instance into a QStringList + */ + virtual QStringList verboseDescription(AuthSessionPtr session) = 0; + + Status currentStatus() const; + + int getConsoleMaxLines() const; + bool shouldStopOnConsoleOverflow() const; protected: - void changeStatus(Status newStatus); + void changeStatus(Status newStatus); signals: - /*! - * \brief Signal emitted when properties relevant to the instance view change - */ - void propertiesChanged(BaseInstance *inst); - /*! - * \brief Signal emitted when groups are affected in any way - */ - void groupChanged(); + /*! + * \brief Signal emitted when properties relevant to the instance view change + */ + void propertiesChanged(BaseInstance *inst); + /*! + * \brief Signal emitted when groups are affected in any way + */ + void groupChanged(); - void launchTaskChanged(std::shared_ptr); + void launchTaskChanged(std::shared_ptr); - void runningStatusChanged(bool running); + void runningStatusChanged(bool running); - void statusChanged(Status from, Status to); + void statusChanged(Status from, Status to); protected slots: - void iconUpdated(QString key); + void iconUpdated(QString key); protected: /* data */ - QString m_rootDir; - QString m_group; - SettingsObjectPtr m_settings; - // InstanceFlags m_flags; - bool m_isRunning = false; - std::shared_ptr m_launchProcess; - QDateTime m_timeStarted; - BaseInstanceProvider * m_provider = nullptr; + QString m_rootDir; + QString m_group; + SettingsObjectPtr m_settings; + // InstanceFlags m_flags; + bool m_isRunning = false; + std::shared_ptr m_launchProcess; + QDateTime m_timeStarted; + BaseInstanceProvider * m_provider = nullptr; private: /* data */ - Status m_status = Status::Present; - bool m_crashed = false; - bool m_hasUpdate = false; - bool m_hasBrokenVersion = false; + Status m_status = Status::Present; + bool m_crashed = false; + bool m_hasUpdate = false; + bool m_hasBrokenVersion = false; }; Q_DECLARE_METATYPE(std::shared_ptr) diff --git a/api/logic/BaseInstanceProvider.h b/api/logic/BaseInstanceProvider.h index 34489c5d..1eee0e4f 100644 --- a/api/logic/BaseInstanceProvider.h +++ b/api/logic/BaseInstanceProvider.h @@ -12,46 +12,46 @@ using InstanceLocator = std::pair; enum class InstCreateError { - NoCreateError = 0, - NoSuchVersion, - UnknownCreateError, - InstExists, - CantCreateDir + NoCreateError = 0, + NoSuchVersion, + UnknownCreateError, + InstExists, + CantCreateDir }; class MULTIMC_LOGIC_EXPORT BaseInstanceProvider : public QObject { - Q_OBJECT + Q_OBJECT public: - BaseInstanceProvider(SettingsObjectPtr settings) : m_globalSettings(settings) - { - // nil - } + BaseInstanceProvider(SettingsObjectPtr settings) : m_globalSettings(settings) + { + // nil + } public: - virtual QList discoverInstances() = 0; - virtual InstancePtr loadInstance(const InstanceId &id) = 0; - virtual void loadGroupList() = 0; - virtual void saveGroupList() = 0; - - virtual QString getStagedInstancePath() - { - return QString(); - } - virtual bool commitStagedInstance(const QString & path, const QString& instanceName, const QString & groupName) - { - return false; - } - virtual bool destroyStagingPath(const QString & path) - { - return true; - } + virtual QList discoverInstances() = 0; + virtual InstancePtr loadInstance(const InstanceId &id) = 0; + virtual void loadGroupList() = 0; + virtual void saveGroupList() = 0; + + virtual QString getStagedInstancePath() + { + return QString(); + } + virtual bool commitStagedInstance(const QString & path, const QString& instanceName, const QString & groupName) + { + return false; + } + virtual bool destroyStagingPath(const QString & path) + { + return true; + } signals: - // Emit this when the list of provided instances changed - void instancesChanged(); - // Emit when the set of groups your provider supplies changes. - void groupsChanged(QSet groups); + // Emit this when the list of provided instances changed + void instancesChanged(); + // Emit when the set of groups your provider supplies changes. + void groupsChanged(QSet groups); protected: - SettingsObjectPtr m_globalSettings; + SettingsObjectPtr m_globalSettings; }; diff --git a/api/logic/BaseVersion.h b/api/logic/BaseVersion.h index e49d6277..4f06c3bc 100644 --- a/api/logic/BaseVersion.h +++ b/api/logic/BaseVersion.h @@ -25,33 +25,33 @@ class BaseVersion { public: - virtual ~BaseVersion() {} - /*! - * A string used to identify this version in config files. - * This should be unique within the version list or shenanigans will occur. - */ - virtual QString descriptor() = 0; - - /*! - * The name of this version as it is displayed to the user. - * For example: "1.5.1" - */ - virtual QString name() = 0; - - /*! - * This should return a string that describes - * the kind of version this is (Stable, Beta, Snapshot, whatever) - */ - virtual QString typeString() const = 0; - - virtual bool operator<(BaseVersion &a) - { - return name() < a.name(); - }; - virtual bool operator>(BaseVersion &a) - { - return name() > a.name(); - }; + virtual ~BaseVersion() {} + /*! + * A string used to identify this version in config files. + * This should be unique within the version list or shenanigans will occur. + */ + virtual QString descriptor() = 0; + + /*! + * The name of this version as it is displayed to the user. + * For example: "1.5.1" + */ + virtual QString name() = 0; + + /*! + * This should return a string that describes + * the kind of version this is (Stable, Beta, Snapshot, whatever) + */ + virtual QString typeString() const = 0; + + virtual bool operator<(BaseVersion &a) + { + return name() < a.name(); + }; + virtual bool operator>(BaseVersion &a) + { + return name() > a.name(); + }; }; typedef std::shared_ptr BaseVersionPtr; diff --git a/api/logic/BaseVersionList.cpp b/api/logic/BaseVersionList.cpp index 31a635d7..b1f73529 100644 --- a/api/logic/BaseVersionList.cpp +++ b/api/logic/BaseVersionList.cpp @@ -22,78 +22,78 @@ BaseVersionList::BaseVersionList(QObject *parent) : QAbstractListModel(parent) BaseVersionPtr BaseVersionList::findVersion(const QString &descriptor) { - for (int i = 0; i < count(); i++) - { - if (at(i)->descriptor() == descriptor) - return at(i); - } - return BaseVersionPtr(); + for (int i = 0; i < count(); i++) + { + if (at(i)->descriptor() == descriptor) + return at(i); + } + return BaseVersionPtr(); } BaseVersionPtr BaseVersionList::getRecommended() const { - if (count() <= 0) - return BaseVersionPtr(); - else - return at(0); + if (count() <= 0) + return BaseVersionPtr(); + else + return at(0); } QVariant BaseVersionList::data(const QModelIndex &index, int role) const { - if (!index.isValid()) - return QVariant(); + if (!index.isValid()) + return QVariant(); - if (index.row() > count()) - return QVariant(); + if (index.row() > count()) + return QVariant(); - BaseVersionPtr version = at(index.row()); + BaseVersionPtr version = at(index.row()); - switch (role) - { - case VersionPointerRole: - return qVariantFromValue(version); + switch (role) + { + case VersionPointerRole: + return qVariantFromValue(version); - case VersionRole: - return version->name(); + case VersionRole: + return version->name(); - case VersionIdRole: - return version->descriptor(); + case VersionIdRole: + return version->descriptor(); - case TypeRole: - return version->typeString(); + case TypeRole: + return version->typeString(); - default: - return QVariant(); - } + default: + return QVariant(); + } } BaseVersionList::RoleList BaseVersionList::providesRoles() const { - return {VersionPointerRole, VersionRole, VersionIdRole, TypeRole}; + return {VersionPointerRole, VersionRole, VersionIdRole, TypeRole}; } int BaseVersionList::rowCount(const QModelIndex &parent) const { - // Return count - return count(); + // Return count + return count(); } int BaseVersionList::columnCount(const QModelIndex &parent) const { - return 1; + return 1; } QHash BaseVersionList::roleNames() const { - QHash roles = QAbstractListModel::roleNames(); - roles.insert(VersionRole, "version"); - roles.insert(VersionIdRole, "versionId"); - roles.insert(ParentVersionRole, "parentGameVersion"); - roles.insert(RecommendedRole, "recommended"); - roles.insert(LatestRole, "latest"); - roles.insert(TypeRole, "type"); - roles.insert(BranchRole, "branch"); - roles.insert(PathRole, "path"); - roles.insert(ArchitectureRole, "architecture"); - return roles; + QHash roles = QAbstractListModel::roleNames(); + roles.insert(VersionRole, "version"); + roles.insert(VersionIdRole, "versionId"); + roles.insert(ParentVersionRole, "parentGameVersion"); + roles.insert(RecommendedRole, "recommended"); + roles.insert(LatestRole, "latest"); + roles.insert(TypeRole, "type"); + roles.insert(BranchRole, "branch"); + roles.insert(PathRole, "path"); + roles.insert(ArchitectureRole, "architecture"); + return roles; } diff --git a/api/logic/BaseVersionList.h b/api/logic/BaseVersionList.h index b609e039..a70a414c 100644 --- a/api/logic/BaseVersionList.h +++ b/api/logic/BaseVersionList.h @@ -38,85 +38,85 @@ */ class MULTIMC_LOGIC_EXPORT BaseVersionList : public QAbstractListModel { - Q_OBJECT + Q_OBJECT public: - enum ModelRoles - { - VersionPointerRole = Qt::UserRole, - VersionRole, - VersionIdRole, - ParentVersionRole, - RecommendedRole, - LatestRole, - TypeRole, - BranchRole, - PathRole, - ArchitectureRole, - SortRole - }; - typedef QList RoleList; + enum ModelRoles + { + VersionPointerRole = Qt::UserRole, + VersionRole, + VersionIdRole, + ParentVersionRole, + RecommendedRole, + LatestRole, + TypeRole, + BranchRole, + PathRole, + ArchitectureRole, + SortRole + }; + typedef QList RoleList; - explicit BaseVersionList(QObject *parent = 0); + explicit BaseVersionList(QObject *parent = 0); - /*! - * \brief Gets a task that will reload the version list. - * Simply execute the task to load the list. - * 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. - */ - virtual shared_qobject_ptr getLoadTask() = 0; + /*! + * \brief Gets a task that will reload the version list. + * Simply execute the task to load the list. + * 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. + */ + virtual shared_qobject_ptr getLoadTask() = 0; - //! Checks whether or not the list is loaded. If this returns false, the list should be - //loaded. - virtual bool isLoaded() = 0; + //! Checks whether or not the list is loaded. If this returns false, the list should be + //loaded. + virtual bool isLoaded() = 0; - //! Gets the version at the given index. - virtual const BaseVersionPtr at(int i) const = 0; + //! Gets the version at the given index. + virtual const BaseVersionPtr at(int i) const = 0; - //! Returns the number of versions in the list. - virtual int count() const = 0; + //! Returns the number of versions in the list. + virtual int count() const = 0; - //////// List Model Functions //////// - QVariant data(const QModelIndex &index, int role) const override; - int rowCount(const QModelIndex &parent) const override; - int columnCount(const QModelIndex &parent) const override; - QHash roleNames() const override; + //////// List Model Functions //////// + QVariant data(const QModelIndex &index, int role) const override; + int rowCount(const QModelIndex &parent) const override; + int columnCount(const QModelIndex &parent) const override; + QHash roleNames() const override; - //! which roles are provided by this version list? - virtual RoleList providesRoles() const; + //! which roles are provided by this version list? + virtual RoleList providesRoles() const; - /*! - * \brief Finds a version by its descriptor. - * \param descriptor The descriptor of the version to find. - * \return A const pointer to the version with the given descriptor. NULL if - * one doesn't exist. - */ - virtual BaseVersionPtr findVersion(const QString &descriptor); + /*! + * \brief Finds a version by its descriptor. + * \param descriptor The descriptor of the version to find. + * \return A const pointer to the version with the given descriptor. NULL if + * one doesn't exist. + */ + virtual BaseVersionPtr findVersion(const QString &descriptor); - /*! - * \brief Gets the recommended version from this list - * If the list doesn't support recommended versions, this works exactly as getLatestStable - */ - virtual BaseVersionPtr getRecommended() const; + /*! + * \brief Gets the recommended version from this list + * If the list doesn't support recommended versions, this works exactly as getLatestStable + */ + virtual BaseVersionPtr getRecommended() const; - /*! - * Sorts the version list. - */ - virtual void sortVersions() = 0; + /*! + * Sorts the version list. + */ + virtual void sortVersions() = 0; protected slots: - /*! - * Updates this list with the given list of versions. - * This is done by copying each version in the given list and inserting it - * into this one. - * We need to do this so that we can set the parents of the versions are set to this - * version list. This can't be done in the load task, because the versions the load - * task creates are on the load task's thread and Qt won't allow their parents - * to be set to something created on another thread. - * To get around that problem, we invoke this method on the GUI thread, which - * then copies the versions and sets their parents correctly. - * \param versions List of versions whose parents should be set. - */ - virtual void updateListData(QList versions) = 0; + /*! + * Updates this list with the given list of versions. + * This is done by copying each version in the given list and inserting it + * into this one. + * We need to do this so that we can set the parents of the versions are set to this + * version list. This can't be done in the load task, because the versions the load + * task creates are on the load task's thread and Qt won't allow their parents + * to be set to something created on another thread. + * To get around that problem, we invoke this method on the GUI thread, which + * then copies the versions and sets their parents correctly. + * \param versions List of versions whose parents should be set. + */ + virtual void updateListData(QList versions) = 0; }; diff --git a/api/logic/CMakeLists.txt b/api/logic/CMakeLists.txt index 769f112e..4c2445f0 100644 --- a/api/logic/CMakeLists.txt +++ b/api/logic/CMakeLists.txt @@ -3,446 +3,446 @@ project(MultiMC_logic) include (UnitTest) set(CORE_SOURCES - # LOGIC - Base classes and infrastructure - BaseInstaller.h - BaseInstaller.cpp - BaseVersionList.h - BaseVersionList.cpp - InstanceList.h - InstanceList.cpp - InstanceTask.h - InstanceTask.cpp - LoggedProcess.h - LoggedProcess.cpp - MessageLevel.cpp - MessageLevel.h - BaseInstanceProvider.h - FolderInstanceProvider.h - FolderInstanceProvider.cpp - BaseVersion.h - BaseInstance.h - BaseInstance.cpp - NullInstance.h - MMCZip.h - MMCZip.cpp - MMCStrings.h - MMCStrings.cpp - - # Basic instance manipulation tasks (derived from InstanceTask) - InstanceCreationTask.h - InstanceCreationTask.cpp - InstanceCopyTask.h - InstanceCopyTask.cpp - InstanceImportTask.h - InstanceImportTask.cpp - - # Use tracking separate from memory management - Usable.h - - # Prefix tree where node names are strings between separators - SeparatorPrefixTree.h - - # WARNING: globals live here - Env.h - Env.cpp - - # String filters - Filter.h - Filter.cpp - - # JSON parsing helpers - Json.h - Json.cpp - - FileSystem.h - FileSystem.cpp - - Exception.h - - # RW lock protected map - RWStorage.h - - # A variable that has an implicit default value and keeps track of changes - DefaultVariable.h - - # a smart pointer wrapper intended for safer use with Qt signal/slot mechanisms - QObjectPtr.h - - # Compression support - GZip.h - GZip.cpp - - # Command line parameter parsing - Commandline.h - Commandline.cpp - - # Version number string support - Version.h - Version.cpp - - # A Recursive file system watcher - RecursiveFileSystemWatcher.h - RecursiveFileSystemWatcher.cpp + # LOGIC - Base classes and infrastructure + BaseInstaller.h + BaseInstaller.cpp + BaseVersionList.h + BaseVersionList.cpp + InstanceList.h + InstanceList.cpp + InstanceTask.h + InstanceTask.cpp + LoggedProcess.h + LoggedProcess.cpp + MessageLevel.cpp + MessageLevel.h + BaseInstanceProvider.h + FolderInstanceProvider.h + FolderInstanceProvider.cpp + BaseVersion.h + BaseInstance.h + BaseInstance.cpp + NullInstance.h + MMCZip.h + MMCZip.cpp + MMCStrings.h + MMCStrings.cpp + + # Basic instance manipulation tasks (derived from InstanceTask) + InstanceCreationTask.h + InstanceCreationTask.cpp + InstanceCopyTask.h + InstanceCopyTask.cpp + InstanceImportTask.h + InstanceImportTask.cpp + + # Use tracking separate from memory management + Usable.h + + # Prefix tree where node names are strings between separators + SeparatorPrefixTree.h + + # WARNING: globals live here + Env.h + Env.cpp + + # String filters + Filter.h + Filter.cpp + + # JSON parsing helpers + Json.h + Json.cpp + + FileSystem.h + FileSystem.cpp + + Exception.h + + # RW lock protected map + RWStorage.h + + # A variable that has an implicit default value and keeps track of changes + DefaultVariable.h + + # a smart pointer wrapper intended for safer use with Qt signal/slot mechanisms + QObjectPtr.h + + # Compression support + GZip.h + GZip.cpp + + # Command line parameter parsing + Commandline.h + Commandline.cpp + + # Version number string support + Version.h + Version.cpp + + # A Recursive file system watcher + RecursiveFileSystemWatcher.h + RecursiveFileSystemWatcher.cpp ) add_unit_test(FileSystem - SOURCES FileSystem_test.cpp - LIBS MultiMC_logic - DATA testdata - ) + SOURCES FileSystem_test.cpp + LIBS MultiMC_logic + DATA testdata + ) add_unit_test(GZip - SOURCES GZip_test.cpp - LIBS MultiMC_logic - ) + SOURCES GZip_test.cpp + LIBS MultiMC_logic + ) set(PATHMATCHER_SOURCES - # Path matchers - pathmatcher/FSTreeMatcher.h - pathmatcher/IPathMatcher.h - pathmatcher/MultiMatcher.h - pathmatcher/RegexpMatcher.h + # Path matchers + pathmatcher/FSTreeMatcher.h + pathmatcher/IPathMatcher.h + pathmatcher/MultiMatcher.h + pathmatcher/RegexpMatcher.h ) set(NET_SOURCES - # network stuffs - net/ByteArraySink.h - net/ChecksumValidator.h - net/Download.cpp - net/Download.h - net/FileSink.cpp - net/FileSink.h - net/HttpMetaCache.cpp - net/HttpMetaCache.h - net/MetaCacheSink.cpp - net/MetaCacheSink.h - net/NetAction.h - net/NetJob.cpp - net/NetJob.h - net/PasteUpload.cpp - net/PasteUpload.h - net/Sink.h - net/URLConstants.cpp - net/URLConstants.h - net/Validator.h + # network stuffs + net/ByteArraySink.h + net/ChecksumValidator.h + net/Download.cpp + net/Download.h + net/FileSink.cpp + net/FileSink.h + net/HttpMetaCache.cpp + net/HttpMetaCache.h + net/MetaCacheSink.cpp + net/MetaCacheSink.h + net/NetAction.h + net/NetJob.cpp + net/NetJob.h + net/PasteUpload.cpp + net/PasteUpload.h + net/Sink.h + net/URLConstants.cpp + net/URLConstants.h + net/Validator.h ) # Game launch logic set(LAUNCH_SOURCES - launch/steps/PostLaunchCommand.cpp - launch/steps/PostLaunchCommand.h - launch/steps/PreLaunchCommand.cpp - launch/steps/PreLaunchCommand.h - launch/steps/TextPrint.cpp - launch/steps/TextPrint.h - launch/steps/Update.cpp - launch/steps/Update.h - launch/LaunchStep.cpp - launch/LaunchStep.h - launch/LaunchTask.cpp - launch/LaunchTask.h - launch/LogModel.cpp - launch/LogModel.h + launch/steps/PostLaunchCommand.cpp + launch/steps/PostLaunchCommand.h + launch/steps/PreLaunchCommand.cpp + launch/steps/PreLaunchCommand.h + launch/steps/TextPrint.cpp + launch/steps/TextPrint.h + launch/steps/Update.cpp + launch/steps/Update.h + launch/LaunchStep.cpp + launch/LaunchStep.h + launch/LaunchTask.cpp + launch/LaunchTask.h + launch/LogModel.cpp + launch/LogModel.h ) # Old update system set(UPDATE_SOURCES - updater/GoUpdate.h - updater/GoUpdate.cpp - updater/UpdateChecker.h - updater/UpdateChecker.cpp - updater/DownloadTask.h - updater/DownloadTask.cpp + updater/GoUpdate.h + updater/GoUpdate.cpp + updater/UpdateChecker.h + updater/UpdateChecker.cpp + updater/DownloadTask.h + updater/DownloadTask.cpp ) add_unit_test(UpdateChecker - SOURCES updater/UpdateChecker_test.cpp - LIBS MultiMC_logic - DATA updater/testdata - ) + SOURCES updater/UpdateChecker_test.cpp + LIBS MultiMC_logic + DATA updater/testdata + ) add_unit_test(DownloadTask - SOURCES updater/DownloadTask_test.cpp - LIBS MultiMC_logic - DATA updater/testdata - ) + SOURCES updater/DownloadTask_test.cpp + LIBS MultiMC_logic + DATA updater/testdata + ) # Rarely used notifications set(NOTIFICATIONS_SOURCES - # Notifications - short warning messages - notifications/NotificationChecker.h - notifications/NotificationChecker.cpp + # Notifications - short warning messages + notifications/NotificationChecker.h + notifications/NotificationChecker.cpp ) # Backend for the news bar... there's usually no news. set(NEWS_SOUR