From aea51a08763d81ce82326b2b875ace8a0039fb1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Tue, 28 Apr 2015 09:01:37 +0200 Subject: GH-328 overhaul all relevant version lists --- logic/minecraft/MinecraftVersionList.cpp | 38 +++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'logic/minecraft/MinecraftVersionList.cpp') 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(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" -- cgit v1.2.3