summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorAssam Boudjelthia <assam.boudjelthia@qt.io>2020-01-21 15:34:33 +0200
committerAssam Boudjelthia <assam.boudjelthia@qt.io>2020-02-13 10:38:48 +0000
commitff7047edb0001eb1536cd54a0c3a9f1d4153a794 (patch)
treeeefdc416f06836665b804f4e22698e38d1eca4b7 /src/plugins
parentcecf3da6857d45472635020ecd16dae80c3c35c2 (diff)
downloadqt-creator-ff7047edb0001eb1536cd54a0c3a9f1d4153a794.tar.gz
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 <eike.ziller@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/qtsupport/exampleslistmodel.cpp28
-rw-r--r--src/plugins/qtsupport/exampleslistmodel.h3
2 files changed, 26 insertions, 5 deletions
diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp
index c82dae0f17..045168a29f 100644
--- a/src/plugins/qtsupport/exampleslistmodel.cpp
+++ b/src/plugins/qtsupport/exampleslistmodel.cpp
@@ -24,7 +24,6 @@
****************************************************************************/
#include "exampleslistmodel.h"
-
#include "screenshotcropper.h"
#include <QBuffer>
@@ -34,6 +33,7 @@
#include <QPixmapCache>
#include <QUrl>
+#include <android/androidconstants.h>
#include <coreplugin/helpmanager.h>
#include <coreplugin/icore.h>
@@ -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<const ExampleItem *>(item);
- if (m_showTutorialsOnly && exampleItem->type != Tutorial) {
+ const bool isTutorial = static_cast<const ExampleItem *>(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 80b0a8fe33..ad86b12e66 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<ExtraExampleSet> m_extraExampleSets;
QList<BaseQtVersion*> m_qtVersions;
int m_selectedExampleSetIndex = -1;
+ QSet<Core::Id> 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