summaryrefslogtreecommitdiffstats
path: root/libmultimc/include
diff options
context:
space:
mode:
authorAndrew <forkk@forkk.net>2013-05-03 20:14:38 -0500
committerAndrew <forkk@forkk.net>2013-05-03 20:14:38 -0500
commit857a4e4dbed88b647619c213d731dc460d034820 (patch)
treeddff2ab3d6af3fb049b1931cd8b27cbedd7b6ee3 /libmultimc/include
parent055198303c7bf15f456687838c37650871596946 (diff)
downloadMultiMC-857a4e4dbed88b647619c213d731dc460d034820.tar
MultiMC-857a4e4dbed88b647619c213d731dc460d034820.tar.gz
MultiMC-857a4e4dbed88b647619c213d731dc460d034820.tar.lz
MultiMC-857a4e4dbed88b647619c213d731dc460d034820.tar.xz
MultiMC-857a4e4dbed88b647619c213d731dc460d034820.zip
Implemented version list sorting.
Resolves MMC-8: https://jira.forkk.net/browse/MMC-8
Diffstat (limited to 'libmultimc/include')
-rw-r--r--libmultimc/include/instversion.h24
-rw-r--r--libmultimc/include/instversionlist.h5
-rw-r--r--libmultimc/include/minecraftversionlist.h2
3 files changed, 31 insertions, 0 deletions
diff --git a/libmultimc/include/instversion.h b/libmultimc/include/instversion.h
index e91e68ba..009bd412 100644
--- a/libmultimc/include/instversion.h
+++ b/libmultimc/include/instversion.h
@@ -104,6 +104,30 @@ public:
*/
virtual InstVersion *copyVersion(InstVersionList *newParent) const = 0;
+ /*!
+ * Checks if this version is less (older) than the given version.
+ * \param other The version to compare this one to.
+ * \return True if this version is older than the given version.
+ */
+ virtual bool isLessThan(const InstVersion &other) const;
+
+ /*!
+ * Checks if this version is greater (newer) than the given version.
+ * \param other The version to compare this one to.
+ * \return True if this version is newer than the given version.
+ */
+ virtual bool isGreaterThan(const InstVersion &other) const;
+
+ /*!
+ * \sa shouldSortBefore()
+ */
+ virtual bool operator<(const InstVersion &rhs) { return isLessThan(rhs); }
+
+ /*!
+ * \sa shouldSortAfter()
+ */
+ virtual bool operator>(const InstVersion &rhs) { return isGreaterThan(rhs); }
+
protected:
QString m_descriptor;
QString m_name;
diff --git a/libmultimc/include/instversionlist.h b/libmultimc/include/instversionlist.h
index 1aabc5cf..e28bd96f 100644
--- a/libmultimc/include/instversionlist.h
+++ b/libmultimc/include/instversionlist.h
@@ -88,6 +88,11 @@ public:
*/
virtual const InstVersion *getLatestStable();
+ /*!
+ * Sorts the version list.
+ */
+ virtual void sort() = 0;
+
protected slots:
/*!
* Updates this list with the given list of versions.
diff --git a/libmultimc/include/minecraftversionlist.h b/libmultimc/include/minecraftversionlist.h
index 18eb4ea6..0a9b9a67 100644
--- a/libmultimc/include/minecraftversionlist.h
+++ b/libmultimc/include/minecraftversionlist.h
@@ -45,12 +45,14 @@ public:
virtual const InstVersion *at(int i) const;
virtual int count() const;
virtual void printToStdOut() const;
+ virtual void sort();
/*!
* Gets the main version list instance.
*/
static MinecraftVersionList &getMainList();
+
protected:
QList<InstVersion *>m_vlist;