Allow plugins to register additional example sets

Change-Id: Icfa2a8093a5cffd86dc029fd1b06117f599203ab
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Eike Ziller
2019-12-16 14:24:15 +01:00
parent ab188df276
commit 83ed1e3a7c
4 changed files with 31 additions and 9 deletions

View File

@@ -107,6 +107,7 @@ ExampleSetModel::ExampleSetModel()
<< ", examplesPath=" << set.examplesPath; << ", examplesPath=" << set.examplesPath;
} }
} }
m_extraExampleSets += pluginRegisteredExampleSets();
connect(QtVersionManager::instance(), &QtVersionManager::qtVersionsLoaded, connect(QtVersionManager::instance(), &QtVersionManager::qtVersionsLoaded,
this, &ExampleSetModel::qtVersionManagerLoaded); this, &ExampleSetModel::qtVersionManagerLoaded);

View File

@@ -45,6 +45,14 @@ class ExampleSetModel : public QStandardItemModel
Q_OBJECT Q_OBJECT
public: public:
struct ExtraExampleSet
{
QString displayName;
QString manifestPath;
QString examplesPath;
};
static QVector<ExtraExampleSet> pluginRegisteredExampleSets();
ExampleSetModel(); ExampleSetModel();
int selectedExampleSet() const { return m_selectedExampleSetIndex; } int selectedExampleSet() const { return m_selectedExampleSetIndex; }
@@ -56,11 +64,6 @@ signals:
void selectedExampleSetChanged(int); void selectedExampleSetChanged(int);
private: private:
struct ExtraExampleSet {
QString displayName;
QString manifestPath;
QString examplesPath;
};
enum ExampleSetType { enum ExampleSetType {
InvalidExampleSet, InvalidExampleSet,
@@ -87,8 +90,7 @@ private:
void helpManagerInitialized(); void helpManagerInitialized();
void tryToInitialize(); void tryToInitialize();
QList<ExtraExampleSet> m_extraExampleSets; QVector<ExtraExampleSet> m_extraExampleSets;
QList<BaseQtVersion*> m_qtVersions;
int m_selectedExampleSetIndex = -1; int m_selectedExampleSetIndex = -1;
QSet<Core::Id> m_selectedQtTypes; QSet<Core::Id> m_selectedQtTypes;

View File

@@ -25,10 +25,11 @@
#include "qtversionmanager.h" #include "qtversionmanager.h"
#include "qtkitinformation.h"
#include "qtversionfactory.h"
#include "baseqtversion.h" #include "baseqtversion.h"
#include "exampleslistmodel.h"
#include "qtkitinformation.h"
#include "qtsupportconstants.h" #include "qtsupportconstants.h"
#include "qtversionfactory.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/helpmanager.h> #include <coreplugin/helpmanager.h>
@@ -77,6 +78,7 @@ static QtVersionManager *m_instance = nullptr;
static FileSystemWatcher *m_configFileWatcher = nullptr; static FileSystemWatcher *m_configFileWatcher = nullptr;
static QTimer *m_fileWatcherTimer = nullptr; static QTimer *m_fileWatcherTimer = nullptr;
static PersistentSettingsWriter *m_writer = nullptr; static PersistentSettingsWriter *m_writer = nullptr;
static QVector<ExampleSetModel::ExtraExampleSet> m_pluginRegisteredExampleSets;
static Q_LOGGING_CATEGORY(log, "qtc.qt.versions", QtWarningMsg); static Q_LOGGING_CATEGORY(log, "qtc.qt.versions", QtWarningMsg);
@@ -100,6 +102,11 @@ static bool restoreQtVersions();
static void findSystemQt(); static void findSystemQt();
static void saveQtVersions(); static void saveQtVersions();
QVector<ExampleSetModel::ExtraExampleSet> ExampleSetModel::pluginRegisteredExampleSets()
{
return m_pluginRegisteredExampleSets;
}
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// QtVersionManager // QtVersionManager
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@@ -471,6 +478,13 @@ void QtVersionManager::removeVersion(BaseQtVersion *version)
delete version; delete version;
} }
void QtVersionManager::registerExampleSet(const QString &displayName,
const QString &manifestPath,
const QString &examplesPath)
{
m_pluginRegisteredExampleSets.append({displayName, manifestPath, examplesPath});
}
using Path = QString; using Path = QString;
using FileName = QString; using FileName = QString;
static QList<std::pair<Path, FileName>> documentationFiles(BaseQtVersion *v) static QList<std::pair<Path, FileName>> documentationFiles(BaseQtVersion *v)

View File

@@ -63,6 +63,11 @@ public:
static void addVersion(BaseQtVersion *version); static void addVersion(BaseQtVersion *version);
static void removeVersion(BaseQtVersion *version); static void removeVersion(BaseQtVersion *version);
// Call latest in extensionsInitialized of plugin depending on QtSupport
static void registerExampleSet(const QString &displayName,
const QString &manifestPath,
const QString &examplesPath);
signals: signals:
// content of BaseQtVersion objects with qmake path might have changed // content of BaseQtVersion objects with qmake path might have changed
void qtVersionsChanged(const QList<int> &addedIds, const QList<int> &removedIds, const QList<int> &changedIds); void qtVersionsChanged(const QList<int> &addedIds, const QList<int> &removedIds, const QList<int> &changedIds);