From 5784e2ad869bc6feb52be6c8ee39c4a5ee7d1dff Mon Sep 17 00:00:00 2001 From: Daniel Molkentin <daniel.molkentin@nokia.com> Date: Tue, 25 May 2010 17:09:33 +0200 Subject: [PATCH] prefer adding Qt versions shipping with QML examples Reviewed-by: dt --- .../qt4projectmanager/qtversionmanager.cpp | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp index b84098ad3c5..10006b18219 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.cpp +++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp @@ -228,23 +228,30 @@ void QtVersionManager::updateDocumentation() void QtVersionManager::updateExamples() { - QList<QtVersion *> versions; - versions.append(m_versions); - - QString examplesPath; - QString demosPath; QtVersion *version = 0; + QList<QtVersion*> candidates; + // try to find a version which has both, demos and examples - foreach (version, versions) { - if (version->hasExamples()) - examplesPath = version->examplesPath(); - if (version->hasDemos()) - demosPath = version->demosPath(); - if (!examplesPath.isEmpty() && !demosPath.isEmpty()) { - emit updateExamples(examplesPath, demosPath, version->sourcePath()); + foreach (version, m_versions) { + if (version->hasExamples() && version->hasDemos()) + candidates.append(version); + } + + // prefer versions with declarative examples + foreach (version, candidates) { + if (QDir(version->examplesPath()+"/declarative").exists()) { + emit updateExamples(version->examplesPath(), version->demosPath(), version->sourcePath()); return; } } + + if (!candidates.isEmpty()) { + version = candidates.first(); + emit updateExamples(version->examplesPath(), version->demosPath(), version->sourcePath()); + return; + } + return; + } int QtVersionManager::getUniqueId() -- GitLab