pollymc/api/logic/FolderInstanceProvider.h

60 lines
1.9 KiB
C
Raw Normal View History

2016-10-03 04:25:54 +05:30
#pragma once
#include "BaseInstanceProvider.h"
#include <QMap>
class QFileSystemWatcher;
2018-03-19 07:06:12 +05:30
class InstanceTask;
2016-10-03 04:25:54 +05:30
class MULTIMC_LOGIC_EXPORT FolderInstanceProvider : public BaseInstanceProvider
{
2018-07-15 18:21:05 +05:30
Q_OBJECT
2016-10-03 04:25:54 +05:30
public:
2018-07-15 18:21:05 +05:30
FolderInstanceProvider(SettingsObjectPtr settings, const QString & instDir);
2016-10-03 04:25:54 +05:30
public:
2018-07-15 18:21:05 +05:30
/// used by InstanceList to @return a list of plausible IDs to probe for
QList<InstanceId> discoverInstances() override;
2016-10-03 04:25:54 +05:30
2018-07-15 18:21:05 +05:30
/// used by InstanceList to (re)load an instance with the given @id.
InstancePtr loadInstance(const InstanceId& id) override;
2016-10-03 04:25:54 +05:30
2018-07-15 18:21:05 +05:30
// Wrap an instance creation task in some more task machinery and make it ready to be used
Task * wrapInstanceTask(InstanceTask * task);
/**
* 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;
/**
* 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;
/**
* Destroy a previously created staging area given by @keyPath - used when creation fails.
* Used by instance manipulation tasks.
*/
bool destroyStagingPath(const QString & keyPath) override;
2016-10-03 04:25:54 +05:30
public slots:
2018-07-15 18:21:05 +05:30
void on_InstFolderChanged(const Setting &setting, QVariant value);
2016-10-03 04:25:54 +05:30
private slots:
2018-07-15 18:21:05 +05:30
void instanceDirContentsChanged(const QString &path);
void groupChanged();
2016-10-03 04:25:54 +05:30
private: /* methods */
2018-07-15 18:21:05 +05:30
void loadGroupList() override;
void saveGroupList() override;
2016-10-03 04:25:54 +05:30
private: /* data */
2018-07-15 18:21:05 +05:30
QString m_instDir;
QFileSystemWatcher * m_watcher;
QMap<InstanceId, GroupId> groupMap;
QSet<InstanceId> instanceSet;
2018-07-15 18:21:05 +05:30
bool m_groupsLoaded = false;
bool m_instancesProbed = false;
2016-10-03 04:25:54 +05:30
};