From ff7047edb0001eb1536cd54a0c3a9f1d4153a794 Mon Sep 17 00:00:00 2001 From: Assam Boudjelthia Date: Tue, 21 Jan 2020 15:34:33 +0200 Subject: [PATCH] QtSupport: Qt for Android Examples lists only "android" tagged examples In the welcome page Examples tab, Qt for Android kits shows all available examples which might not be properly tested or intended for Android. Thus, such a kit should only lists examples tagged for android. Task-number: QTBUG-80716 Change-Id: I22dafb5d5829cb2f6b3c55ff6f2d251c0ee08557 Reviewed-by: Eike Ziller --- src/plugins/qtsupport/exampleslistmodel.cpp | 28 +++++++++++++++++---- src/plugins/qtsupport/exampleslistmodel.h | 3 +++ 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp index c82dae0f170..045168a29f2 100644 --- a/src/plugins/qtsupport/exampleslistmodel.cpp +++ b/src/plugins/qtsupport/exampleslistmodel.cpp @@ -24,7 +24,6 @@ ****************************************************************************/ #include "exampleslistmodel.h" - #include "screenshotcropper.h" #include @@ -34,6 +33,7 @@ #include #include +#include #include #include @@ -216,6 +216,11 @@ int ExampleSetModel::getQtId(int i) const return variant.toInt(); } +bool ExampleSetModel::selectedQtSupports(const Core::Id &target) const +{ + return m_selectedQtTypes.contains(target); +} + int ExampleSetModel::getExtraExampleSetIndex(int i) const { QTC_ASSERT(i >= 0, return -1); @@ -651,6 +656,10 @@ void ExampleSetModel::selectExampleSet(int index) if (index != m_selectedExampleSetIndex) { m_selectedExampleSetIndex = index; writeCurrentIdToSettings(m_selectedExampleSetIndex); + if (getType(m_selectedExampleSetIndex) == ExampleSetModel::QtExampleSet) { + BaseQtVersion *selectedQtVersion = QtVersionManager::version(getQtId(m_selectedExampleSetIndex)); + m_selectedQtTypes = selectedQtVersion->targetDeviceTypes(); + } emit selectedExampleSetChanged(m_selectedExampleSetIndex); } } @@ -690,7 +699,8 @@ void ExampleSetModel::tryToInitialize() ExamplesListModelFilter::ExamplesListModelFilter(ExamplesListModel *sourceModel, bool showTutorialsOnly, QObject *parent) : Core::ListModelFilter(sourceModel, parent), - m_showTutorialsOnly(showTutorialsOnly) + m_showTutorialsOnly(showTutorialsOnly), + m_examplesListModel(sourceModel) { } @@ -699,16 +709,24 @@ bool ExamplesListModelFilter::leaveFilterAcceptsRowBeforeFiltering(const Core::L { QTC_ASSERT(earlyExitResult, return false); - const ExampleItem *exampleItem = static_cast(item); - if (m_showTutorialsOnly && exampleItem->type != Tutorial) { + const bool isTutorial = static_cast(item)->type == Tutorial; + + if (m_showTutorialsOnly) { + *earlyExitResult = isTutorial; + return !isTutorial; + } + + if (isTutorial) { *earlyExitResult = false; return true; } - if (!m_showTutorialsOnly && exampleItem->type != Example && exampleItem->type != Demo) { + if (m_examplesListModel->exampleSetModel()->selectedQtSupports(Android::Constants::ANDROID_DEVICE_TYPE) + && !item->tags.contains("android")) { *earlyExitResult = false; return true; } + return false; } diff --git a/src/plugins/qtsupport/exampleslistmodel.h b/src/plugins/qtsupport/exampleslistmodel.h index 80b0a8fe333..ad86b12e665 100644 --- a/src/plugins/qtsupport/exampleslistmodel.h +++ b/src/plugins/qtsupport/exampleslistmodel.h @@ -50,6 +50,7 @@ public: int selectedExampleSet() const { return m_selectedExampleSetIndex; } void selectExampleSet(int index); QStringList exampleSources(QString *examplesInstallPath, QString *demosInstallPath); + bool selectedQtSupports(const Core::Id &target) const; signals: void selectedExampleSetChanged(int); @@ -89,6 +90,7 @@ private: QList m_extraExampleSets; QList m_qtVersions; int m_selectedExampleSetIndex = -1; + QSet m_selectedQtTypes; bool m_qtVersionManagerInitialized = false; bool m_helpManagerInitialized = false; @@ -158,6 +160,7 @@ protected: bool *earlyExitResult) const override; private: const bool m_showTutorialsOnly; + ExamplesListModel *m_examplesListModel = nullptr; }; } // namespace Internal