GH-942 fix vanilla version list
Latest release gets the star Latest snapshot, if it's newer than latest release gets the bug
This commit is contained in:
parent
9598f80335
commit
2a4647125d
@ -165,17 +165,28 @@ QVariant VersionProxyModel::data(const QModelIndex &index, int role) const
|
|||||||
switch(column)
|
switch(column)
|
||||||
{
|
{
|
||||||
case Name:
|
case Name:
|
||||||
|
{
|
||||||
|
if(hasRecommended)
|
||||||
{
|
{
|
||||||
auto value = sourceModel()->data(parentIndex, BaseVersionList::RecommendedRole);
|
auto value = sourceModel()->data(parentIndex, BaseVersionList::RecommendedRole);
|
||||||
if(value.toBool())
|
if(value.toBool())
|
||||||
{
|
{
|
||||||
return tr("Recommended");
|
return tr("Recommended");
|
||||||
}
|
}
|
||||||
|
else if(hasLatest)
|
||||||
|
{
|
||||||
|
auto value = sourceModel()->data(parentIndex, BaseVersionList::LatestRole);
|
||||||
|
if(value.toBool())
|
||||||
|
{
|
||||||
|
return tr("Latest");
|
||||||
|
}
|
||||||
|
}
|
||||||
else if(index.row() == 0)
|
else if(index.row() == 0)
|
||||||
{
|
{
|
||||||
return tr("Latest");
|
return tr("Latest");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
return sourceModel()->data(parentIndex, BaseVersionList::VersionIdRole);
|
return sourceModel()->data(parentIndex, BaseVersionList::VersionIdRole);
|
||||||
@ -187,12 +198,22 @@ QVariant VersionProxyModel::data(const QModelIndex &index, int role) const
|
|||||||
switch(column)
|
switch(column)
|
||||||
{
|
{
|
||||||
case Name:
|
case Name:
|
||||||
|
{
|
||||||
|
if(hasRecommended)
|
||||||
{
|
{
|
||||||
auto value = sourceModel()->data(parentIndex, BaseVersionList::RecommendedRole);
|
auto value = sourceModel()->data(parentIndex, BaseVersionList::RecommendedRole);
|
||||||
if(value.toBool())
|
if(value.toBool())
|
||||||
{
|
{
|
||||||
return MMC->getThemedIcon("star");
|
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)
|
else if(index.row() == 0)
|
||||||
{
|
{
|
||||||
return MMC->getThemedIcon("bug");
|
return MMC->getThemedIcon("bug");
|
||||||
@ -207,6 +228,7 @@ QVariant VersionProxyModel::data(const QModelIndex &index, int role) const
|
|||||||
}
|
}
|
||||||
return *pixmap;
|
return *pixmap;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@ -326,6 +348,14 @@ void VersionProxyModel::setSourceModel(BaseVersionList *replacing)
|
|||||||
{
|
{
|
||||||
m_columns.push_back(Type);
|
m_columns.push_back(Type);
|
||||||
}
|
}
|
||||||
|
if(roles.contains(BaseVersionList::RecommendedRole))
|
||||||
|
{
|
||||||
|
hasRecommended = true;
|
||||||
|
}
|
||||||
|
if(roles.contains(BaseVersionList::LatestRole))
|
||||||
|
{
|
||||||
|
hasLatest = true;
|
||||||
|
}
|
||||||
filterModel->setSourceModel(replacing);
|
filterModel->setSourceModel(replacing);
|
||||||
|
|
||||||
endResetModel();
|
endResetModel();
|
||||||
|
@ -53,4 +53,6 @@ private:
|
|||||||
FilterMap m_filters;
|
FilterMap m_filters;
|
||||||
BaseVersionList::RoleList roles;
|
BaseVersionList::RoleList roles;
|
||||||
VersionFilterModel * filterModel;
|
VersionFilterModel * filterModel;
|
||||||
|
bool hasRecommended = false;
|
||||||
|
bool hasLatest = false;
|
||||||
};
|
};
|
||||||
|
@ -46,6 +46,7 @@ public:
|
|||||||
VersionIdRole,
|
VersionIdRole,
|
||||||
ParentGameVersionRole,
|
ParentGameVersionRole,
|
||||||
RecommendedRole,
|
RecommendedRole,
|
||||||
|
LatestRole,
|
||||||
TypeRole,
|
TypeRole,
|
||||||
BranchRole,
|
BranchRole,
|
||||||
PathRole,
|
PathRole,
|
||||||
|
@ -364,7 +364,21 @@ QVariant MinecraftVersionList::data(const QModelIndex& index, int role) const
|
|||||||
return version->descriptor();
|
return version->descriptor();
|
||||||
|
|
||||||
case RecommendedRole:
|
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:
|
case TypeRole:
|
||||||
return version->typeString();
|
return version->typeString();
|
||||||
@ -376,7 +390,7 @@ QVariant MinecraftVersionList::data(const QModelIndex& index, int role) const
|
|||||||
|
|
||||||
BaseVersionList::RoleList MinecraftVersionList::providesRoles()
|
BaseVersionList::RoleList MinecraftVersionList::providesRoles()
|
||||||
{
|
{
|
||||||
return {VersionPointerRole, VersionRole, VersionIdRole, RecommendedRole, TypeRole};
|
return {VersionPointerRole, VersionRole, VersionIdRole, RecommendedRole, LatestRole, TypeRole};
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseVersionPtr MinecraftVersionList::getLatestStable() const
|
BaseVersionPtr MinecraftVersionList::getLatestStable() const
|
||||||
@ -388,14 +402,6 @@ BaseVersionPtr MinecraftVersionList::getLatestStable() const
|
|||||||
|
|
||||||
BaseVersionPtr MinecraftVersionList::getRecommended() 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();
|
return getLatestStable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user