summaryrefslogtreecommitdiffstats
path: root/logic/minecraft/MinecraftVersionList.cpp
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/minecraft/MinecraftVersionList.cpp
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/minecraft/MinecraftVersionList.cpp')
-rw-r--r--logic/minecraft/MinecraftVersionList.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/logic/minecraft/MinecraftVersionList.cpp b/logic/minecraft/MinecraftVersionList.cpp
index 7b3325e0..f57478e3 100644
--- a/logic/minecraft/MinecraftVersionList.cpp
+++ b/logic/minecraft/MinecraftVersionList.cpp
@@ -343,6 +343,42 @@ void MinecraftVersionList::sort()
endResetModel();
}
+QVariant MinecraftVersionList::data(const QModelIndex& index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ if (index.row() > count())
+ return QVariant();
+
+ auto version = std::dynamic_pointer_cast<MinecraftVersion>(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 RecommendedRole:
+ return version->descriptor() == "1.7.10";
+
+ case TypeRole:
+ return version->typeString();
+
+ default:
+ return QVariant();
+ }
+}
+
+BaseVersionList::RoleList MinecraftVersionList::providesRoles()
+{
+ return {VersionPointerRole, VersionRole, VersionIdRole, RecommendedRole, TypeRole};
+}
+
BaseVersionPtr MinecraftVersionList::getLatestStable() const
{
if(m_lookup.contains(m_latestReleaseID))
@@ -622,4 +658,4 @@ void MinecraftVersionList::finalizeUpdate(QString version)
saveCachedList();
}
-#include "MinecraftVersionList.moc" \ No newline at end of file
+#include "MinecraftVersionList.moc"