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>
This commit is contained in:
Assam Boudjelthia
2020-01-21 15:34:33 +02:00
parent cecf3da685
commit ff7047edb0
2 changed files with 26 additions and 5 deletions

View File

@@ -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;
}

View File

@@ -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