summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--application/VersionProxyModel.cpp76
-rw-r--r--application/VersionProxyModel.h2
-rw-r--r--logic/BaseVersionList.h1
-rw-r--r--logic/minecraft/MinecraftVersionList.cpp26
4 files changed, 72 insertions, 33 deletions
diff --git a/application/VersionProxyModel.cpp b/application/VersionProxyModel.cpp
index 2bfafd47..743ffad0 100644
--- a/application/VersionProxyModel.cpp
+++ b/application/VersionProxyModel.cpp
@@ -166,14 +166,25 @@ QVariant VersionProxyModel::data(const QModelIndex &index, int role) const
{
case Name:
{
- auto value = sourceModel()->data(parentIndex, BaseVersionList::RecommendedRole);
- if(value.toBool())
+ if(hasRecommended)
{
- return tr("Recommended");
- }
- else if(index.row() == 0)
- {
- return tr("Latest");
+ auto value = sourceModel()->data(parentIndex, BaseVersionList::RecommendedRole);
+ if(value.toBool())
+ {
+ return tr("Recommended");
+ }
+ else if(hasLatest)
+ {
+ auto value = sourceModel()->data(parentIndex, BaseVersionList::LatestRole);
+ if(value.toBool())
+ {
+ return tr("Latest");
+ }
+ }
+ else if(index.row() == 0)
+ {
+ return tr("Latest");
+ }
}
}
default:
@@ -188,24 +199,35 @@ QVariant VersionProxyModel::data(const QModelIndex &index, int role) const
{
case Name:
{
- auto value = sourceModel()->data(parentIndex, BaseVersionList::RecommendedRole);
- if(value.toBool())
- {
- return MMC->getThemedIcon("star");
- }
- else if(index.row() == 0)
- {
- return MMC->getThemedIcon("bug");
- }
- auto pixmap = QPixmapCache::find("placeholder");
- if(!pixmap)
+ if(hasRecommended)
{
- QPixmap px(16,16);
- px.fill(Qt::transparent);
- QPixmapCache::insert("placeholder", px);
- return px;
+ auto value = sourceModel()->data(parentIndex, BaseVersionList::RecommendedRole);
+ if(value.toBool())
+ {
+ return MMC->getThemedIcon("star");
+ }
+ else if(hasLatest)
+ {
+ auto value = sourceModel()->data(parentIndex, BaseVersionList::LatestRole);
+ if(value.toBool())
+ {
+ return MMC->getThemedIcon("bug");
+ }
+ }
+ else if(index.row() == 0)
+ {
+ return MMC->getThemedIcon("bug");
+ }
+ auto pixmap = QPixmapCache::find("placeholder");
+ if(!pixmap)
+ {
+ QPixmap px(16,16);
+ px.fill(Qt::transparent);
+ QPixmapCache::insert("placeholder", px);
+ return px;
+ }
+ return *pixmap;
}
- return *pixmap;
}
default:
{
@@ -326,6 +348,14 @@ void VersionProxyModel::setSourceModel(BaseVersionList *replacing)
{
m_columns.push_back(Type);
}
+ if(roles.contains(BaseVersionList::RecommendedRole))
+ {
+ hasRecommended = true;
+ }
+ if(roles.contains(BaseVersionList::LatestRole))
+ {
+ hasLatest = true;
+ }
filterModel->setSourceModel(replacing);
endResetModel();
diff --git a/application/VersionProxyModel.h b/application/VersionProxyModel.h
index 456268f0..68bb816f 100644
--- a/application/VersionProxyModel.h
+++ b/application/VersionProxyModel.h
@@ -53,4 +53,6 @@ private:
FilterMap m_filters;
BaseVersionList::RoleList roles;
VersionFilterModel * filterModel;
+ bool hasRecommended = false;
+ bool hasLatest = false;
};
diff --git a/logic/BaseVersionList.h b/logic/BaseVersionList.h
index 432f6593..ce36e286 100644
--- a/logic/BaseVersionList.h
+++ b/logic/BaseVersionList.h
@@ -46,6 +46,7 @@ public:
VersionIdRole,
ParentGameVersionRole,
RecommendedRole,
+ LatestRole,
TypeRole,
BranchRole,
PathRole,
diff --git a/logic/minecraft/MinecraftVersionList.cpp b/logic/minecraft/MinecraftVersionList.cpp
index 5f29bfec..0e2cbf90 100644
--- a/logic/minecraft/MinecraftVersionList.cpp
+++ b/logic/minecraft/MinecraftVersionList.cpp
@@ -364,7 +364,21 @@ QVariant MinecraftVersionList::data(const QModelIndex& index, int role) const
return version->descriptor();
case RecommendedRole:
- return version->descriptor() == g_VersionFilterData.recommendedMinecraftVersion;
+ return version->descriptor() == m_latestReleaseID;
+
+ case LatestRole:
+ {
+ if(version->descriptor() != m_latestSnapshotID)
+ return false;
+ MinecraftVersionPtr latestRelease = std::dynamic_pointer_cast<MinecraftVersion>(getLatestStable());
+ /*
+ if(latestRelease && latestRelease->m_releaseTime > version->m_releaseTime)
+ {
+ return false;
+ }
+ */
+ return true;
+ }
case TypeRole:
return version->typeString();
@@ -376,7 +390,7 @@ QVariant MinecraftVersionList::data(const QModelIndex& index, int role) const
BaseVersionList::RoleList MinecraftVersionList::providesRoles()
{
- return {VersionPointerRole, VersionRole, VersionIdRole, RecommendedRole, TypeRole};
+ return {VersionPointerRole, VersionRole, VersionIdRole, RecommendedRole, LatestRole, TypeRole};
}
BaseVersionPtr MinecraftVersionList::getLatestStable() const
@@ -388,14 +402,6 @@ BaseVersionPtr MinecraftVersionList::getLatestStable() const
BaseVersionPtr MinecraftVersionList::getRecommended() const
{
- for(auto item: m_vlist)
- {
- auto version = std::dynamic_pointer_cast<MinecraftVersion>(item);
- if(version->descriptor() == g_VersionFilterData.recommendedMinecraftVersion)
- {
- return item;
- }
- }
return getLatestStable();
}