From ef2cbe16e611da68f3cb529f87f4ecb3038af161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sat, 9 Dec 2017 01:30:23 +0100 Subject: NOISSUE when there is a version added already, preselect it in the version select dialog --- application/VersionProxyModel.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'application/VersionProxyModel.cpp') diff --git a/application/VersionProxyModel.cpp b/application/VersionProxyModel.cpp index 96bdc9ab..0dbc4ef6 100644 --- a/application/VersionProxyModel.cpp +++ b/application/VersionProxyModel.cpp @@ -369,6 +369,24 @@ QModelIndex VersionProxyModel::getRecommended() const return index(recommended, 0); } +QModelIndex VersionProxyModel::getVersion(const QString& version) const +{ + int found = -1; + for (int i = 0; i < rowCount(); i++) + { + auto value = sourceModel()->data(mapToSource(index(i, 0)), BaseVersionList::VersionRole); + if (value.toString() == version) + { + found = i; + } + } + if(found == -1) + { + return QModelIndex(); + } + return index(found, 0); +} + void VersionProxyModel::clearFilters() { m_filters.clear(); -- cgit v1.2.3