summaryrefslogtreecommitdiffstats
path: root/logic/liteloader
diff options
context:
space:
mode:
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;