diff options
Diffstat (limited to 'libmultimc')
-rw-r--r-- | libmultimc/include/instance.h | 10 | ||||
-rw-r--r-- | libmultimc/include/instancetypeinterface.h | 10 | ||||
-rw-r--r-- | libmultimc/include/instversion.h | 33 | ||||
-rw-r--r-- | libmultimc/include/instversionlist.h | 37 | ||||
-rw-r--r-- | libmultimc/include/task.h | 9 | ||||
-rw-r--r-- | libmultimc/src/instversionlist.cpp | 17 | ||||
-rw-r--r-- | libmultimc/src/task.cpp | 5 |
7 files changed, 94 insertions, 27 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); diff --git a/libmultimc/src/instversionlist.cpp b/libmultimc/src/instversionlist.cpp index e171cfa5..301b9969 100644 --- a/libmultimc/src/instversionlist.cpp +++ b/libmultimc/src/instversionlist.cpp @@ -13,9 +13,20 @@ * limitations under the License. */ -#include "include/instversionlist.h" +#include "instversionlist.h" +#include "instversion.h" -InstVersionList::InstVersionList() : - QObject(NULL) +InstVersionList::InstVersionList(QObject *parent) : + QObject(parent) { } + +const InstVersion *InstVersionList::findVersion(const QString &descriptor) +{ + for (int i = 0; i < count(); i++) + { + if (at(i)->descriptor() == descriptor) + return at(i); + } + return NULL; +} diff --git a/libmultimc/src/task.cpp b/libmultimc/src/task.cpp index d581a1dd..3e30827b 100644 --- a/libmultimc/src/task.cpp +++ b/libmultimc/src/task.cpp @@ -37,6 +37,11 @@ int Task::getProgress() const return progress; } +void Task::calcProgress(int parts, int whole) +{ + setProgress((int)((((float)parts) / ((float)whole))*100)); // Not sure if C++ or LISP... +} + void Task::setProgress(int progress) { this->progress = progress; |