Implemented version lists.
This commit is contained in:
@ -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 ////////
|
||||
|
||||
/*!
|
||||
|
@ -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:
|
||||
/*!
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
|
||||
// Reloads the version list.
|
||||
virtual void loadVersionList() = 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;
|
||||
|
||||
// Gets the version at the given index.
|
||||
//! 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.
|
||||
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
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user