forked from qt-creator/qt-creator
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:
@@ -24,7 +24,6 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "exampleslistmodel.h"
|
#include "exampleslistmodel.h"
|
||||||
|
|
||||||
#include "screenshotcropper.h"
|
#include "screenshotcropper.h"
|
||||||
|
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
@@ -34,6 +33,7 @@
|
|||||||
#include <QPixmapCache>
|
#include <QPixmapCache>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
|
#include <android/androidconstants.h>
|
||||||
#include <coreplugin/helpmanager.h>
|
#include <coreplugin/helpmanager.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
@@ -216,6 +216,11 @@ int ExampleSetModel::getQtId(int i) const
|
|||||||
return variant.toInt();
|
return variant.toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ExampleSetModel::selectedQtSupports(const Core::Id &target) const
|
||||||
|
{
|
||||||
|
return m_selectedQtTypes.contains(target);
|
||||||
|
}
|
||||||
|
|
||||||
int ExampleSetModel::getExtraExampleSetIndex(int i) const
|
int ExampleSetModel::getExtraExampleSetIndex(int i) const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(i >= 0, return -1);
|
QTC_ASSERT(i >= 0, return -1);
|
||||||
@@ -651,6 +656,10 @@ void ExampleSetModel::selectExampleSet(int index)
|
|||||||
if (index != m_selectedExampleSetIndex) {
|
if (index != m_selectedExampleSetIndex) {
|
||||||
m_selectedExampleSetIndex = index;
|
m_selectedExampleSetIndex = index;
|
||||||
writeCurrentIdToSettings(m_selectedExampleSetIndex);
|
writeCurrentIdToSettings(m_selectedExampleSetIndex);
|
||||||
|
if (getType(m_selectedExampleSetIndex) == ExampleSetModel::QtExampleSet) {
|
||||||
|
BaseQtVersion *selectedQtVersion = QtVersionManager::version(getQtId(m_selectedExampleSetIndex));
|
||||||
|
m_selectedQtTypes = selectedQtVersion->targetDeviceTypes();
|
||||||
|
}
|
||||||
emit selectedExampleSetChanged(m_selectedExampleSetIndex);
|
emit selectedExampleSetChanged(m_selectedExampleSetIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -690,7 +699,8 @@ void ExampleSetModel::tryToInitialize()
|
|||||||
|
|
||||||
ExamplesListModelFilter::ExamplesListModelFilter(ExamplesListModel *sourceModel, bool showTutorialsOnly, QObject *parent) :
|
ExamplesListModelFilter::ExamplesListModelFilter(ExamplesListModel *sourceModel, bool showTutorialsOnly, QObject *parent) :
|
||||||
Core::ListModelFilter(sourceModel, 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);
|
QTC_ASSERT(earlyExitResult, return false);
|
||||||
|
|
||||||
const ExampleItem *exampleItem = static_cast<const ExampleItem *>(item);
|
const bool isTutorial = static_cast<const ExampleItem *>(item)->type == Tutorial;
|
||||||
if (m_showTutorialsOnly && exampleItem->type != Tutorial) {
|
|
||||||
|
if (m_showTutorialsOnly) {
|
||||||
|
*earlyExitResult = isTutorial;
|
||||||
|
return !isTutorial;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isTutorial) {
|
||||||
*earlyExitResult = false;
|
*earlyExitResult = false;
|
||||||
return true;
|
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;
|
*earlyExitResult = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -50,6 +50,7 @@ public:
|
|||||||
int selectedExampleSet() const { return m_selectedExampleSetIndex; }
|
int selectedExampleSet() const { return m_selectedExampleSetIndex; }
|
||||||
void selectExampleSet(int index);
|
void selectExampleSet(int index);
|
||||||
QStringList exampleSources(QString *examplesInstallPath, QString *demosInstallPath);
|
QStringList exampleSources(QString *examplesInstallPath, QString *demosInstallPath);
|
||||||
|
bool selectedQtSupports(const Core::Id &target) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void selectedExampleSetChanged(int);
|
void selectedExampleSetChanged(int);
|
||||||
@@ -89,6 +90,7 @@ private:
|
|||||||
QList<ExtraExampleSet> m_extraExampleSets;
|
QList<ExtraExampleSet> m_extraExampleSets;
|
||||||
QList<BaseQtVersion*> m_qtVersions;
|
QList<BaseQtVersion*> m_qtVersions;
|
||||||
int m_selectedExampleSetIndex = -1;
|
int m_selectedExampleSetIndex = -1;
|
||||||
|
QSet<Core::Id> m_selectedQtTypes;
|
||||||
|
|
||||||
bool m_qtVersionManagerInitialized = false;
|
bool m_qtVersionManagerInitialized = false;
|
||||||
bool m_helpManagerInitialized = false;
|
bool m_helpManagerInitialized = false;
|
||||||
@@ -158,6 +160,7 @@ protected:
|
|||||||
bool *earlyExitResult) const override;
|
bool *earlyExitResult) const override;
|
||||||
private:
|
private:
|
||||||
const bool m_showTutorialsOnly;
|
const bool m_showTutorialsOnly;
|
||||||
|
ExamplesListModel *m_examplesListModel = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
Reference in New Issue
Block a user