GH-2144 Append '(installed)' to the installed version name

This commit is contained in:
janrupf 2018-11-09 20:44:39 +01:00 committed by Petr Mrázek
parent 16df8d7b88
commit 4cc7329ce3
3 changed files with 15 additions and 1 deletions

View File

@ -126,7 +126,14 @@ QVariant VersionProxyModel::data(const QModelIndex &index, int role) const
switch(column)
{
case Name:
return sourceModel()->data(parentIndex, BaseVersionList::VersionRole);
{
QString version = sourceModel()->data(parentIndex, BaseVersionList::VersionRole).toString();
if(version == m_currentVersion)
{
return version + " " + tr("(installed)");
}
return version;
}
case ParentVersion:
return sourceModel()->data(parentIndex, BaseVersionList::ParentVersionRole);
case Branch:
@ -432,5 +439,9 @@ void VersionProxyModel::sourceRowsRemoved(const QModelIndex& parent, int first,
endRemoveRows();
}
void VersionProxyModel::setCurrentVersion(const QString &version)
{
m_currentVersion = version;
}
#include "VersionProxyModel.moc"

View File

@ -42,6 +42,7 @@ public:
void clearFilters();
QModelIndex getRecommended() const;
QModelIndex getVersion(const QString & version) const;
void setCurrentVersion(const QString &version);
private slots:
void sourceDataChanged(const QModelIndex &source_top_left,const QModelIndex &source_bottom_right);
@ -62,4 +63,5 @@ private:
VersionFilterModel * filterModel;
bool hasRecommended = false;
bool hasLatest = false;
QString m_currentVersion;
};

View File

@ -41,6 +41,7 @@ VersionSelectWidget::VersionSelectWidget(QWidget* parent)
void VersionSelectWidget::setCurrentVersion(const QString& version)
{
m_currentVersion = version;
m_proxyModel->setCurrentVersion(version);
}
void VersionSelectWidget::setEmptyString(QString emptyString)