summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-05-06 09:00:21 +0200
committerPetr Mrázek <peterix@gmail.com>2015-05-06 09:00:21 +0200
commit2a4647125d6fe25237256dd615c8c0338533a2b6 (patch)
treec5cbf5390557ad89484853b8a69fed7238b2fe9c /application
parent9598f80335ae4136e229cd4c5209dcede284e2b0 (diff)
downloadMultiMC-2a4647125d6fe25237256dd615c8c0338533a2b6.tar
MultiMC-2a4647125d6fe25237256dd615c8c0338533a2b6.tar.gz
MultiMC-2a4647125d6fe25237256dd615c8c0338533a2b6.tar.lz
MultiMC-2a4647125d6fe25237256dd615c8c0338533a2b6.tar.xz
MultiMC-2a4647125d6fe25237256dd615c8c0338533a2b6.zip
GH-942 fix vanilla version list
Latest release gets the star Latest snapshot, if it's newer than latest release gets the bug
Diffstat (limited to 'application')
-rw-r--r--application/VersionProxyModel.cpp76
-rw-r--r--application/VersionProxyModel.h2
2 files changed, 55 insertions, 23 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;
};