summaryrefslogtreecommitdiffstats
path: root/logic/minecraft/MinecraftVersionList.cpp
diff options
context:
space:
mode:
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"