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