Commit a3b3d25c authored by Thomas Hartmann's avatar Thomas Hartmann

Cleanup

remove accidentally committed file.

Change-Id: I956f50d6390e8d502f47a89892bf318ca276e170
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent cb002194
From d39debcd0e4ce78df47597cea7e27df1964a1820 Mon Sep 17 00:00:00 2001
From: Thomas Hartmann <Thomas.Hartmann@digia.com>
Date: Wed, 12 Jun 2013 15:43:47 +0200
Subject: [PATCH] WelcomePage: fixes for the filter combobox for examples
"All Versions" did not work correctly and just contributed to
confusion. So it is removed. Since we need a sensible default
setting we now search for the Qt with the highest version that has
examples and demos.
Change-Id: I495252a99753ebe511b598c61a79bbb0cd293e40
---
src/plugins/qtsupport/exampleslistmodel.cpp | 73 ++++++++++++++++++++-------
1 files changed, 54 insertions(+), 19 deletions(-)
diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp
index baad189..d6603c1 100644
--- a/src/plugins/qtsupport/exampleslistmodel.cpp
+++ b/src/plugins/qtsupport/exampleslistmodel.cpp
@@ -48,13 +48,13 @@
namespace QtSupport {
namespace Internal {
-const int allQtVersionsId = -0xff;
+const int noQtVersionsId = -0xff;
static const char currentQtVersionFilterSettingsKeyC[] = "WelcomePageQtVersionFilter";
int uniqueQtVersionIdSetting()
{
QSettings *settings = Core::ICore::settings();
- int id = settings->value(QLatin1String(currentQtVersionFilterSettingsKeyC), allQtVersionsId).toInt();
+ int id = settings->value(QLatin1String(currentQtVersionFilterSettingsKeyC), noQtVersionsId).toInt();
return id;
}
@@ -77,6 +77,38 @@ public:
setRoleNames(roleNames);
}
+ int findHightestQtVersion()
+ {
+ QtVersionManager *versionManager = QtVersionManager::instance();
+ QList <BaseQtVersion *> qtVersions = versionManager->validVersions();
+
+ BaseQtVersion *newVersion = 0;
+
+ foreach (BaseQtVersion *version, qtVersions) {
+
+ if (version->isValid() && version->hasDemos() && version->hasExamples()) {
+ if (!newVersion) {
+ newVersion = version;
+ } else {
+ if (version->qtVersion() > newVersion->qtVersion()) {
+ newVersion = version;
+ } else if (version->qtVersion() == newVersion->qtVersion()
+ && version->uniqueId() < newVersion->uniqueId()) {
+ newVersion = version;
+ }
+ }
+ }
+ }
+
+ if (!newVersion && !qtVersions.isEmpty())
+ newVersion = qtVersions.first();
+
+ if (!newVersion)
+ return noQtVersionsId;
+
+ return newVersion->uniqueId();
+ }
+
void setupQtVersions()
{
beginResetModel();
@@ -90,30 +122,33 @@ public:
if (defaultVersion && qtVersions.contains(defaultVersion))
qtVersions.move(qtVersions.indexOf(defaultVersion), 0);
- QStandardItem *newItem = new QStandardItem();
- newItem->setData(tr("All Versions"), Qt::UserRole + 1);
- newItem->setData(allQtVersionsId, Qt::UserRole + 2);
- appendRow(newItem);
-
int qtVersionSetting = uniqueQtVersionIdSetting();
- if (qtVersionSetting != allQtVersionsId) {
+ int newQtVersionSetting = noQtVersionsId;
+ if (qtVersionSetting != noQtVersionsId) {
//ensure that the unique Qt id is valid
- int newQtVersionSetting = allQtVersionsId;
foreach (BaseQtVersion *version, qtVersions) {
- if (version->uniqueId() == qtVersionSetting)
+ if (version->uniqueId() == qtVersionSetting) {
newQtVersionSetting = qtVersionSetting;
+ }
}
+ }
- if (newQtVersionSetting != qtVersionSetting) {
- setUniqueQtVersionIdSetting(newQtVersionSetting);
- }
+ if (newQtVersionSetting == noQtVersionsId) {
+ newQtVersionSetting = findHightestQtVersion();
+ }
+
+ if (newQtVersionSetting != qtVersionSetting) {
+ setUniqueQtVersionIdSetting(newQtVersionSetting);
}
+
foreach (BaseQtVersion *version, qtVersions) {
- QStandardItem *newItem = new QStandardItem();
- newItem->setData(version->displayName(), Qt::UserRole + 1);
- newItem->setData(version->uniqueId(), Qt::UserRole + 2);
- appendRow(newItem);
+ if (version->hasDemos() || version->hasExamples()) {
+ QStandardItem *newItem = new QStandardItem();
+ newItem->setData(version->displayName(), Qt::UserRole + 1);
+ newItem->setData(version->uniqueId(), Qt::UserRole + 2);
+ appendRow(newItem);
+ }
}
endResetModel();
}
@@ -147,7 +182,7 @@ ExamplesListModel::ExamplesListModel(QObject *parent) :
m_updateOnQtVersionsChanged(false),
m_initialized(false),
m_helpInitialized(false),
- m_uniqueQtId(allQtVersionsId)
+ m_uniqueQtId(noQtVersionsId)
{
QHash<int, QByteArray> roleNames;
roleNames[Name] = "name";
@@ -517,7 +552,7 @@ QStringList ExamplesListModel::exampleSources(QString *examplesInstallPath, QStr
foreach (BaseQtVersion *version, qtVersions) {
//filter for qt versions
- if (version->uniqueId() != m_uniqueQtId && m_uniqueQtId != allQtVersionsId)
+ if (version->uniqueId() != m_uniqueQtId && m_uniqueQtId != noQtVersionsId)
continue;
// qt5 with examples OR demos manifest
--
1.7.6.msysgit.0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment