summaryrefslogtreecommitdiffstats
path: root/logic/liteloader
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-04-28 09:01:37 +0200
committerPetr Mrázek <peterix@gmail.com>2015-05-01 20:50:24 +0200
commitaea51a08763d81ce82326b2b875ace8a0039fb1a (patch)
tree7d92d2ed9500f7cd205257b79e49dd03bc84f001 /logic/liteloader
parent75dfbc61fcc451239254049a362b227e72d94d90 (diff)
downloadMultiMC-aea51a08763d81ce82326b2b875ace8a0039fb1a.tar
MultiMC-aea51a08763d81ce82326b2b875ace8a0039fb1a.tar.gz
MultiMC-aea51a08763d81ce82326b2b875ace8a0039fb1a.tar.lz
MultiMC-aea51a08763d81ce82326b2b875ace8a0039fb1a.tar.xz
MultiMC-aea51a08763d81ce82326b2b875ace8a0039fb1a.zip
GH-328 overhaul all relevant version lists
Diffstat (limited to 'logic/liteloader')
-rw-r--r--logic/liteloader/LiteLoaderVersionList.cpp36
-rw-r--r--logic/liteloader/LiteLoaderVersionList.h2
2 files changed, 38 insertions, 0 deletions
diff --git a/logic/liteloader/LiteLoaderVersionList.cpp b/logic/liteloader/LiteLoaderVersionList.cpp
index 2e54afdf..8b3c13e0 100644
--- a/logic/liteloader/LiteLoaderVersionList.cpp
+++ b/logic/liteloader/LiteLoaderVersionList.cpp
@@ -68,6 +68,42 @@ void LiteLoaderVersionList::sort()
endResetModel();
}
+QVariant LiteLoaderVersionList::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ if (index.row() > count())
+ return QVariant();
+
+ auto version = std::dynamic_pointer_cast<LiteLoaderVersion>(m_vlist[index.row()]);
+ switch (role)
+ {
+ case VersionPointerRole:
+ return qVariantFromValue(m_vlist[index.row()]);
+
+ case VersionRole:
+ return version->name();
+
+ case VersionIdRole:
+ return version->descriptor();
+
+ case ParentGameVersionRole:
+ return version->mcVersion;
+
+ case RecommendedRole:
+ return version->isLatest;
+
+ default:
+ return QVariant();
+ }
+}
+
+QList<BaseVersionList::ModelRoles> LiteLoaderVersionList::providesRoles()
+{
+ return {VersionPointerRole, VersionRole, VersionIdRole, ParentGameVersionRole, RecommendedRole};
+}
+
BaseVersionPtr LiteLoaderVersionList::getLatestStable() const
{
for (int i = 0; i < m_vlist.length(); i++)
diff --git a/logic/liteloader/LiteLoaderVersionList.h b/logic/liteloader/LiteLoaderVersionList.h
index fd20fcfa..f3f78349 100644
--- a/logic/liteloader/LiteLoaderVersionList.h
+++ b/logic/liteloader/LiteLoaderVersionList.h
@@ -78,6 +78,8 @@ public:
virtual const BaseVersionPtr at(int i) const;
virtual int count() const;
virtual void sort();
+ virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
+ virtual QList< ModelRoles > providesRoles();
virtual BaseVersionPtr getLatestStable() const;