summaryrefslogtreecommitdiffstats
path: root/api/logic/InstanceList.h
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-10-03 00:55:54 +0200
committerPetr Mrázek <peterix@gmail.com>2016-10-26 18:21:24 +0200
commitd66fdcd4cc6913508d2987c14cd9fc4d6760b8a5 (patch)
tree4f385106ce732d4f7338feab5391f2a06c68a0e6 /api/logic/InstanceList.h
parentbbe139dce51a7965394c800cac974946820d3869 (diff)
downloadMultiMC-d66fdcd4cc6913508d2987c14cd9fc4d6760b8a5.tar
MultiMC-d66fdcd4cc6913508d2987c14cd9fc4d6760b8a5.tar.gz
MultiMC-d66fdcd4cc6913508d2987c14cd9fc4d6760b8a5.tar.lz
MultiMC-d66fdcd4cc6913508d2987c14cd9fc4d6760b8a5.tar.xz
MultiMC-d66fdcd4cc6913508d2987c14cd9fc4d6760b8a5.zip
NOISSUE Granular instance reload
Diffstat (limited to 'api/logic/InstanceList.h')
-rw-r--r--api/logic/InstanceList.h111
1 files changed, 16 insertions, 95 deletions
diff --git a/api/logic/InstanceList.h b/api/logic/InstanceList.h
index 074cca7c..b643de85 100644
--- a/api/logic/InstanceList.h
+++ b/api/logic/InstanceList.h
@@ -18,24 +18,22 @@
#include <QObject>
#include <QAbstractListModel>
#include <QSet>
+#include <QList>
#include "BaseInstance.h"
+#include "BaseInstanceProvider.h"
#include "multimc_logic_export.h"
+#include "QObjectPtr.h"
+
+class QFileSystemWatcher;
class BaseInstance;
class QDir;
class MULTIMC_LOGIC_EXPORT InstanceList : public QAbstractListModel
{
Q_OBJECT
-private:
- void loadGroupList(QMap<QString, QString> &groupList);
- void suspendGroupSaving();
- void resumeGroupSaving();
-
-public slots:
- void saveGroupList();
public:
explicit InstanceList(SettingsObjectPtr globalSettings, const QString &instDir, QObject *parent = 0);
@@ -64,124 +62,47 @@ public:
UnknownError
};
- enum InstLoadError
- {
- NoLoadError = 0,
- UnknownLoadError,
- NotAnInstance
- };
-
- enum InstCreateError
- {
- NoCreateError = 0,
- NoSuchVersion,
- UnknownCreateError,
- InstExists,
- CantCreateDir
- };
-
- QString instDir() const
- {
- return m_instDir;
- }
-
- /*!
- * \brief Get the instance at index
- */
InstancePtr at(int i) const
{
return m_instances.at(i);
}
- ;
- /*!
- * \brief Get the count of loaded instances
- */
int count() const
{
return m_instances.count();
}
- ;
- /// Clear all instances. Triggers notifications.
- void clear();
+ InstListError loadList(bool complete = false);
- /// Add an instance. Triggers notifications, returns the new index
- int add(InstancePtr t);
+ /// Add an instance provider. Takes ownership of it. Should only be done before the first load.
+ void addInstanceProvider(BaseInstanceProvider * provider);
- /// Get an instance by ID
InstancePtr getInstanceById(QString id) const;
-
QModelIndex getInstanceIndexById(const QString &id) const;
-
- // FIXME: instead of iterating through all instances and forming a set, keep the set around
QStringList getGroups();
void deleteGroup(const QString & name);
- /*!
- * \brief Creates a stub instance
- *
- * \param inst Pointer to store the created instance in.
- * \param version Game version to use for the instance
- * \param instDir The new instance's directory.
- * \return An InstCreateError error code.
- * - InstExists if the given instance directory is already an instance.
- * - CantCreateDir if the given instance directory cannot be created.
- */
- InstCreateError createInstance(InstancePtr &inst, BaseVersionPtr version,
- const QString &instDir);
-
- /*!
- * \brief Creates a copy of an existing instance with a new name
- *
- * \param newInstance Pointer to store the created instance in.
- * \param oldInstance The instance to copy
- * \param instDir The new instance's directory.
- * \return An InstCreateError error code.
- * - InstExists if the given instance directory is already an instance.
- * - CantCreateDir if the given instance directory cannot be created.
- */
- InstCreateError copyInstance(InstancePtr &newInstance, InstancePtr &oldInstance,
- const QString &instDir, bool copySaves);
-
- /*!
- * \brief Loads an instance from the given directory.
- * Checks the instance's INI file to figure out what the instance's type is first.
- * \param inst Pointer to store the loaded instance in.
- * \param instDir The instance's directory.
- * \return An InstLoadError error code.
- * - NotAnInstance if the given instance directory isn't a valid instance.
- */
- InstLoadError loadInstance(InstancePtr &inst, const QString &instDir);
-
signals:
void dataIsInvalid();
-public slots:
- void on_InstFolderChanged(const Setting &setting, QVariant value);
-
- /*!
- * \brief Loads the instance list. Triggers notifications.
- */
- InstListError loadList();
-
private slots:
void propertiesChanged(BaseInstance *inst);
- void instanceNuked(BaseInstance *inst);
- void groupChanged();
+ void groupsPublished(QSet<QString>);
+ void providerUpdated();
private:
int getInstIndex(BaseInstance *inst) const;
-
-public:
- static bool continueProcessInstance(InstancePtr instPtr, const int error, const QDir &dir, QMap<QString, QString> &groupMap);
+ void suspendWatch();
+ void resumeWatch();
+ void add(const QList<InstancePtr> &list);
protected:
+ int m_watchLevel = 0;
+ QSet<BaseInstanceProvider *> m_updatedProviders;
QString m_instDir;
QList<InstancePtr> m_instances;
QSet<QString> m_groups;
SettingsObjectPtr m_globalSettings;
- bool suspendedGroupSave = false;
- bool queuedGroupSave = false;
+ QVector<shared_qobject_ptr<BaseInstanceProvider>> m_providers;
};