summaryrefslogtreecommitdiffstats
path: root/logic/forge
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/forge
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/forge')
-rw-r--r--logic/forge/ForgeVersionList.cpp95
-rw-r--r--logic/forge/ForgeVersionList.h3
2 files changed, 42 insertions, 56 deletions
diff --git a/logic/forge/ForgeVersionList.cpp b/logic/forge/ForgeVersionList.cpp
index 56ffad11..b2320a6d 100644
--- a/logic/forge/ForgeVersionList.cpp
+++ b/logic/forge/ForgeVersionList.cpp
@@ -51,7 +51,7 @@ int ForgeVersionList::count() const
int ForgeVersionList::columnCount(const QModelIndex &parent) const
{
- return 3;
+ return 1;
}
QVariant ForgeVersionList::data(const QModelIndex &index, int role) const
@@ -65,73 +65,34 @@ QVariant ForgeVersionList::data(const QModelIndex &index, int role) const
auto version = std::dynamic_pointer_cast<ForgeVersion>(m_vlist[index.row()]);
switch (role)
{
- case Qt::DisplayRole:
- switch (index.column())
- {
- case 0:
- return version->name();
-
- case 1:
- return version->mcver_sane;
-
- case 2:
- return version->typeString();
- default:
- return QVariant();
- }
-
- case Qt::ToolTipRole:
- return version->descriptor();
-
case VersionPointerRole:
return qVariantFromValue(m_vlist[index.row()]);
- default:
- return QVariant();
- }
-}
-
-QVariant ForgeVersionList::headerData(int section, Qt::Orientation orientation, int role) const
-{
- switch (role)
- {
- case Qt::DisplayRole:
- switch (section)
- {
- case 0:
- return tr("Version");
-
- case 1:
- return tr("Minecraft");
-
- case 2:
- return tr("Type");
+ case VersionRole:
+ return version->name();
- default:
- return QVariant();
- }
-
- case Qt::ToolTipRole:
- switch (section)
- {
- case 0:
- return tr("The name of the version.");
+ case VersionIdRole:
+ return version->descriptor();
- case 1:
- return tr("Minecraft version");
+ case ParentGameVersionRole:
+ return version->mcver_sane;
- case 2:
- return tr("The version's type.");
+ case RecommendedRole:
+ return version->is_recommended;
- default:
- return QVariant();
- }
+ case BranchRole:
+ return version->branch;
default:
return QVariant();
}
}
+QList<BaseVersionList::ModelRoles> ForgeVersionList::providesRoles()
+{
+ return {VersionPointerRole, VersionRole, VersionIdRole, ParentGameVersionRole, RecommendedRole, BranchRole};
+}
+
BaseVersionPtr ForgeVersionList::getLatestStable() const
{
return BaseVersionPtr();
@@ -296,6 +257,7 @@ bool ForgeListLoadTask::parseForgeList(QList<BaseVersionPtr> &out)
bool ForgeListLoadTask::parseForgeGradleList(QList<BaseVersionPtr> &out)
{
+ QMap<int, std::shared_ptr<ForgeVersion>> lookup;
QByteArray data;
{
auto dlJob = gradleListDownload;
@@ -402,6 +364,29 @@ bool ForgeListLoadTask::parseForgeGradleList(QList<BaseVersionPtr> &out)
fVersion->installer_filename = installer_filename;
fVersion->type = ForgeVersion::Gradle;
out.append(fVersion);
+ lookup[fVersion->m_buildnr] = fVersion;
+ }
+ QJsonObject promos = root.value("promos").toObject();
+ for (auto it = promos.begin(); it != promos.end(); ++it)
+ {
+ QString key = it.key();
+ int build = it.value().toInt();
+ QRegularExpression regexp("^(?<mcversion>[0-9]+(.[0-9]+)*)-(?<label>[a-z]+)$");
+ auto match = regexp.match(key);
+ if(!match.hasMatch())
+ {
+ qDebug() << key << "doesn't match." << "build" << build;
+ continue;
+ }
+
+ QString label = match.captured("label");
+ if(label != "recommended")
+ {
+ continue;
+ }
+ QString mcversion = match.captured("mcversion");
+ qDebug() << "Forge build" << build << "is the" << label << "for Minecraft" << mcversion << QString("<%1>").arg(key);
+ lookup[build]->is_recommended = true;
}
return true;
}
diff --git a/logic/forge/ForgeVersionList.h b/logic/forge/ForgeVersionList.h
index 75e1dd78..baae570d 100644
--- a/logic/forge/ForgeVersionList.h
+++ b/logic/forge/ForgeVersionList.h
@@ -44,7 +44,8 @@ public:
ForgeVersionPtr findVersionByVersionNr(QString version);
virtual QVariant data(const QModelIndex &index, int role) const;
- virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ virtual QList<ModelRoles> providesRoles() override;
+
virtual int columnCount(const QModelIndex &parent) const;
protected: