diff options
author | Petr Mrázek <peterix@gmail.com> | 2018-07-24 00:11:24 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2018-07-28 22:12:57 +0200 |
commit | 76d6ec91a4a9b330e8df413f76b3d8189e0eec2f (patch) | |
tree | 80ddc5d403f830ab68750b0042b5aa36d366eb8a /api/logic/FolderInstanceProvider.h | |
parent | 7b439c85c0bf3583ac8970e7ab9e8db3bd65c968 (diff) | |
download | MultiMC-76d6ec91a4a9b330e8df413f76b3d8189e0eec2f.tar MultiMC-76d6ec91a4a9b330e8df413f76b3d8189e0eec2f.tar.gz MultiMC-76d6ec91a4a9b330e8df413f76b3d8189e0eec2f.tar.lz MultiMC-76d6ec91a4a9b330e8df413f76b3d8189e0eec2f.tar.xz MultiMC-76d6ec91a4a9b330e8df413f76b3d8189e0eec2f.zip |
NOISSUE simplify.
Diffstat (limited to 'api/logic/FolderInstanceProvider.h')
-rw-r--r-- | api/logic/FolderInstanceProvider.h | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/api/logic/FolderInstanceProvider.h b/api/logic/FolderInstanceProvider.h index e1f2ad64..ce5337c1 100644 --- a/api/logic/FolderInstanceProvider.h +++ b/api/logic/FolderInstanceProvider.h @@ -1,23 +1,42 @@ #pragma once -#include "BaseInstanceProvider.h" + +#include <QObject> +#include <QString> #include <QMap> +#include "BaseInstance.h" +#include "settings/SettingsObject.h" + +#include "multimc_logic_export.h" class QFileSystemWatcher; class InstanceTask; +using InstanceId = QString; +using GroupId = QString; +using InstanceLocator = std::pair<InstancePtr, int>; -class MULTIMC_LOGIC_EXPORT FolderInstanceProvider : public BaseInstanceProvider +enum class InstCreateError +{ + NoCreateError = 0, + NoSuchVersion, + UnknownCreateError, + InstExists, + CantCreateDir +}; + +class MULTIMC_LOGIC_EXPORT FolderInstanceProvider : public QObject { Q_OBJECT public: FolderInstanceProvider(SettingsObjectPtr settings, const QString & instDir); + virtual ~FolderInstanceProvider() = default; public: /// used by InstanceList to @return a list of plausible IDs to probe for - QList<InstanceId> discoverInstances() override; + QList<InstanceId> discoverInstances(); /// used by InstanceList to (re)load an instance with the given @id. - InstancePtr loadInstance(const InstanceId& id) override; + InstancePtr loadInstance(const InstanceId& id); // Wrap an instance creation task in some more task machinery and make it ready to be used Task * wrapInstanceTask(InstanceTask * task); @@ -26,17 +45,24 @@ public: * Create a new empty staging area for instance creation and @return a path/key top commit it later. * Used by instance manipulation tasks. */ - QString getStagedInstancePath() override; + QString getStagedInstancePath(); /** * Commit the staging area given by @keyPath to the provider - used when creation succeeds. * Used by instance manipulation tasks. */ - bool commitStagedInstance(const QString & keyPath, const QString& instanceName, const QString & groupName) override; + bool commitStagedInstance(const QString & keyPath, const QString& instanceName, const QString & groupName); /** * Destroy a previously created staging area given by @keyPath - used when creation fails. * Used by instance manipulation tasks. */ - bool destroyStagingPath(const QString & keyPath) override; + bool destroyStagingPath(const QString & keyPath); + +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<QString> groups); + public slots: void on_InstFolderChanged(const Setting &setting, QVariant value); @@ -46,10 +72,11 @@ private slots: void groupChanged(); private: /* methods */ - void loadGroupList() override; - void saveGroupList() override; + void loadGroupList(); + void saveGroupList(); private: /* data */ + SettingsObjectPtr m_globalSettings; QString m_instDir; QFileSystemWatcher * m_watcher; QMap<InstanceId, GroupId> groupMap; |