diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp index 2c3e337abe9..1c45124f631 100644 --- a/src/plugins/qtsupport/exampleslistmodel.cpp +++ b/src/plugins/qtsupport/exampleslistmodel.cpp @@ -92,9 +92,7 @@ void ExampleSetModel::update() extraManifestDirs.insert(set.manifestPath); } - QList qtVersions = examplesModel->qtVersions(); - - foreach (BaseQtVersion *version, qtVersions) { + foreach (BaseQtVersion *version, QtVersionManager::versions()) { // sanitize away qt versions that have already been added through extra sets if (extraManifestDirs.contains(version->documentationPath())) { if (debugExamples()) { @@ -488,11 +486,6 @@ void ExamplesListModel::updateQtVersions() if (defaultVersion && versions.contains(defaultVersion)) versions.move(versions.indexOf(defaultVersion), 0); - if (m_qtVersions == versions && m_selectedExampleSetIndex >= 0) - return; - - m_qtVersions = versions; - m_exampleSetModel->update(); int currentIndex = m_selectedExampleSetIndex; @@ -510,9 +503,7 @@ void ExamplesListModel::updateQtVersions() // try to select the previously selected Qt version, or // select examples corresponding to 'highest' Qt version int currentQtId = m_exampleSetModel->getQtId(currentIndex); - BaseQtVersion *newQtVersion = Utils::findOrDefault(m_qtVersions, - Utils::equal(&BaseQtVersion::uniqueId, currentQtId)); - + BaseQtVersion *newQtVersion = QtVersionManager::version(currentQtId); if (!newQtVersion) newQtVersion = findHighestQtVersion(); currentIndex = m_exampleSetModel->indexForQtVersion(newQtVersion); @@ -522,11 +513,10 @@ void ExamplesListModel::updateQtVersions() BaseQtVersion *ExamplesListModel::findHighestQtVersion() const { - QList versions = qtVersions(); + BaseQtVersion *newVersion = nullptr; - BaseQtVersion *newVersion = 0; - - foreach (BaseQtVersion *version, versions) { + const QList versions = QtVersionManager::versions(); + for (BaseQtVersion *version : versions) { if (!newVersion) { newVersion = version; } else { @@ -542,9 +532,6 @@ BaseQtVersion *ExamplesListModel::findHighestQtVersion() const if (!newVersion && !versions.isEmpty()) newVersion = versions.first(); - if (!newVersion) - return 0; - return newVersion; } @@ -569,7 +556,7 @@ QStringList ExamplesListModel::exampleSources(QString *examplesInstallPath, QStr demosPath = exampleSet.examplesPath; } else if (currentType == ExampleSetModel::QtExampleSet) { int qtId = m_exampleSetModel->getQtId(m_selectedExampleSetIndex); - foreach (BaseQtVersion *version, qtVersions()) { + foreach (BaseQtVersion *version, QtVersionManager::versions()) { if (version->uniqueId() == qtId) { manifestScanPath = version->documentationPath(); examplesPath = version->examplesPath(); @@ -651,7 +638,7 @@ void ExamplesListModel::selectExampleSet(int index) QStringList ExamplesListModel::exampleSets() const { - return Utils::transform(m_qtVersions, &BaseQtVersion::displayName); + return Utils::transform(QtVersionManager::versions(), &BaseQtVersion::displayName); } ExamplesListModelFilter::ExamplesListModelFilter(ExamplesListModel *sourceModel, bool showTutorialsOnly, QObject *parent) : diff --git a/src/plugins/qtsupport/exampleslistmodel.h b/src/plugins/qtsupport/exampleslistmodel.h index ec764ab25d8..09ca3d9a0d8 100644 --- a/src/plugins/qtsupport/exampleslistmodel.h +++ b/src/plugins/qtsupport/exampleslistmodel.h @@ -117,7 +117,6 @@ public: int selectedExampleSet() const; void selectExampleSet(int index); - QList qtVersions() const { return m_qtVersions; } QList extraExampleSets() const { return m_extraExampleSets; } QStringList exampleSets() const; @@ -139,7 +138,6 @@ private: QStringList exampleSources(QString *examplesInstallPath, QString *demosInstallPath); ExampleSetModel* m_exampleSetModel; - QList m_qtVersions; QList m_extraExampleSets; QList m_exampleItems; int m_selectedExampleSetIndex = -1;