summaryrefslogtreecommitdiffstats
path: root/libmultimc/include
diff options
context:
space:
mode:
authorAndrew <forkk@forkk.net>2013-03-08 13:56:26 -0600
committerAndrew <forkk@forkk.net>2013-03-08 13:56:26 -0600
commit2d6e785e4ee8a8b837fe84f83972ec23a09564af (patch)
tree6afdac6e06f1ba8ae5c29f62b5a4a9bc1b696b12 /libmultimc/include
parent69040f923b0344de214d6f1fc4553d223df7d2d6 (diff)
downloadMultiMC-2d6e785e4ee8a8b837fe84f83972ec23a09564af.tar
MultiMC-2d6e785e4ee8a8b837fe84f83972ec23a09564af.tar.gz
MultiMC-2d6e785e4ee8a8b837fe84f83972ec23a09564af.tar.lz
MultiMC-2d6e785e4ee8a8b837fe84f83972ec23a09564af.tar.xz
MultiMC-2d6e785e4ee8a8b837fe84f83972ec23a09564af.zip
Implemented version lists.
Diffstat (limited to 'libmultimc/include')
-rw-r--r--libmultimc/include/instance.h10
-rw-r--r--libmultimc/include/instancetypeinterface.h10
-rw-r--r--libmultimc/include/instversion.h33
-rw-r--r--libmultimc/include/instversionlist.h37
-rw-r--r--libmultimc/include/task.h9
5 files changed, 75 insertions, 24 deletions
diff --git a/libmultimc/include/instance.h b/libmultimc/include/instance.h
index aaefbd6e..41e664ff 100644
--- a/libmultimc/include/instance.h
+++ b/libmultimc/include/instance.h
@@ -23,6 +23,7 @@
#include "inifile.h"
#include "instancetypeinterface.h"
+#include "instversionlist.h"
#include "libmmc_config.h"
@@ -253,6 +254,15 @@ public:
+ //////// LISTS, LISTS, AND MORE LISTS ////////
+ /*!
+ * \brief Gets a pointer to this instance's version list.
+ * \return A pointer to the available version list for this instance.
+ */
+ virtual InstVersionList *versionList() const = 0;
+
+
+
//////// INSTANCE TYPE STUFF ////////
/*!
diff --git a/libmultimc/include/instancetypeinterface.h b/libmultimc/include/instancetypeinterface.h
index 30a12d99..ba13f820 100644
--- a/libmultimc/include/instancetypeinterface.h
+++ b/libmultimc/include/instancetypeinterface.h
@@ -20,6 +20,8 @@
#include "instanceloader.h"
+class InstVersionList;
+
//! The InstanceTypeInterface's interface ID.
#define InstanceTypeInterface_IID "net.forkk.MultiMC.InstanceTypeInterface/0.1"
@@ -56,7 +58,13 @@ public:
* \brief Gets a longer, more detailed description of this instance type.
* \return The instance type's description.
*/
- virtual QString description() const = 0;
+ virtual QString description() const = 0;
+
+ /*!
+ * \brief Gets the version list for this instance type.
+ * \return A pointer to this instance type's version list.
+ */
+ virtual InstVersionList *versionList() const = 0;
protected:
/*!
diff --git a/libmultimc/include/instversion.h b/libmultimc/include/instversion.h
index 3c6b7ac9..7de83966 100644
--- a/libmultimc/include/instversion.h
+++ b/libmultimc/include/instversion.h
@@ -26,27 +26,32 @@ class LIBMULTIMC_EXPORT InstVersion : public QObject
{
Q_OBJECT
public:
- // Constructs a new InstVersion with the given parent. The parent *must*
- // be the InstVersionList that contains this InstVersion. The InstVersion
- // should be added to the list immediately after being created as any calls
- // to id() will likely fail unless the InstVersion is in a list.
+ /*!
+ * \brief Constructs a new InstVersion with the given parent.
+ * The parent *must* be the InstVersionList that contains this InstVersion.
+ * The InstVersion should be added to the list immediately after being created.
+ */
explicit InstVersion(InstVersionList *parent = 0);
- // Returns this InstVersion's ID. This is usually just the InstVersion's index
- // within its InstVersionList, but not always.
- // If this InstVersion is not in an InstVersionList, returns -1.
- virtual int id() const = 0;
+ //! Gets the string used to identify this version in config files.
+ virtual QString descriptor() const = 0;
+
+ /*!
+ * \breif Returns this InstVersion's name.
+ * This is displayed to the user in the GUI and is usually just the version number ("1.4.7"), for example.
+ */
- // Returns this InstVersion's name. This is displayed to the user in the GUI
- // and is usually just the version number ("1.4.7"), for example.
virtual QString name() const = 0;
- // Returns this InstVersion's name. This is usually displayed to the user
- // in the GUI and specifies what kind of version this is. For example: it
- // could be "Snapshot", "Latest Version", "MCNostalgia", etc.
+ /*!
+ * \brief Returns this InstVersion's name.
+ * This is usually displayed to the user in the GUI and specifies what
+ * kind of version this is. For example: it could be "Snapshot",
+ * "Latest Version", "MCNostalgia", etc.
+ */
virtual QString type() const = 0;
- // Returns the version list that this InstVersion is a part of.
+ //! Returns the version list that this InstVersion is a part of.
virtual InstVersionList *versionList() const;
};
diff --git a/libmultimc/include/instversionlist.h b/libmultimc/include/instversionlist.h
index d64a286f..4345aaaa 100644
--- a/libmultimc/include/instversionlist.h
+++ b/libmultimc/include/instversionlist.h
@@ -21,25 +21,44 @@
#include "libmmc_config.h"
class InstVersion;
+class Task;
-// Class that each instance type's version list derives from. Version lists are
-// the lists that keep track of the available game versions for that instance.
-// This list will not be loaded on startup. It will be loaded when the list's
-// load function is called.
+/*!
+ * \brief Class that each instance type's version list derives from.
+ * Version lists are the lists that keep track of the available game versions
+ * for that instance. This list will not be loaded on startup. It will be loaded
+ * when the list's load function is called. Before using the version list, you
+ * should check to see if it has been loaded yet and if not, load the list.
+ */
class LIBMULTIMC_EXPORT InstVersionList : public QObject
{
Q_OBJECT
public:
- explicit InstVersionList();
+ explicit InstVersionList(QObject *parent = 0);
+
+ /*!
+ * \brief Gets a task that will reload the version list.
+ * Simply execute the task to load the list.
+ * \return A pointer to a task that reloads the version list.
+ */
+ virtual Task *getLoadTask() = 0;
- // Reloads the version list.
- virtual void loadVersionList() = 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.
+ //! Gets the version at the given index.
virtual const InstVersion *at(int i) const = 0;
- // Returns the number of versions in the list.
+ //! Returns the number of versions in the list.
virtual int count() const = 0;
+
+ /*!
+ * \brief Finds a version by its descriptor.
+ * \param 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 const InstVersion *findVersion(const QString &descriptor);
};
#endif // INSTVERSIONLIST_H
diff --git a/libmultimc/include/task.h b/libmultimc/include/task.h
index b1a3052d..fc5b1d25 100644
--- a/libmultimc/include/task.h
+++ b/libmultimc/include/task.h
@@ -34,6 +34,15 @@ public:
QString getStatus() const;
int getProgress() const;
+ /*!
+ * \brief Calculates and sets the task's progress based on the number of parts completed out of the total number to complete.
+ * This is essentially just shorthand for setProgress((parts / whole) * 100);
+ * \param parts The parts out of the whole completed. This parameter should
+ * be less than whole. If it is greater than whole, progress is set to 100.
+ * \param whole The total number of things that need to be completed.
+ */
+ void calcProgress(int parts, int whole);
+
public slots:
void setStatus(const QString& status);
void setProgress(int progress);