forked from qt-creator/qt-creator
De-emphasize PluginManager::getObjects<Type>()
... by additionally keeping local (currently non-owning) pools per "interesting" type. Current situation: - The global object pool does not scale well for looking up objects, as iteration plus qobject_cast typically iterates over all pooled objects. - User code that can use typed results from the object pool need to have access to the full type definition anyway, i.e. depend on the plugin of the target class anyway. The patch here solves the scaling problem is to have local type-specific pools to which objects register in their constructors and deregister in their destructors. This patch here does *not* change the ownership model of the pooled objects, however, it opens the possibility to change the ownership model per type (e.g. by not putting things into the global pool at all anymore and make the local pool 'owning') and the intent is to handle that in later patchs. Even without the follow-up patches this here is a performance improvement for the cases that access the local pools instead the global one, i.e. "practically all". Change-Id: Ib11a42df2c4ecf5e1155534730083a520dd1995b Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -82,6 +82,8 @@ public:
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
// This is useful for soft dependencies using pure interfaces.
|
||||
template <typename T> static T *getObject()
|
||||
{
|
||||
QReadLocker lock(listLock());
|
||||
|
@@ -204,6 +204,24 @@ QString PropertyInfo::toString() const
|
||||
return list.join('|');
|
||||
}
|
||||
|
||||
static QList<CustomImportsProvider *> g_customImportProviders;
|
||||
|
||||
CustomImportsProvider::CustomImportsProvider(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
g_customImportProviders.append(this);
|
||||
}
|
||||
|
||||
CustomImportsProvider::~CustomImportsProvider()
|
||||
{
|
||||
g_customImportProviders.removeOne(this);
|
||||
}
|
||||
|
||||
const QList<CustomImportsProvider *> CustomImportsProvider::allProviders()
|
||||
{
|
||||
return g_customImportProviders;
|
||||
}
|
||||
|
||||
} // namespace QmlJS
|
||||
|
||||
CppComponentValue::CppComponentValue(FakeMetaObject::ConstPtr metaObject, const QString &className,
|
||||
|
@@ -1127,8 +1127,11 @@ class QMLJS_EXPORT CustomImportsProvider : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CustomImportsProvider(QObject *parent = 0) : QObject(parent) {}
|
||||
virtual ~CustomImportsProvider() {}
|
||||
explicit CustomImportsProvider(QObject *parent = nullptr);
|
||||
virtual ~CustomImportsProvider();
|
||||
|
||||
static const QList<CustomImportsProvider *> allProviders();
|
||||
|
||||
virtual QList<Import> imports(ValueOwner *valueOwner, const Document *context) const = 0;
|
||||
};
|
||||
|
||||
|
@@ -33,8 +33,6 @@
|
||||
#include "qmljsqrcparser.h"
|
||||
#include "qmljsconstants.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <QDir>
|
||||
|
||||
using namespace LanguageUtils;
|
||||
@@ -212,12 +210,9 @@ Context::ImportsPerDocument LinkPrivate::linkImports()
|
||||
Imports *imports = new Imports(valueOwner);
|
||||
|
||||
// Add custom imports for the opened document
|
||||
if (ExtensionSystem::PluginManager::instance()) {
|
||||
auto providers = ExtensionSystem::PluginManager::getObjects<CustomImportsProvider>();
|
||||
foreach (const auto &provider, providers)
|
||||
for (const auto &provider : CustomImportsProvider::allProviders())
|
||||
foreach (const auto &import, provider->imports(valueOwner, document.data()))
|
||||
importCache.insert(ImportCacheKey(import.info), import);
|
||||
}
|
||||
|
||||
populateImportedTypes(imports, document);
|
||||
importsPerDocument.insert(document.data(), QSharedPointer<Imports>(imports));
|
||||
|
@@ -41,8 +41,6 @@
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <projectexplorer/buildconfiguration.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
@@ -92,6 +90,18 @@ static bool openXmlFile(QDomDocument &doc, const Utils::FileName &fileName);
|
||||
static bool openManifest(ProjectExplorer::Target *target, QDomDocument &doc);
|
||||
static int parseMinSdk(const QDomElement &manifestElem);
|
||||
|
||||
static QList<AndroidQtSupport *> g_androidQtSupportProviders;
|
||||
|
||||
AndroidQtSupport::AndroidQtSupport()
|
||||
{
|
||||
g_androidQtSupportProviders.append(this);
|
||||
}
|
||||
|
||||
AndroidQtSupport::~AndroidQtSupport()
|
||||
{
|
||||
g_androidQtSupportProviders.removeOne(this);
|
||||
}
|
||||
|
||||
bool AndroidManager::supportsAndroid(const ProjectExplorer::Kit *kit)
|
||||
{
|
||||
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit);
|
||||
@@ -457,8 +467,7 @@ bool AndroidManager::checkForQt51Files(Utils::FileName fileName)
|
||||
|
||||
AndroidQtSupport *AndroidManager::androidQtSupport(ProjectExplorer::Target *target)
|
||||
{
|
||||
QList<AndroidQtSupport *> providerList = ExtensionSystem::PluginManager::getObjects<AndroidQtSupport>();
|
||||
foreach (AndroidQtSupport *provider, providerList) {
|
||||
for (AndroidQtSupport *provider : g_androidQtSupportProviders) {
|
||||
if (provider->canHandle(target))
|
||||
return provider;
|
||||
}
|
||||
|
@@ -45,6 +45,10 @@ class ANDROID_EXPORT AndroidQtSupport : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
protected:
|
||||
AndroidQtSupport();
|
||||
~AndroidQtSupport();
|
||||
|
||||
public:
|
||||
enum BuildType {
|
||||
DebugBuild,
|
||||
@@ -52,7 +56,6 @@ public:
|
||||
ReleaseBuildSigned
|
||||
};
|
||||
|
||||
public:
|
||||
virtual bool canHandle(const ProjectExplorer::Target *target) const = 0;
|
||||
virtual QStringList soLibSearchPath(const ProjectExplorer::Target *target) const = 0;
|
||||
virtual QStringList androidExtraLibs(const ProjectExplorer::Target *target) const = 0;
|
||||
|
@@ -28,14 +28,24 @@
|
||||
#include "basefilewizardfactory.h"
|
||||
#include "ifilewizardextension.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace Core {
|
||||
|
||||
static QList<IFileWizardExtension *> g_fileWizardExtensions;
|
||||
|
||||
IFileWizardExtension::IFileWizardExtension()
|
||||
{
|
||||
g_fileWizardExtensions.append(this);
|
||||
}
|
||||
|
||||
IFileWizardExtension::~IFileWizardExtension()
|
||||
{
|
||||
g_fileWizardExtensions.removeOne(this);
|
||||
}
|
||||
|
||||
BaseFileWizard::BaseFileWizard(const BaseFileWizardFactory *factory,
|
||||
const QVariantMap &extraValues,
|
||||
QWidget *parent) :
|
||||
@@ -43,19 +53,8 @@ BaseFileWizard::BaseFileWizard(const BaseFileWizardFactory *factory,
|
||||
m_extraValues(extraValues),
|
||||
m_factory(factory)
|
||||
{
|
||||
// Compile extension pages, purge out unused ones
|
||||
QList<IFileWizardExtension *> extensionList
|
||||
= ExtensionSystem::PluginManager::getObjects<IFileWizardExtension>();
|
||||
|
||||
for (auto it = extensionList.begin(); it != extensionList.end(); ) {
|
||||
const QList<QWizardPage *> extensionPages = (*it)->extensionPages(factory);
|
||||
if (extensionPages.empty()) {
|
||||
it = extensionList.erase(it);
|
||||
} else {
|
||||
m_extensionPages += extensionPages;
|
||||
++it;
|
||||
}
|
||||
}
|
||||
for (IFileWizardExtension *extension : g_fileWizardExtensions)
|
||||
m_extensionPages += extension->extensionPages(factory);
|
||||
|
||||
if (!m_extensionPages.empty())
|
||||
m_firstExtensionPage = m_extensionPages.front();
|
||||
@@ -67,9 +66,7 @@ void BaseFileWizard::initializePage(int id)
|
||||
if (page(id) == m_firstExtensionPage) {
|
||||
generateFileList();
|
||||
|
||||
QList<IFileWizardExtension *> extensionList
|
||||
= ExtensionSystem::PluginManager::getObjects<IFileWizardExtension>();
|
||||
foreach (IFileWizardExtension *ex, extensionList)
|
||||
for (IFileWizardExtension *ex : g_fileWizardExtensions)
|
||||
ex->firstExtensionPageShown(m_files, m_extraValues);
|
||||
}
|
||||
}
|
||||
@@ -99,9 +96,7 @@ void BaseFileWizard::accept()
|
||||
break;
|
||||
}
|
||||
|
||||
QList<IFileWizardExtension *> extensionList
|
||||
= ExtensionSystem::PluginManager::getObjects<IFileWizardExtension>();
|
||||
foreach (IFileWizardExtension *ex, extensionList) {
|
||||
for (IFileWizardExtension *ex : g_fileWizardExtensions) {
|
||||
for (int i = 0; i < m_files.count(); i++) {
|
||||
ex->applyCodeStyle(&m_files[i]);
|
||||
}
|
||||
@@ -116,7 +111,7 @@ void BaseFileWizard::accept()
|
||||
|
||||
bool removeOpenProjectAttribute = false;
|
||||
// Run the extensions
|
||||
foreach (IFileWizardExtension *ex, extensionList) {
|
||||
for (IFileWizardExtension *ex : g_fileWizardExtensions) {
|
||||
bool remove;
|
||||
if (!ex->processFiles(m_files, &remove, &errorMessage)) {
|
||||
if (!errorMessage.isEmpty())
|
||||
|
@@ -135,6 +135,7 @@ QIcon Core::IOptionsPage::categoryIcon() const
|
||||
Sets \a categoryIcon as the category icon of the options page.
|
||||
*/
|
||||
|
||||
static QList<Core::IOptionsPage *> g_optionsPages;
|
||||
|
||||
/*!
|
||||
Constructs an options page with the given \a parent.
|
||||
@@ -143,7 +144,7 @@ Core::IOptionsPage::IOptionsPage(QObject *parent)
|
||||
: QObject(parent),
|
||||
m_keywordsInitialized(false)
|
||||
{
|
||||
|
||||
g_optionsPages.append(this);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -151,6 +152,12 @@ Core::IOptionsPage::IOptionsPage(QObject *parent)
|
||||
*/
|
||||
Core::IOptionsPage::~IOptionsPage()
|
||||
{
|
||||
g_optionsPages.removeOne(this);
|
||||
}
|
||||
|
||||
const QList<Core::IOptionsPage *> Core::IOptionsPage::allOptionsPages()
|
||||
{
|
||||
return g_optionsPages;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -183,6 +190,24 @@ bool Core::IOptionsPage::matches(const QString &searchKeyWord) const
|
||||
return false;
|
||||
}
|
||||
|
||||
static QList<Core::IOptionsPageProvider *> g_optionsPagesProviders;
|
||||
|
||||
Core::IOptionsPageProvider::IOptionsPageProvider(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
g_optionsPagesProviders.append(this);
|
||||
}
|
||||
|
||||
Core::IOptionsPageProvider::~IOptionsPageProvider()
|
||||
{
|
||||
g_optionsPagesProviders.removeOne(this);
|
||||
}
|
||||
|
||||
const QList<Core::IOptionsPageProvider *> Core::IOptionsPageProvider::allOptionsPagesProviders()
|
||||
{
|
||||
return g_optionsPagesProviders;
|
||||
}
|
||||
|
||||
QIcon Core::IOptionsPageProvider::categoryIcon() const
|
||||
{
|
||||
return QIcon(m_categoryIcon);
|
||||
|
@@ -47,6 +47,8 @@ public:
|
||||
IOptionsPage(QObject *parent = 0);
|
||||
virtual ~IOptionsPage();
|
||||
|
||||
static const QList<IOptionsPage *> allOptionsPages();
|
||||
|
||||
Id id() const { return m_id; }
|
||||
QString displayName() const { return m_displayName; }
|
||||
Id category() const { return m_category; }
|
||||
@@ -88,7 +90,10 @@ class CORE_EXPORT IOptionsPageProvider : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IOptionsPageProvider(QObject *parent = 0) : QObject(parent) {}
|
||||
IOptionsPageProvider(QObject *parent = nullptr);
|
||||
~IOptionsPageProvider();
|
||||
|
||||
static const QList<IOptionsPageProvider *> allOptionsPagesProviders();
|
||||
|
||||
Id category() const { return m_category; }
|
||||
QString displayCategory() const { return m_displayCategory; }
|
||||
|
@@ -27,7 +27,6 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/fancylineedit.h>
|
||||
@@ -69,7 +68,7 @@ bool optionsPageLessThan(const IOptionsPage *p1, const IOptionsPage *p2)
|
||||
|
||||
static inline QList<IOptionsPage*> sortedOptionsPages()
|
||||
{
|
||||
QList<IOptionsPage*> rc = ExtensionSystem::PluginManager::getObjects<IOptionsPage>();
|
||||
QList<IOptionsPage*> rc = IOptionsPage::allOptionsPages();
|
||||
std::stable_sort(rc.begin(), rc.end(), optionsPageLessThan);
|
||||
return rc;
|
||||
}
|
||||
@@ -414,8 +413,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
|
||||
else
|
||||
setWindowTitle(tr("Options"));
|
||||
|
||||
m_model->setPages(m_pages,
|
||||
ExtensionSystem::PluginManager::getObjects<IOptionsPageProvider>());
|
||||
m_model->setPages(m_pages, IOptionsPageProvider::allOptionsPagesProviders());
|
||||
|
||||
m_proxyModel->setSourceModel(m_model);
|
||||
m_proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||
|
@@ -25,13 +25,23 @@
|
||||
|
||||
#include "diffservice.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
static DiffService *g_instance = nullptr;
|
||||
|
||||
DiffService::DiffService()
|
||||
{
|
||||
g_instance = this;
|
||||
}
|
||||
|
||||
DiffService::~DiffService()
|
||||
{
|
||||
g_instance = nullptr;
|
||||
}
|
||||
|
||||
DiffService *DiffService::instance()
|
||||
{
|
||||
return ExtensionSystem::PluginManager::getObject<DiffService>();
|
||||
return g_instance;
|
||||
}
|
||||
|
||||
} // Core
|
||||
|
@@ -38,7 +38,8 @@ class CORE_EXPORT DiffService
|
||||
public:
|
||||
static DiffService *instance();
|
||||
|
||||
virtual ~DiffService() {}
|
||||
DiffService();
|
||||
virtual ~DiffService();
|
||||
|
||||
virtual void diffFiles(const QString &leftFileName, const QString &rightFileName) = 0;
|
||||
virtual void diffModifiedFiles(const QStringList &fileNames) = 0;
|
||||
|
@@ -711,24 +711,26 @@ bool DocumentManager::saveDocument(IDocument *document, const QString &fileName,
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<typename FactoryType>
|
||||
QSet<QString> filterStrings()
|
||||
QString DocumentManager::allDocumentFactoryFiltersString(QString *allFilesFilter = 0)
|
||||
{
|
||||
QSet<QString> filters;
|
||||
for (FactoryType *factory : ExtensionSystem::PluginManager::getObjects<FactoryType>()) {
|
||||
QSet<QString> uniqueFilters;
|
||||
|
||||
for (IEditorFactory *factory : IEditorFactory::allEditorFactories()) {
|
||||
for (const QString &mt : factory->mimeTypes()) {
|
||||
const QString filter = mimeTypeForName(mt).filterString();
|
||||
if (!filter.isEmpty())
|
||||
filters.insert(filter);
|
||||
uniqueFilters.insert(filter);
|
||||
}
|
||||
}
|
||||
|
||||
for (IDocumentFactory *factory : IDocumentFactory::allDocumentFactories()) {
|
||||
for (const QString &mt : factory->mimeTypes()) {
|
||||
const QString filter = mimeTypeForName(mt).filterString();
|
||||
if (!filter.isEmpty())
|
||||
uniqueFilters.insert(filter);
|
||||
}
|
||||
}
|
||||
return filters;
|
||||
}
|
||||
|
||||
QString DocumentManager::allDocumentFactoryFiltersString(QString *allFilesFilter = 0)
|
||||
{
|
||||
const QSet<QString> uniqueFilters = filterStrings<IDocumentFactory>()
|
||||
+ filterStrings<IEditorFactory>();
|
||||
QStringList filters = uniqueFilters.toList();
|
||||
filters.sort();
|
||||
const QString allFiles = Utils::allFilesFilterString();
|
||||
|
@@ -186,17 +186,6 @@ static void setFocusToEditorViewAndUnmaximizePanes(EditorView *view)
|
||||
}
|
||||
}
|
||||
|
||||
/* For something that has a 'QString id' (IEditorFactory
|
||||
* or IExternalEditor), find the one matching a id. */
|
||||
template <class EditorFactoryLike>
|
||||
EditorFactoryLike *findById(Id id)
|
||||
{
|
||||
return ExtensionSystem::PluginManager::getObject<EditorFactoryLike>(
|
||||
[&id](EditorFactoryLike *efl) {
|
||||
return id == efl->id();
|
||||
});
|
||||
}
|
||||
|
||||
EditorManagerPrivate::EditorManagerPrivate(QObject *parent) :
|
||||
QObject(parent),
|
||||
m_revertToSavedAction(new QAction(EditorManager::tr("Revert to Saved"), this)),
|
||||
@@ -606,7 +595,9 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const QString &fileN
|
||||
return 0;
|
||||
}
|
||||
if (editorId.isValid()) {
|
||||
if (IEditorFactory *factory = findById<IEditorFactory>(editorId)) {
|
||||
IEditorFactory *factory = Utils::findOrDefault(IEditorFactory::allEditorFactories(),
|
||||
Utils::equal(&IEditorFactory::id, editorId));
|
||||
if (factory) {
|
||||
factories.removeOne(factory);
|
||||
factories.push_front(factory);
|
||||
}
|
||||
@@ -1139,7 +1130,9 @@ EditorManager::EditorFactoryList EditorManagerPrivate::findFactories(Id editorId
|
||||
factories = EditorManager::editorFactories(mimeType, false);
|
||||
} else {
|
||||
// Find by editor id
|
||||
if (IEditorFactory *factory = findById<IEditorFactory>(editorId))
|
||||
IEditorFactory *factory = Utils::findOrDefault(IEditorFactory::allEditorFactories(),
|
||||
Utils::equal(&IEditorFactory::id, editorId));
|
||||
if (factory)
|
||||
factories.push_back(factory);
|
||||
}
|
||||
if (factories.empty()) {
|
||||
@@ -2606,7 +2599,7 @@ EditorManager::EditorFactoryList
|
||||
EditorManager::editorFactories(const Utils::MimeType &mimeType, bool bestMatchOnly)
|
||||
{
|
||||
EditorFactoryList rc;
|
||||
const EditorFactoryList allFactories = ExtensionSystem::PluginManager::getObjects<IEditorFactory>();
|
||||
const EditorFactoryList allFactories = IEditorFactory::allEditorFactories();
|
||||
mimeTypeFactoryLookup(mimeType, allFactories, bestMatchOnly, &rc);
|
||||
if (debugEditorManager)
|
||||
qDebug() << Q_FUNC_INFO << mimeType.name() << " returns " << rc;
|
||||
@@ -2617,7 +2610,7 @@ EditorManager::ExternalEditorList
|
||||
EditorManager::externalEditors(const Utils::MimeType &mimeType, bool bestMatchOnly)
|
||||
{
|
||||
ExternalEditorList rc;
|
||||
const ExternalEditorList allEditors = ExtensionSystem::PluginManager::getObjects<IExternalEditor>();
|
||||
const ExternalEditorList allEditors = IExternalEditor::allExternalEditors();
|
||||
mimeTypeFactoryLookup(mimeType, allEditors, bestMatchOnly, &rc);
|
||||
if (debugEditorManager)
|
||||
qDebug() << Q_FUNC_INFO << mimeType.name() << " returns " << rc;
|
||||
@@ -2692,7 +2685,8 @@ bool EditorManager::isAutoSaveFile(const QString &fileName)
|
||||
|
||||
bool EditorManager::openExternalEditor(const QString &fileName, Id editorId)
|
||||
{
|
||||
IExternalEditor *ee = findById<IExternalEditor>(editorId);
|
||||
IExternalEditor *ee = Utils::findOrDefault(IExternalEditor::allExternalEditors(),
|
||||
Utils::equal(&IExternalEditor::id, editorId));
|
||||
if (!ee)
|
||||
return false;
|
||||
QString errorMessage;
|
||||
|
@@ -27,9 +27,24 @@
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
Core::IEditorFactory::IEditorFactory(QObject *parent)
|
||||
namespace Core {
|
||||
|
||||
static QList<IEditorFactory *> g_editorFactories;
|
||||
|
||||
IEditorFactory::IEditorFactory(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
|
||||
g_editorFactories.append(this);
|
||||
}
|
||||
|
||||
IEditorFactory::~IEditorFactory()
|
||||
{
|
||||
g_editorFactories.removeOne(this);
|
||||
}
|
||||
|
||||
const QList<IEditorFactory *> IEditorFactory::allEditorFactories()
|
||||
{
|
||||
return g_editorFactories;
|
||||
}
|
||||
|
||||
} // Core
|
||||
|
@@ -40,7 +40,11 @@ class CORE_EXPORT IEditorFactory : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IEditorFactory(QObject *parent = 0);
|
||||
IEditorFactory(QObject *parent = nullptr);
|
||||
~IEditorFactory();
|
||||
|
||||
static const QList<IEditorFactory *> allEditorFactories();
|
||||
|
||||
QString displayName() const { return m_displayName; }
|
||||
void setDisplayName(const QString &displayName) { m_displayName = displayName; }
|
||||
|
||||
|
@@ -25,6 +25,8 @@
|
||||
|
||||
#include "iexternaleditor.h"
|
||||
|
||||
namespace Core {
|
||||
|
||||
/*!
|
||||
\class Core::IExternalEditor
|
||||
\mainclass
|
||||
@@ -50,3 +52,23 @@
|
||||
Opens the editor with \a fileName. Returns \c true on success or \c false
|
||||
on failure along with the error in \a errorMessage.
|
||||
*/
|
||||
|
||||
static QList<IExternalEditor *> g_externalEditors;
|
||||
|
||||
IExternalEditor::IExternalEditor(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
g_externalEditors.append(this);
|
||||
}
|
||||
|
||||
IExternalEditor::~IExternalEditor()
|
||||
{
|
||||
g_externalEditors.removeOne(this);
|
||||
}
|
||||
|
||||
const QList<IExternalEditor *> IExternalEditor::allExternalEditors()
|
||||
{
|
||||
return g_externalEditors;
|
||||
}
|
||||
|
||||
} // Core
|
||||
|
@@ -38,7 +38,10 @@ class CORE_EXPORT IExternalEditor : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit IExternalEditor(QObject *parent = 0) : QObject(parent) {}
|
||||
explicit IExternalEditor(QObject *parent = nullptr);
|
||||
~IExternalEditor();
|
||||
|
||||
static const QList<IExternalEditor *> allExternalEditors();
|
||||
|
||||
virtual QStringList mimeTypes() const = 0;
|
||||
virtual Id id() const = 0;
|
||||
|
@@ -202,13 +202,12 @@ static QString filterActionName(const IFindFilter *filter)
|
||||
|
||||
void FindPrivate::setupFilterMenuItems()
|
||||
{
|
||||
QList<IFindFilter*> findInterfaces = ExtensionSystem::PluginManager::getObjects<IFindFilter>();
|
||||
Command *cmd;
|
||||
|
||||
ActionContainer *mfindadvanced = ActionManager::actionContainer(Constants::M_FIND_ADVANCED);
|
||||
bool haveEnabledFilters = false;
|
||||
const Id base("FindFilter.");
|
||||
QList<IFindFilter *> sortedFilters = findInterfaces;
|
||||
QList<IFindFilter *> sortedFilters = IFindFilter::allFindFilters();
|
||||
Utils::sort(sortedFilters, &IFindFilter::displayName);
|
||||
foreach (IFindFilter *filter, sortedFilters) {
|
||||
QAction *action = new QAction(filterActionName(filter), this);
|
||||
|
@@ -36,8 +36,6 @@
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/findplaceholder.h>
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/stylehelper.h>
|
||||
@@ -727,10 +725,10 @@ void FindToolBar::hideAndResetFocus()
|
||||
|
||||
FindToolBarPlaceHolder *FindToolBar::findToolBarPlaceHolder() const
|
||||
{
|
||||
QList<FindToolBarPlaceHolder*> placeholders = ExtensionSystem::PluginManager::getObjects<FindToolBarPlaceHolder>();
|
||||
const QList<FindToolBarPlaceHolder*> placeholders = FindToolBarPlaceHolder::allFindToolbarPlaceHolders();
|
||||
QWidget *candidate = QApplication::focusWidget();
|
||||
while (candidate) {
|
||||
foreach (FindToolBarPlaceHolder *ph, placeholders) {
|
||||
for (FindToolBarPlaceHolder *ph : placeholders) {
|
||||
if (ph->owner() == candidate)
|
||||
return ph;
|
||||
}
|
||||
|
@@ -227,6 +227,23 @@
|
||||
|
||||
namespace Core {
|
||||
|
||||
static QList<IFindFilter *> g_findFilters;
|
||||
|
||||
IFindFilter::IFindFilter()
|
||||
{
|
||||
g_findFilters.append(this);
|
||||
}
|
||||
|
||||
IFindFilter::~IFindFilter()
|
||||
{
|
||||
g_findFilters.removeOne(this);
|
||||
}
|
||||
|
||||
const QList<IFindFilter *> IFindFilter::allFindFilters()
|
||||
{
|
||||
return g_findFilters;
|
||||
}
|
||||
|
||||
QKeySequence IFindFilter::defaultShortcut() const
|
||||
{
|
||||
return QKeySequence();
|
||||
|
@@ -39,9 +39,12 @@ namespace Core {
|
||||
class CORE_EXPORT IFindFilter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
virtual ~IFindFilter() {}
|
||||
public:
|
||||
IFindFilter();
|
||||
virtual ~IFindFilter();
|
||||
|
||||
static const QList<IFindFilter *> allFindFilters();
|
||||
|
||||
virtual QString id() const = 0;
|
||||
virtual QString displayName() const = 0;
|
||||
|
@@ -26,26 +26,26 @@
|
||||
#include "findplaceholder.h"
|
||||
#include "find/findtoolbar.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
||||
using namespace Core;
|
||||
|
||||
FindToolBarPlaceHolder *FindToolBarPlaceHolder::m_current = 0;
|
||||
|
||||
static QList<FindToolBarPlaceHolder *> g_findToolBarPlaceHolders;
|
||||
|
||||
FindToolBarPlaceHolder::FindToolBarPlaceHolder(QWidget *owner, QWidget *parent)
|
||||
: QWidget(parent), m_owner(owner), m_subWidget(0), m_lightColored(false)
|
||||
{
|
||||
g_findToolBarPlaceHolders.append(this);
|
||||
setLayout(new QVBoxLayout);
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
|
||||
layout()->setMargin(0);
|
||||
ExtensionSystem::PluginManager::addObject(this);
|
||||
}
|
||||
|
||||
FindToolBarPlaceHolder::~FindToolBarPlaceHolder()
|
||||
{
|
||||
ExtensionSystem::PluginManager::removeObject(this);
|
||||
g_findToolBarPlaceHolders.removeOne(this);
|
||||
if (m_subWidget) {
|
||||
m_subWidget->setVisible(false);
|
||||
m_subWidget->setParent(0);
|
||||
@@ -54,6 +54,11 @@ FindToolBarPlaceHolder::~FindToolBarPlaceHolder()
|
||||
m_current = 0;
|
||||
}
|
||||
|
||||
const QList<FindToolBarPlaceHolder *> FindToolBarPlaceHolder::allFindToolbarPlaceHolders()
|
||||
{
|
||||
return g_findToolBarPlaceHolders;
|
||||
}
|
||||
|
||||
QWidget *FindToolBarPlaceHolder::owner() const
|
||||
{
|
||||
return m_owner;
|
||||
|
@@ -39,6 +39,9 @@ class CORE_EXPORT FindToolBarPlaceHolder : public QWidget
|
||||
public:
|
||||
explicit FindToolBarPlaceHolder(QWidget *owner, QWidget *parent = 0);
|
||||
~FindToolBarPlaceHolder();
|
||||
|
||||
static const QList<FindToolBarPlaceHolder *> allFindToolbarPlaceHolders();
|
||||
|
||||
QWidget *owner() const;
|
||||
bool isUsedByWidget(QWidget *widget);
|
||||
|
||||
|
@@ -29,6 +29,24 @@
|
||||
|
||||
namespace Core {
|
||||
|
||||
static QList<IDocumentFactory *> g_documentFactories;
|
||||
|
||||
IDocumentFactory::IDocumentFactory(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
g_documentFactories.append(this);
|
||||
}
|
||||
|
||||
IDocumentFactory::~IDocumentFactory()
|
||||
{
|
||||
g_documentFactories.removeOne(this);
|
||||
}
|
||||
|
||||
const QList<IDocumentFactory *> IDocumentFactory::allDocumentFactories()
|
||||
{
|
||||
return g_documentFactories;
|
||||
}
|
||||
|
||||
IDocument *IDocumentFactory::open(const QString &filename)
|
||||
{
|
||||
QTC_ASSERT(m_opener, return 0);
|
||||
|
@@ -41,7 +41,10 @@ class CORE_EXPORT IDocumentFactory : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IDocumentFactory(QObject *parent = 0) : QObject(parent) {}
|
||||
IDocumentFactory(QObject *parent = nullptr);
|
||||
~IDocumentFactory();
|
||||
|
||||
static const QList<IDocumentFactory *> allDocumentFactories();
|
||||
|
||||
typedef std::function<IDocument *(const QString &fileName)> Opener;
|
||||
IDocument *open(const QString &filename);
|
||||
|
@@ -48,6 +48,10 @@ class CORE_EXPORT IFileWizardExtension : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
IFileWizardExtension();
|
||||
~IFileWizardExtension();
|
||||
static QList<IFileWizardExtension *> allFileWizardExtensions();
|
||||
|
||||
/* Return a list of pages to be added to the Wizard (empty list if not
|
||||
* applicable). */
|
||||
virtual QList<QWizardPage *> extensionPages(const IWizardFactory *wizard) = 0;
|
||||
|
@@ -85,12 +85,25 @@
|
||||
|
||||
using namespace Core;
|
||||
|
||||
static QList<INavigationWidgetFactory *> g_navigationWidgetFactories;
|
||||
|
||||
/*!
|
||||
Creates a \l{Core::NavigationViewFactory}.
|
||||
*/
|
||||
INavigationWidgetFactory::INavigationWidgetFactory()
|
||||
: m_priority(0)
|
||||
{
|
||||
g_navigationWidgetFactories.append(this);
|
||||
}
|
||||
|
||||
INavigationWidgetFactory::~INavigationWidgetFactory()
|
||||
{
|
||||
g_navigationWidgetFactories.removeOne(this);
|
||||
}
|
||||
|
||||
const QList<INavigationWidgetFactory *> INavigationWidgetFactory::allNavigationFactories()
|
||||
{
|
||||
return g_navigationWidgetFactories;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@@ -53,6 +53,9 @@ class CORE_EXPORT INavigationWidgetFactory : public QObject
|
||||
|
||||
public:
|
||||
INavigationWidgetFactory();
|
||||
~INavigationWidgetFactory();
|
||||
|
||||
static const QList<INavigationWidgetFactory *> allNavigationFactories();
|
||||
|
||||
void setDisplayName(const QString &displayName);
|
||||
void setPriority(int priority);
|
||||
|
@@ -42,7 +42,8 @@ class CORE_EXPORT IOutputPane : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IOutputPane(QObject *parent = 0) : QObject(parent) {}
|
||||
IOutputPane(QObject *parent = nullptr);
|
||||
~IOutputPane();
|
||||
|
||||
virtual QWidget *outputWidget(QWidget *parent) = 0;
|
||||
virtual QList<QWidget *> toolBarWidgets() const = 0;
|
||||
|
@@ -41,12 +41,21 @@ using namespace Utils;
|
||||
|
||||
namespace Core {
|
||||
|
||||
static QList<IWelcomePage *> g_welcomePages;
|
||||
|
||||
const QList<IWelcomePage *> IWelcomePage::allWelcomePages()
|
||||
{
|
||||
return g_welcomePages;
|
||||
}
|
||||
|
||||
IWelcomePage::IWelcomePage()
|
||||
{
|
||||
g_welcomePages.append(this);
|
||||
}
|
||||
|
||||
IWelcomePage::~IWelcomePage()
|
||||
{
|
||||
g_welcomePages.removeOne(this);
|
||||
}
|
||||
|
||||
static QPalette buttonPalette(bool isActive, bool isCursorInside, bool forText)
|
||||
|
@@ -55,6 +55,8 @@ public:
|
||||
virtual int priority() const { return 0; }
|
||||
virtual Core::Id id() const = 0;
|
||||
virtual QWidget *createWidget() const = 0;
|
||||
|
||||
static const QList<IWelcomePage *> allWelcomePages();
|
||||
};
|
||||
|
||||
class WelcomePageButtonPrivate;
|
||||
|
@@ -48,12 +48,25 @@ using namespace Core;
|
||||
The filter is added to \uicontrol Tools > \uicontrol Locate.
|
||||
*/
|
||||
|
||||
static QList<ILocatorFilter *> g_locatorFilters;
|
||||
|
||||
/*!
|
||||
Constructs a locator filter with \a parent. Call from subclasses.
|
||||
*/
|
||||
ILocatorFilter::ILocatorFilter(QObject *parent):
|
||||
QObject(parent)
|
||||
{
|
||||
g_locatorFilters.append(this);
|
||||
}
|
||||
|
||||
ILocatorFilter::~ILocatorFilter()
|
||||
{
|
||||
g_locatorFilters.removeOne(this);
|
||||
}
|
||||
|
||||
const QList<ILocatorFilter *> ILocatorFilter::allLocatorFilters()
|
||||
{
|
||||
return g_locatorFilters;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@@ -107,8 +107,10 @@ class CORE_EXPORT ILocatorFilter : public QObject
|
||||
public:
|
||||
enum Priority {Highest = 0, High = 1, Medium = 2, Low = 3};
|
||||
|
||||
ILocatorFilter(QObject *parent = 0);
|
||||
virtual ~ILocatorFilter() {}
|
||||
ILocatorFilter(QObject *parent = nullptr);
|
||||
virtual ~ILocatorFilter();
|
||||
|
||||
static const QList<ILocatorFilter *> allLocatorFilters();
|
||||
|
||||
Id id() const;
|
||||
Id actionId() const;
|
||||
|
@@ -139,7 +139,7 @@ void Locator::initialize(CorePlugin *corePlugin, const QStringList &, QString *)
|
||||
|
||||
void Locator::extensionsInitialized()
|
||||
{
|
||||
m_filters = ExtensionSystem::PluginManager::getObjects<ILocatorFilter>();
|
||||
m_filters = ILocatorFilter::allLocatorFilters();
|
||||
Utils::sort(m_filters, [](const ILocatorFilter *first, const ILocatorFilter *second) -> bool {
|
||||
if (first->priority() != second->priority())
|
||||
return first->priority() < second->priority();
|
||||
|
@@ -341,8 +341,8 @@ void MainWindow::extensionsInitialized()
|
||||
m_statusBarManager->extensionsInitalized();
|
||||
OutputPaneManager::instance()->init();
|
||||
m_vcsManager->extensionsInitialized();
|
||||
m_leftNavigationWidget->setFactories(PluginManager::getObjects<INavigationWidgetFactory>());
|
||||
m_rightNavigationWidget->setFactories(PluginManager::getObjects<INavigationWidgetFactory>());
|
||||
m_leftNavigationWidget->setFactories(INavigationWidgetFactory::allNavigationFactories());
|
||||
m_rightNavigationWidget->setFactories(INavigationWidgetFactory::allNavigationFactories());
|
||||
|
||||
readSettings();
|
||||
updateContext();
|
||||
@@ -808,7 +808,7 @@ IDocument *MainWindow::openFiles(const QStringList &fileNames,
|
||||
ICore::OpenFilesFlags flags,
|
||||
const QString &workingDirectory)
|
||||
{
|
||||
QList<IDocumentFactory*> documentFactories = PluginManager::getObjects<IDocumentFactory>();
|
||||
const QList<IDocumentFactory*> documentFactories = IDocumentFactory::allDocumentFactories();
|
||||
IDocument *res = nullptr;
|
||||
|
||||
foreach (const QString &fileName, fileNames) {
|
||||
|
@@ -37,8 +37,6 @@
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/styledbar.h>
|
||||
@@ -66,6 +64,22 @@
|
||||
using namespace Utils;
|
||||
|
||||
namespace Core {
|
||||
|
||||
// OutputPane
|
||||
|
||||
static QList<IOutputPane *> g_outputPanes;
|
||||
|
||||
IOutputPane::IOutputPane(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
g_outputPanes.append(this);
|
||||
}
|
||||
|
||||
IOutputPane::~IOutputPane()
|
||||
{
|
||||
g_outputPanes.removeOne(this);
|
||||
}
|
||||
|
||||
namespace Internal {
|
||||
|
||||
static char outputPaneSettingsKeyC[] = "OutputPaneVisibility";
|
||||
@@ -256,7 +270,7 @@ void OutputPaneManager::init()
|
||||
QFontMetrics titleFm = m_titleLabel->fontMetrics();
|
||||
int minTitleWidth = 0;
|
||||
|
||||
m_panes = ExtensionSystem::PluginManager::getObjects<IOutputPane>();
|
||||
m_panes = g_outputPanes;
|
||||
Utils::sort(m_panes, [](IOutputPane *p1, IOutputPane *p2) {
|
||||
return p1->priorityInStatusBar() > p2->priorityInStatusBar();
|
||||
});
|
||||
|
@@ -49,8 +49,6 @@ class CPPEDITOR_EXPORT CppQuickFixFactory: public TextEditor::QuickFixFactory
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CppQuickFixFactory() {}
|
||||
|
||||
void matchingOperations(const TextEditor::QuickFixInterface &interface,
|
||||
TextEditor::QuickFixOperations &result);
|
||||
|
||||
|
@@ -34,7 +34,7 @@
|
||||
|
||||
#include <cplusplus/ASTPath.h>
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
using namespace TextEditor;
|
||||
@@ -59,10 +59,9 @@ IAssistProcessor *CppQuickFixAssistProvider::createProcessor() const
|
||||
|
||||
QList<QuickFixFactory *> CppQuickFixAssistProvider::quickFixFactories() const
|
||||
{
|
||||
QList<QuickFixFactory *> results;
|
||||
foreach (CppQuickFixFactory *f, ExtensionSystem::PluginManager::getObjects<CppQuickFixFactory>())
|
||||
results.append(f);
|
||||
return results;
|
||||
return Utils::filtered(QuickFixFactory::allQuickFixFactories(), [](QuickFixFactory *f) {
|
||||
return qobject_cast<CppQuickFixFactory *>(f) != nullptr;
|
||||
});
|
||||
}
|
||||
|
||||
// --------------------------
|
||||
|
@@ -41,7 +41,6 @@
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <texteditor/textdocument.h>
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <cplusplus/CppDocument.h>
|
||||
#include <cplusplus/TranslationUnit.h>
|
||||
#include <utils/algorithm.h>
|
||||
@@ -448,25 +447,22 @@ void RunAllQuickFixesTokenAction::run(CppEditorWidget *editorWidget)
|
||||
// Calling editorWidget->invokeAssist(QuickFix) would be not enough
|
||||
// since we also want to execute the ones that match.
|
||||
|
||||
const QList<CppQuickFixFactory *> quickFixFactories
|
||||
= ExtensionSystem::PluginManager::getObjects<CppQuickFixFactory>();
|
||||
QVERIFY(!quickFixFactories.isEmpty());
|
||||
|
||||
CppQuickFixInterface qfi(editorWidget, ExplicitlyInvoked);
|
||||
// This guard is important since the Quick Fixes expect to get a non-empty path().
|
||||
if (qfi.path().isEmpty())
|
||||
return;
|
||||
|
||||
foreach (CppQuickFixFactory *quickFixFactory, quickFixFactories) {
|
||||
for (QuickFixFactory *quickFixFactory : QuickFixFactory::allQuickFixFactories()) {
|
||||
if (auto cppQuickFixFactory = qobject_cast<CppQuickFixFactory *>(quickFixFactory)) {
|
||||
QuickFixOperations operations;
|
||||
// Some Quick Fixes pop up a dialog and are therefore inappropriate for this test.
|
||||
// Where possible, use a guiless version of the factory.
|
||||
if (qobject_cast<InsertVirtualMethods *>(quickFixFactory)) {
|
||||
if (qobject_cast<InsertVirtualMethods *>(cppQuickFixFactory)) {
|
||||
QScopedPointer<CppQuickFixFactory> factoryProducingGuiLessOperations;
|
||||
factoryProducingGuiLessOperations.reset(InsertVirtualMethods::createTestFactory());
|
||||
factoryProducingGuiLessOperations->match(qfi, operations);
|
||||
} else {
|
||||
quickFixFactory->match(qfi, operations);
|
||||
cppQuickFixFactory->match(qfi, operations);
|
||||
}
|
||||
|
||||
foreach (QuickFixOperation::Ptr operation, operations) {
|
||||
@@ -477,6 +473,7 @@ void RunAllQuickFixesTokenAction::run(CppEditorWidget *editorWidget)
|
||||
QApplication::processEvents();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SwitchHeaderSourceFileAction : public TestActionsTestCase::AbstractAction
|
||||
|
@@ -123,10 +123,7 @@ TextEditor::Indenter *CppCodeStylePreferencesFactory::createIndenter() const
|
||||
|
||||
TextEditor::SnippetProvider *CppCodeStylePreferencesFactory::snippetProvider() const
|
||||
{
|
||||
return ExtensionSystem::PluginManager::getObject<TextEditor::SnippetProvider>(
|
||||
[](TextEditor::SnippetProvider *provider) {
|
||||
return provider->groupId() == QLatin1String(CppEditor::Constants::CPP_SNIPPETS_GROUP_ID);
|
||||
});
|
||||
return TextEditor::SnippetProvider::snippetProviderForGroupId(CppEditor::Constants::CPP_SNIPPETS_GROUP_ID);
|
||||
}
|
||||
|
||||
QString CppCodeStylePreferencesFactory::previewText() const
|
||||
|
@@ -493,10 +493,8 @@ void CppCodeStylePreferencesWidget::updatePreview()
|
||||
|
||||
void CppCodeStylePreferencesWidget::decorateEditors(const FontSettings &fontSettings)
|
||||
{
|
||||
const SnippetProvider *provider = ExtensionSystem::PluginManager::getObject<SnippetProvider>(
|
||||
[](SnippetProvider *current) {
|
||||
return current->groupId() == QLatin1String(CppEditor::Constants::CPP_SNIPPETS_GROUP_ID);
|
||||
});
|
||||
const SnippetProvider *provider =
|
||||
SnippetProvider::snippetProviderForGroupId(CppEditor::Constants::CPP_SNIPPETS_GROUP_ID);
|
||||
|
||||
foreach (SnippetEditorWidget *editor, m_previews) {
|
||||
editor->textDocument()->setFontSettings(fontSettings);
|
||||
|
@@ -30,13 +30,15 @@
|
||||
#include "../editor/nimindenter.h"
|
||||
|
||||
#include <coreplugin/id.h>
|
||||
|
||||
#include <texteditor/simplecodestylepreferences.h>
|
||||
#include <texteditor/snippets/snippetprovider.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLayout>
|
||||
|
||||
using namespace TextEditor;
|
||||
|
||||
namespace Nim {
|
||||
|
||||
NimCodeStylePreferencesFactory::NimCodeStylePreferencesFactory()
|
||||
@@ -71,12 +73,9 @@ TextEditor::Indenter *NimCodeStylePreferencesFactory::createIndenter() const
|
||||
return new NimIndenter();
|
||||
}
|
||||
|
||||
TextEditor::SnippetProvider *NimCodeStylePreferencesFactory::snippetProvider() const
|
||||
SnippetProvider *NimCodeStylePreferencesFactory::snippetProvider() const
|
||||
{
|
||||
return ExtensionSystem::PluginManager::getObject<TextEditor::SnippetProvider>(
|
||||
[](TextEditor::SnippetProvider *provider) {
|
||||
return provider->groupId() == Nim::Constants::C_NIMSNIPPETSGROUP_ID;
|
||||
});
|
||||
return SnippetProvider::snippetProviderForGroupId(Nim::Constants::C_NIMSNIPPETSGROUP_ID);
|
||||
}
|
||||
|
||||
QString NimCodeStylePreferencesFactory::previewText() const
|
||||
|
@@ -38,7 +38,7 @@
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/projectmacroexpander.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <coreplugin/idocument.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -318,6 +318,18 @@ void BuildConfiguration::prependCompilerPathToEnvironment(Kit *k, Utils::Environ
|
||||
// IBuildConfigurationFactory
|
||||
///
|
||||
|
||||
static QList<IBuildConfigurationFactory *> g_buildConfigurationFactories;
|
||||
|
||||
IBuildConfigurationFactory::IBuildConfigurationFactory()
|
||||
{
|
||||
g_buildConfigurationFactories.append(this);
|
||||
}
|
||||
|
||||
IBuildConfigurationFactory::~IBuildConfigurationFactory()
|
||||
{
|
||||
g_buildConfigurationFactories.removeOne(this);
|
||||
}
|
||||
|
||||
int IBuildConfigurationFactory::priority(const Target *parent) const
|
||||
{
|
||||
return canHandle(parent) ? 0 : -1;
|
||||
@@ -334,32 +346,26 @@ int IBuildConfigurationFactory::priority(const Kit *k, const QString &projectPat
|
||||
// restore
|
||||
IBuildConfigurationFactory *IBuildConfigurationFactory::find(Target *parent, const QVariantMap &map)
|
||||
{
|
||||
QList<IBuildConfigurationFactory *> factories
|
||||
= ExtensionSystem::PluginManager::getObjects<IBuildConfigurationFactory>(
|
||||
[&parent, map](IBuildConfigurationFactory *factory) {
|
||||
return factory->canRestore(parent, map);
|
||||
});
|
||||
|
||||
IBuildConfigurationFactory *factory = 0;
|
||||
int priority = -1;
|
||||
foreach (IBuildConfigurationFactory *i, factories) {
|
||||
for (IBuildConfigurationFactory *i : g_buildConfigurationFactories) {
|
||||
if (i->canRestore(parent, map)) {
|
||||
int iPriority = i->priority(parent);
|
||||
if (iPriority > priority) {
|
||||
factory = i;
|
||||
priority = iPriority;
|
||||
}
|
||||
}
|
||||
}
|
||||
return factory;
|
||||
}
|
||||
|
||||
// setup
|
||||
IBuildConfigurationFactory *IBuildConfigurationFactory::find(const Kit *k, const QString &projectPath)
|
||||
{
|
||||
QList<IBuildConfigurationFactory *> factories
|
||||
= ExtensionSystem::PluginManager::instance()->getObjects<IBuildConfigurationFactory>();
|
||||
IBuildConfigurationFactory *factory = 0;
|
||||
int priority = -1;
|
||||
foreach (IBuildConfigurationFactory *i, factories) {
|
||||
for (IBuildConfigurationFactory *i : g_buildConfigurationFactories) {
|
||||
int iPriority = i->priority(k, projectPath);
|
||||
if (iPriority > priority) {
|
||||
factory = i;
|
||||
@@ -372,11 +378,9 @@ IBuildConfigurationFactory *IBuildConfigurationFactory::find(const Kit *k, const
|
||||
// create
|
||||
IBuildConfigurationFactory * IBuildConfigurationFactory::find(Target *parent)
|
||||
{
|
||||
QList<IBuildConfigurationFactory *> factories
|
||||
= ExtensionSystem::PluginManager::instance()->getObjects<IBuildConfigurationFactory>();
|
||||
IBuildConfigurationFactory *factory = 0;
|
||||
int priority = -1;
|
||||
foreach (IBuildConfigurationFactory *i, factories) {
|
||||
for (IBuildConfigurationFactory *i : g_buildConfigurationFactories) {
|
||||
int iPriority = i->priority(parent);
|
||||
if (iPriority > priority) {
|
||||
factory = i;
|
||||
@@ -389,21 +393,17 @@ IBuildConfigurationFactory * IBuildConfigurationFactory::find(Target *parent)
|
||||
// clone
|
||||
IBuildConfigurationFactory *IBuildConfigurationFactory::find(Target *parent, BuildConfiguration *bc)
|
||||
{
|
||||
QList<IBuildConfigurationFactory *> factories
|
||||
= ExtensionSystem::PluginManager::getObjects<IBuildConfigurationFactory>(
|
||||
[&parent, &bc](IBuildConfigurationFactory *factory) {
|
||||
return factory->canClone(parent, bc);
|
||||
});
|
||||
|
||||
IBuildConfigurationFactory *factory = 0;
|
||||
int priority = -1;
|
||||
foreach (IBuildConfigurationFactory *i, factories) {
|
||||
for (IBuildConfigurationFactory *i : g_buildConfigurationFactories) {
|
||||
if (i->canClone(parent, bc)) {
|
||||
int iPriority = i->priority(parent);
|
||||
if (iPriority > priority) {
|
||||
factory = i;
|
||||
priority = iPriority;
|
||||
}
|
||||
}
|
||||
}
|
||||
return factory;
|
||||
}
|
||||
|
||||
|
@@ -121,7 +121,8 @@ class PROJECTEXPLORER_EXPORT IBuildConfigurationFactory : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
protected:
|
||||
IBuildConfigurationFactory() = default;
|
||||
IBuildConfigurationFactory();
|
||||
~IBuildConfigurationFactory();
|
||||
|
||||
public:
|
||||
// The priority is negative if this factory can not create anything for the target.
|
||||
|
@@ -114,6 +114,8 @@ static const char buildStepEnabledKey[] = "ProjectExplorer.BuildStep.Enabled";
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
static QList<BuildStepFactory *> g_buildStepFactories;
|
||||
|
||||
BuildStep::BuildStep(BuildStepList *bsl, Core::Id id) :
|
||||
ProjectConfiguration(bsl, id)
|
||||
{
|
||||
@@ -213,7 +215,19 @@ bool BuildStep::enabled() const
|
||||
}
|
||||
|
||||
BuildStepFactory::BuildStepFactory()
|
||||
{ }
|
||||
{
|
||||
g_buildStepFactories.append(this);
|
||||
}
|
||||
|
||||
BuildStepFactory::~BuildStepFactory()
|
||||
{
|
||||
g_buildStepFactories.removeOne(this);
|
||||
}
|
||||
|
||||
const QList<BuildStepFactory *> BuildStepFactory::allBuildStepFactories()
|
||||
{
|
||||
return g_buildStepFactories;
|
||||
}
|
||||
|
||||
bool BuildStepFactory::canHandle(BuildStepList *bsl) const
|
||||
{
|
||||
|
@@ -124,6 +124,9 @@ class PROJECTEXPLORER_EXPORT BuildStepFactory : public QObject
|
||||
|
||||
public:
|
||||
BuildStepFactory();
|
||||
~BuildStepFactory();
|
||||
|
||||
static const QList<BuildStepFactory *> allBuildStepFactories();
|
||||
|
||||
BuildStepInfo stepInfo() const;
|
||||
Core::Id stepId() const;
|
||||
|
@@ -32,7 +32,6 @@
|
||||
#include "projectexplorer.h"
|
||||
#include "target.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
@@ -108,8 +107,7 @@ bool BuildStepList::fromMap(const QVariantMap &map)
|
||||
if (!ProjectConfiguration::fromMap(map))
|
||||
return false;
|
||||
|
||||
const QList<BuildStepFactory *> factories
|
||||
= ExtensionSystem::PluginManager::getObjects<BuildStepFactory>();
|
||||
const QList<BuildStepFactory *> factories = BuildStepFactory::allBuildStepFactories();
|
||||
|
||||
int maxSteps = map.value(QString::fromLatin1(STEPS_COUNT_KEY), 0).toInt();
|
||||
for (int i = 0; i < maxSteps; ++i) {
|
||||
|
@@ -32,7 +32,7 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/coreicons.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/detailswidget.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
@@ -288,8 +288,7 @@ void BuildStepListWidget::updateAddBuildStepMenu()
|
||||
{
|
||||
QMap<QString, QPair<Core::Id, BuildStepFactory *> > map;
|
||||
//Build up a list of possible steps and save map the display names to the (internal) name and factories.
|
||||
QList<BuildStepFactory *> factories = ExtensionSystem::PluginManager::getObjects<BuildStepFactory>();
|
||||
foreach (BuildStepFactory *factory, factories) {
|
||||
for (BuildStepFactory *factory : BuildStepFactory::allBuildStepFactories()) {
|
||||
if (factory->canHandle(m_buildStepList)) {
|
||||
const BuildStepInfo &info = factory->stepInfo();
|
||||
if (info.flags & BuildStepInfo::Uncreatable)
|
||||
|
@@ -65,6 +65,19 @@ bool enableLoadTemplateFiles()
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
static QList<ICustomWizardMetaFactory *> g_customWizardMetaFactories;
|
||||
|
||||
ICustomWizardMetaFactory::ICustomWizardMetaFactory(const QString &klass, Core::IWizardFactory::WizardKind kind) :
|
||||
m_klass(klass), m_kind(kind)
|
||||
{
|
||||
g_customWizardMetaFactories.append(this);
|
||||
}
|
||||
|
||||
ICustomWizardMetaFactory::~ICustomWizardMetaFactory()
|
||||
{
|
||||
g_customWizardMetaFactories.removeOne(this);
|
||||
}
|
||||
|
||||
namespace Internal {
|
||||
/*!
|
||||
\class ProjectExplorer::ICustomWizardFactory
|
||||
@@ -338,7 +351,7 @@ CustomWizard::CustomWizardContextPtr CustomWizard::context() const
|
||||
|
||||
CustomWizard *CustomWizard::createWizard(const CustomProjectWizard::CustomWizardParametersPtr &p)
|
||||
{
|
||||
ICustomWizardMetaFactory *factory = ExtensionSystem::PluginManager::getObject<ICustomWizardMetaFactory>(
|
||||
ICustomWizardMetaFactory *factory = Utils::findOrDefault(g_customWizardMetaFactories,
|
||||
[&p](ICustomWizardMetaFactory *factory) {
|
||||
return p->klass.isEmpty() ? (p->kind == factory->kind()) : (p->klass == factory->klass());
|
||||
});
|
||||
|
@@ -55,9 +55,8 @@ class PROJECTEXPLORER_EXPORT ICustomWizardMetaFactory : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ICustomWizardMetaFactory(const QString &klass, Core::IWizardFactory::WizardKind kind) :
|
||||
m_klass(klass), m_kind(kind)
|
||||
{ }
|
||||
ICustomWizardMetaFactory(const QString &klass, Core::IWizardFactory::WizardKind kind);
|
||||
~ICustomWizardMetaFactory();
|
||||
|
||||
virtual CustomWizard *create() const = 0;
|
||||
QString klass() const { return m_klass; }
|
||||
|
@@ -32,8 +32,6 @@
|
||||
#include "projectexplorer.h"
|
||||
#include "target.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
@@ -142,9 +140,22 @@ bool DeployConfiguration::isActive() const
|
||||
// DeployConfigurationFactory
|
||||
///
|
||||
|
||||
static QList<DeployConfigurationFactory *> g_deployConfigurationFactories;
|
||||
|
||||
DeployConfigurationFactory::DeployConfigurationFactory()
|
||||
{
|
||||
setObjectName("DeployConfigurationFactory");
|
||||
g_deployConfigurationFactories.append(this);
|
||||
}
|
||||
|
||||
DeployConfigurationFactory::~DeployConfigurationFactory()
|
||||
{
|
||||
g_deployConfigurationFactories.removeOne(this);
|
||||
}
|
||||
|
||||
QList<DeployConfigurationFactory *> DeployConfigurationFactory::allDeployConfigurationFactories()
|
||||
{
|
||||
return g_deployConfigurationFactories;
|
||||
}
|
||||
|
||||
QList<Core::Id> DeployConfigurationFactory::availableCreationIds(Target *parent) const
|
||||
@@ -256,7 +267,7 @@ bool DeployConfigurationFactory::canRestore(Target *parent, const QVariantMap &m
|
||||
|
||||
DeployConfigurationFactory *DeployConfigurationFactory::find(Target *parent, const QVariantMap &map)
|
||||
{
|
||||
return ExtensionSystem::PluginManager::getObject<DeployConfigurationFactory>(
|
||||
return Utils::findOrDefault(g_deployConfigurationFactories,
|
||||
[&parent, &map](DeployConfigurationFactory *factory) {
|
||||
return factory->canRestore(parent, map);
|
||||
});
|
||||
@@ -264,7 +275,7 @@ DeployConfigurationFactory *DeployConfigurationFactory::find(Target *parent, con
|
||||
|
||||
QList<DeployConfigurationFactory *> DeployConfigurationFactory::find(Target *parent)
|
||||
{
|
||||
return ExtensionSystem::PluginManager::getObjects<DeployConfigurationFactory>(
|
||||
return Utils::filtered(g_deployConfigurationFactories,
|
||||
[&parent](DeployConfigurationFactory *factory) {
|
||||
return !factory->availableCreationIds(parent).isEmpty();
|
||||
});
|
||||
@@ -272,7 +283,7 @@ QList<DeployConfigurationFactory *> DeployConfigurationFactory::find(Target *par
|
||||
|
||||
DeployConfigurationFactory *DeployConfigurationFactory::find(Target *parent, DeployConfiguration *dc)
|
||||
{
|
||||
return ExtensionSystem::PluginManager::getObject<DeployConfigurationFactory>(
|
||||
return Utils::findOrDefault(g_deployConfigurationFactories,
|
||||
[&parent, &dc](DeployConfigurationFactory *factory) {
|
||||
return factory->canClone(parent, dc);
|
||||
});
|
||||
|
@@ -78,6 +78,9 @@ class PROJECTEXPLORER_EXPORT DeployConfigurationFactory : public QObject
|
||||
|
||||
public:
|
||||
DeployConfigurationFactory();
|
||||
~DeployConfigurationFactory();
|
||||
|
||||
static QList<DeployConfigurationFactory *> allDeployConfigurationFactories();
|
||||
|
||||
// used to show the list of possible additons to a target, returns a list of types
|
||||
QList<Core::Id> availableCreationIds(Target *parent) const;
|
||||
|
@@ -31,8 +31,6 @@
|
||||
|
||||
#include <coreplugin/id.h>
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
@@ -44,9 +42,7 @@ DeviceFactorySelectionDialog::DeviceFactorySelectionDialog(QWidget *parent) :
|
||||
ui->setupUi(this);
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Start Wizard"));
|
||||
|
||||
const QList<IDeviceFactory *> &factories
|
||||
= ExtensionSystem::PluginManager::getObjects<IDeviceFactory>();
|
||||
foreach (const IDeviceFactory * const factory, factories) {
|
||||
for (const IDeviceFactory * const factory : IDeviceFactory::allDeviceFactories()) {
|
||||
if (!factory->canCreate())
|
||||
continue;
|
||||
foreach (Core::Id id, factory->availableCreationIds()) {
|
||||
|
@@ -29,7 +29,7 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <ssh/sshhostkeydatabase.h>
|
||||
@@ -338,7 +338,7 @@ void DeviceManager::setDefaultDevice(Core::Id id)
|
||||
|
||||
const IDeviceFactory *DeviceManager::restoreFactory(const QVariantMap &map)
|
||||
{
|
||||
IDeviceFactory *factory = ExtensionSystem::PluginManager::getObject<IDeviceFactory>(
|
||||
IDeviceFactory *factory = Utils::findOrDefault(IDeviceFactory::allDeviceFactories(),
|
||||
[&map](IDeviceFactory *factory) {
|
||||
return factory->canRestore(map);
|
||||
});
|
||||
|
@@ -38,7 +38,7 @@
|
||||
#include <projectexplorer/projectexplorericons.h>
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
@@ -111,10 +111,8 @@ void DeviceSettingsWidget::initGui()
|
||||
m_ui->configurationComboBox->setModel(m_deviceManagerModel);
|
||||
m_ui->nameLineEdit->setValidator(m_nameValidator);
|
||||
|
||||
const QList<IDeviceFactory *> &factories
|
||||
= ExtensionSystem::PluginManager::getObjects<IDeviceFactory>();
|
||||
|
||||
bool hasDeviceFactories = Utils::anyOf(factories, &IDeviceFactory::canCreate);
|
||||
bool hasDeviceFactories = Utils::anyOf(IDeviceFactory::allDeviceFactories(),
|
||||
&IDeviceFactory::canCreate);
|
||||
|
||||
m_ui->addConfigButton->setEnabled(hasDeviceFactories);
|
||||
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "idevicefactory.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
@@ -83,15 +83,29 @@ bool IDeviceFactory::canCreate() const
|
||||
return !availableCreationIds().isEmpty();
|
||||
}
|
||||
|
||||
static QList<IDeviceFactory *> g_deviceFactories;
|
||||
|
||||
IDeviceFactory *IDeviceFactory::find(Core::Id type)
|
||||
{
|
||||
return ExtensionSystem::PluginManager::getObject<IDeviceFactory>(
|
||||
return Utils::findOrDefault(g_deviceFactories,
|
||||
[&type](IDeviceFactory *factory) {
|
||||
return factory->availableCreationIds().contains(type);
|
||||
});
|
||||
}
|
||||
|
||||
IDeviceFactory::IDeviceFactory(QObject *parent) : QObject(parent)
|
||||
{ }
|
||||
{
|
||||
g_deviceFactories.append(this);
|
||||
}
|
||||
|
||||
IDeviceFactory::~IDeviceFactory()
|
||||
{
|
||||
g_deviceFactories.removeOne(this);
|
||||
}
|
||||
|
||||
const QList<IDeviceFactory *> IDeviceFactory::allDeviceFactories()
|
||||
{
|
||||
return g_deviceFactories;
|
||||
}
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
@@ -44,6 +44,8 @@ class PROJECTEXPLORER_EXPORT IDeviceFactory : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
~IDeviceFactory();
|
||||
static const QList<IDeviceFactory *> allDeviceFactories();
|
||||
|
||||
virtual QString displayNameForId(Core::Id type) const = 0;
|
||||
|
||||
|
@@ -34,7 +34,11 @@ namespace ProjectExplorer {
|
||||
class PROJECTEXPLORER_EXPORT IPotentialKit : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IPotentialKit();
|
||||
~IPotentialKit() override;
|
||||
|
||||
virtual QString displayName() const = 0;
|
||||
virtual void executeFromMenu() = 0;
|
||||
virtual QWidget *createWidget(QWidget *parent) const = 0;
|
||||
|
@@ -44,7 +44,8 @@ class PROJECTEXPLORER_EXPORT ITaskHandler : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
virtual ~ITaskHandler() { }
|
||||
ITaskHandler();
|
||||
~ITaskHandler() override;
|
||||
|
||||
virtual bool isDefaultHandler() const { return false; }
|
||||
virtual bool canHandle(const Task &) const = 0;
|
||||
|
@@ -32,8 +32,6 @@
|
||||
#include "osparser.h"
|
||||
#include "projectexplorerconstants.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/icon.h>
|
||||
@@ -369,7 +367,7 @@ Id Kit::id() const
|
||||
|
||||
static QIcon iconForDeviceType(Core::Id deviceType)
|
||||
{
|
||||
const IDeviceFactory *factory = ExtensionSystem::PluginManager::getObject<IDeviceFactory>(
|
||||
const IDeviceFactory *factory = Utils::findOrDefault(IDeviceFactory::allDeviceFactories(),
|
||||
[&deviceType](const IDeviceFactory *factory) {
|
||||
return factory->availableCreationIds().contains(deviceType);
|
||||
});
|
||||
|
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "kitinformation.h"
|
||||
|
||||
#include "abi.h"
|
||||
#include "devicesupport/desktopdevice.h"
|
||||
#include "devicesupport/devicemanager.h"
|
||||
#include "projectexplorerconstants.h"
|
||||
@@ -33,8 +34,6 @@
|
||||
#include "toolchain.h"
|
||||
#include "toolchainmanager.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <projectexplorer/abi.h>
|
||||
#include <ssh/sshconnection.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
@@ -566,7 +565,7 @@ KitInformation::ItemList DeviceTypeKitInformation::toUserOutput(const Kit *k) co
|
||||
Core::Id type = deviceTypeId(k);
|
||||
QString typeDisplayName = tr("Unknown device type");
|
||||
if (type.isValid()) {
|
||||
IDeviceFactory *factory = ExtensionSystem::PluginManager::getObject<IDeviceFactory>(
|
||||
IDeviceFactory *factory = Utils::findOrDefault(IDeviceFactory::allDeviceFactories(),
|
||||
[&type](IDeviceFactory *factory) {
|
||||
return factory->availableCreationIds().contains(type);
|
||||
});
|
||||
|
@@ -37,7 +37,7 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/variablechooser.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fancylineedit.h>
|
||||
#include <utils/environment.h>
|
||||
@@ -261,9 +261,7 @@ int ToolChainInformationConfigWidget::indexOf(QComboBox *cb, const ToolChain *tc
|
||||
DeviceTypeInformationConfigWidget::DeviceTypeInformationConfigWidget(Kit *workingCopy, const KitInformation *ki) :
|
||||
KitConfigWidget(workingCopy, ki), m_comboBox(new QComboBox)
|
||||
{
|
||||
QList<IDeviceFactory *> factories
|
||||
= ExtensionSystem::PluginManager::getObjects<IDeviceFactory>();
|
||||
foreach (IDeviceFactory *factory, factories) {
|
||||
for (IDeviceFactory *factory : IDeviceFactory::allDeviceFactories()) {
|
||||
foreach (Id id, factory->availableCreationIds())
|
||||
m_comboBox->addItem(factory->displayNameForId(id), id.toSetting());
|
||||
}
|
||||
|
@@ -34,8 +34,6 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <utils/persistentsettings.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/stringutils.h>
|
||||
@@ -560,7 +558,7 @@ QSet<Id> KitFeatureProvider::availablePlatforms() const
|
||||
|
||||
QString KitFeatureProvider::displayNameForPlatform(Id id) const
|
||||
{
|
||||
foreach (IDeviceFactory *f, ExtensionSystem::PluginManager::getObjects<IDeviceFactory>()) {
|
||||
for (IDeviceFactory *f : IDeviceFactory::allDeviceFactories()) {
|
||||
if (f->availableCreationIds().contains(id)) {
|
||||
const QString dn = f->displayNameForId(id);
|
||||
QTC_ASSERT(!dn.isEmpty(), continue);
|
||||
|
@@ -37,8 +37,6 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -374,11 +372,9 @@ bool ProjectImporter::hasKitWithTemporaryData(Core::Id id, const QVariant &data)
|
||||
static ProjectImporter::ToolChainData
|
||||
createToolChains(const Utils::FileName &toolChainPath, const Core::Id &language)
|
||||
{
|
||||
const QList<ToolChainFactory *> factories
|
||||
= ExtensionSystem::PluginManager::getObjects<ToolChainFactory>();
|
||||
ProjectImporter::ToolChainData data;
|
||||
|
||||
for (ToolChainFactory *factory : factories) {
|
||||
for (ToolChainFactory *factory : ToolChainFactory::allToolChainFactories()) {
|
||||
data.tcs = factory->autoDetect(toolChainPath, language);
|
||||
if (data.tcs.isEmpty())
|
||||
continue;
|
||||
|
@@ -36,8 +36,6 @@
|
||||
#include "session.h"
|
||||
#include "kitinformation.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/checkablemessagebox.h>
|
||||
#include <utils/outputformatter.h>
|
||||
@@ -432,9 +430,22 @@ Utils::OutputFormatter *RunConfiguration::createOutputFormatter() const
|
||||
Translates the types to names to display to the user.
|
||||
*/
|
||||
|
||||
static QList<IRunConfigurationFactory *> g_runConfigurationFactories;
|
||||
|
||||
IRunConfigurationFactory::IRunConfigurationFactory(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
g_runConfigurationFactories.append(this);
|
||||
}
|
||||
|
||||
IRunConfigurationFactory::~IRunConfigurationFactory()
|
||||
{
|
||||
g_runConfigurationFactories.removeOne(this);
|
||||
}
|
||||
|
||||
const QList<IRunConfigurationFactory *> IRunConfigurationFactory::allRunConfigurationFactories()
|
||||
{
|
||||
return g_runConfigurationFactories;
|
||||
}
|
||||
|
||||
QList<RunConfigurationCreationInfo>
|
||||
@@ -556,7 +567,7 @@ RunConfiguration *IRunConfigurationFactory::clone(Target *parent, RunConfigurati
|
||||
|
||||
IRunConfigurationFactory *IRunConfigurationFactory::find(Target *parent, const QVariantMap &map)
|
||||
{
|
||||
return ExtensionSystem::PluginManager::getObject<IRunConfigurationFactory>(
|
||||
return Utils::findOrDefault(g_runConfigurationFactories,
|
||||
[&parent, &map](IRunConfigurationFactory *factory) {
|
||||
return factory->canRestore(parent, map);
|
||||
});
|
||||
@@ -564,7 +575,7 @@ IRunConfigurationFactory *IRunConfigurationFactory::find(Target *parent, const Q
|
||||
|
||||
IRunConfigurationFactory *IRunConfigurationFactory::find(Target *parent, RunConfiguration *rc)
|
||||
{
|
||||
return ExtensionSystem::PluginManager::getObject<IRunConfigurationFactory>(
|
||||
return Utils::findOrDefault(g_runConfigurationFactories,
|
||||
[&parent, rc](IRunConfigurationFactory *factory) {
|
||||
return factory->canClone(parent, rc);
|
||||
});
|
||||
@@ -572,7 +583,7 @@ IRunConfigurationFactory *IRunConfigurationFactory::find(Target *parent, RunConf
|
||||
|
||||
QList<IRunConfigurationFactory *> IRunConfigurationFactory::find(Target *parent)
|
||||
{
|
||||
return ExtensionSystem::PluginManager::getObjects<IRunConfigurationFactory>(
|
||||
return Utils::filtered(g_runConfigurationFactories,
|
||||
[&parent](IRunConfigurationFactory *factory) {
|
||||
return !factory->availableCreators(parent).isEmpty();
|
||||
});
|
||||
|
@@ -295,6 +295,9 @@ class PROJECTEXPLORER_EXPORT IRunConfigurationFactory : public QObject
|
||||
|
||||
public:
|
||||
explicit IRunConfigurationFactory(QObject *parent = nullptr);
|
||||
~IRunConfigurationFactory();
|
||||
|
||||
static const QList<IRunConfigurationFactory *> allRunConfigurationFactories();
|
||||
|
||||
enum CreationMode {UserCreate, AutoCreate};
|
||||
|
||||
|
@@ -237,11 +237,8 @@ void RunSettingsWidget::aboutToShowAddMenu()
|
||||
connect(cloneAction, &QAction::triggered,
|
||||
this, &RunSettingsWidget::cloneRunConfiguration);
|
||||
}
|
||||
const QList<IRunConfigurationFactory *> factories =
|
||||
ExtensionSystem::PluginManager::getObjects<IRunConfigurationFactory>();
|
||||
|
||||
QList<QAction *> menuActions;
|
||||
for (IRunConfigurationFactory *factory : factories) {
|
||||
for (IRunConfigurationFactory *factory : IRunConfigurationFactory::allRunConfigurationFactories()) {
|
||||
const QList<RunConfigurationCreationInfo> items = factory->availableCreators(m_target);
|
||||
for (const RunConfigurationCreationInfo &item : items) {
|
||||
auto action = new QAction(item.displayName, m_addRunMenu);
|
||||
|
@@ -87,8 +87,6 @@ class TargetPrivate
|
||||
public:
|
||||
TargetPrivate(Kit *k);
|
||||
|
||||
QList<DeployConfigurationFactory *> deployFactories() const;
|
||||
|
||||
bool m_isEnabled = true;
|
||||
QIcon m_overlayIcon;
|
||||
|
||||
@@ -109,11 +107,6 @@ TargetPrivate::TargetPrivate(Kit *k) :
|
||||
m_kit(k)
|
||||
{ }
|
||||
|
||||
QList<DeployConfigurationFactory *> TargetPrivate::deployFactories() const
|
||||
{
|
||||
return ExtensionSystem::PluginManager::getObjects<DeployConfigurationFactory>();
|
||||
}
|
||||
|
||||
Target::Target(Project *project, Kit *k) :
|
||||
ProjectConfiguration(project, k->id()),
|
||||
d(new TargetPrivate(k))
|
||||
@@ -269,7 +262,7 @@ void Target::addDeployConfiguration(DeployConfiguration *dc)
|
||||
QTC_ASSERT(dc && !d->m_deployConfigurations.contains(dc), return);
|
||||
Q_ASSERT(dc->target() == this);
|
||||
|
||||
if (d->deployFactories().isEmpty())
|
||||
if (DeployConfigurationFactory::allDeployConfigurationFactories().isEmpty())
|
||||
return;
|
||||
|
||||
// Check that we don't have a configuration with the same displayName
|
||||
|
@@ -36,8 +36,9 @@
|
||||
#include "targetsetupwidget.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <projectexplorer/ipotentialkit.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/wizard.h>
|
||||
@@ -52,6 +53,19 @@
|
||||
#include <QCheckBox>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
static QList<IPotentialKit *> g_potentialKits;
|
||||
|
||||
IPotentialKit::IPotentialKit()
|
||||
{
|
||||
g_potentialKits.append(this);
|
||||
}
|
||||
|
||||
IPotentialKit::~IPotentialKit()
|
||||
{
|
||||
g_potentialKits.removeOne(this);
|
||||
}
|
||||
|
||||
namespace Internal {
|
||||
static Utils::FileName importDirectory(const QString &projectPath)
|
||||
{
|
||||
@@ -183,9 +197,7 @@ TargetSetupPage::TargetSetupPage(QWidget *parent) :
|
||||
|
||||
setTitle(tr("Kit Selection"));
|
||||
|
||||
QList<IPotentialKit *> potentialKits =
|
||||
ExtensionSystem::PluginManager::instance()->getObjects<IPotentialKit>();
|
||||
foreach (IPotentialKit *pk, potentialKits)
|
||||
for (IPotentialKit *pk : g_potentialKits)
|
||||
if (pk->isEnabled())
|
||||
m_potentialWidgets.append(pk->createWidget(this));
|
||||
|
||||
|
@@ -36,7 +36,7 @@
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/itemviews.h>
|
||||
@@ -56,6 +56,19 @@ const char SESSION_FILTER_WARNINGS[] = "TaskWindow.IncludeWarnings";
|
||||
}
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
static QList<ITaskHandler *> g_taskHandlers;
|
||||
|
||||
ITaskHandler::ITaskHandler()
|
||||
{
|
||||
g_taskHandlers.append(this);
|
||||
}
|
||||
|
||||
ITaskHandler::~ITaskHandler()
|
||||
{
|
||||
g_taskHandlers.removeOne(this);
|
||||
}
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class TaskView : public Utils::ListView
|
||||
@@ -321,8 +334,7 @@ void TaskWindow::delayedInitialization()
|
||||
|
||||
alreadyDone = true;
|
||||
|
||||
QList<ITaskHandler *> handlers = ExtensionSystem::PluginManager::getObjects<ITaskHandler>();
|
||||
foreach (ITaskHandler *h, handlers) {
|
||||
for (ITaskHandler *h : g_taskHandlers) {
|
||||
if (h->isDefaultHandler() && !d->m_defaultHandler)
|
||||
d->m_defaultHandler = h;
|
||||
|
||||
|
@@ -322,6 +322,23 @@ QList<Task> ToolChain::validateKit(const Kit *) const
|
||||
Used by the tool chain manager to restore user-generated tool chains.
|
||||
*/
|
||||
|
||||
static QList<ToolChainFactory *> g_toolChainFactories;
|
||||
|
||||
ToolChainFactory::ToolChainFactory()
|
||||
{
|
||||
g_toolChainFactories.append(this);
|
||||
}
|
||||
|
||||
ToolChainFactory::~ToolChainFactory()
|
||||
{
|
||||
g_toolChainFactories.removeOne(this);
|
||||
}
|
||||
|
||||
const QList<ToolChainFactory *> ToolChainFactory::allToolChainFactories()
|
||||
{
|
||||
return g_toolChainFactories;
|
||||
}
|
||||
|
||||
QList<ToolChain *> ToolChainFactory::autoDetect(const QList<ToolChain *> &alreadyKnown)
|
||||
{
|
||||
Q_UNUSED(alreadyKnown);
|
||||
|
@@ -177,6 +177,11 @@ class PROJECTEXPLORER_EXPORT ToolChainFactory : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ToolChainFactory();
|
||||
~ToolChainFactory();
|
||||
|
||||
static const QList<ToolChainFactory *> allToolChainFactories();
|
||||
|
||||
QString displayName() const { return m_displayName; }
|
||||
|
||||
virtual QList<ToolChain *> autoDetect(const QList<ToolChain *> &alreadyKnown);
|
||||
|
@@ -31,8 +31,6 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/persistentsettings.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -139,7 +137,7 @@ static QList<ToolChain *> restoreFromFile(const FileName &fileName)
|
||||
if (version < 1)
|
||||
return result;
|
||||
|
||||
QList<ToolChainFactory *> factories = ExtensionSystem::PluginManager::getObjects<ToolChainFactory>();
|
||||
const QList<ToolChainFactory *> factories = ToolChainFactory::allToolChainFactories();
|
||||
|
||||
int count = data.value(QLatin1String(TOOLCHAIN_COUNT_KEY), 0).toInt();
|
||||
for (int i = 0; i < count; ++i) {
|
||||
@@ -150,7 +148,7 @@ static QList<ToolChain *> restoreFromFile(const FileName &fileName)
|
||||
const QVariantMap tcMap = data.value(key).toMap();
|
||||
|
||||
bool restored = false;
|
||||
foreach (ToolChainFactory *f, factories) {
|
||||
for (ToolChainFactory *f : factories) {
|
||||
if (f->canRestore(tcMap)) {
|
||||
if (ToolChain *tc = f->restore(tcMap)) {
|
||||
result.append(tc);
|
||||
@@ -172,9 +170,7 @@ static QList<ToolChain *> restoreFromFile(const FileName &fileName)
|
||||
static QList<ToolChain *> autoDetectToolChains(const QList<ToolChain *> alreadyKnownTcs)
|
||||
{
|
||||
QList<ToolChain *> result;
|
||||
const QList<ToolChainFactory *> factories
|
||||
= ExtensionSystem::PluginManager::getObjects<ToolChainFactory>();
|
||||
foreach (ToolChainFactory *f, factories)
|
||||
for (ToolChainFactory *f : ToolChainFactory::allToolChainFactories())
|
||||
result.append(f->autoDetect(alreadyKnownTcs));
|
||||
|
||||
// Remove invalid toolchains that might have sneaked in.
|
||||
|
@@ -110,7 +110,7 @@ class ToolChainOptionsWidget : public QWidget
|
||||
public:
|
||||
ToolChainOptionsWidget()
|
||||
{
|
||||
m_factories = ExtensionSystem::PluginManager::getObjects<ToolChainFactory>(
|
||||
m_factories = Utils::filtered(ToolChainFactory::allToolChainFactories(),
|
||||
[](ToolChainFactory *factory) { return factory->canCreate();});
|
||||
|
||||
m_model.setHeader({ToolChainOptionsPage::tr("Name"), ToolChainOptionsPage::tr("Type")});
|
||||
|
@@ -39,6 +39,9 @@ class QBSPROJECTMANAGER_EXPORT PropertyProvider : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PropertyProvider();
|
||||
~PropertyProvider();
|
||||
|
||||
virtual bool canHandle(const ProjectExplorer::Kit *k) const = 0;
|
||||
virtual QVariantMap properties(const ProjectExplorer::Kit *k, const QVariantMap &defaultData) const = 0;
|
||||
};
|
||||
|
@@ -34,7 +34,7 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <projectexplorer/kit.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
@@ -54,6 +54,19 @@ static QString qtcProfileGroup() { return QLatin1String("preferences.qtcreator.k
|
||||
static QString qtcProfilePrefix() { return qtcProfileGroup() + sep; }
|
||||
|
||||
namespace QbsProjectManager {
|
||||
|
||||
static QList<PropertyProvider *> g_propertyProviders;
|
||||
|
||||
PropertyProvider::PropertyProvider()
|
||||
{
|
||||
g_propertyProviders.append(this);
|
||||
}
|
||||
|
||||
PropertyProvider::~PropertyProvider()
|
||||
{
|
||||
g_propertyProviders.removeOne(this);
|
||||
}
|
||||
|
||||
namespace Internal {
|
||||
|
||||
qbs::Settings *QbsManager::m_settings = nullptr;
|
||||
@@ -200,8 +213,7 @@ void QbsManager::addProfileFromKit(const ProjectExplorer::Kit *k)
|
||||
|
||||
// set up properties:
|
||||
QVariantMap data = m_defaultPropertyProvider->properties(k, QVariantMap());
|
||||
QList<PropertyProvider *> providerList = ExtensionSystem::PluginManager::getObjects<PropertyProvider>();
|
||||
foreach (PropertyProvider *provider, providerList) {
|
||||
for (PropertyProvider *provider : g_propertyProviders) {
|
||||
if (provider->canHandle(k))
|
||||
data = provider->properties(k, data);
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "qmakerunconfigurationfactory.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace QmakeProjectManager {
|
||||
|
||||
@@ -35,13 +35,15 @@ QmakeRunConfigurationFactory::QmakeRunConfigurationFactory(QObject *parent) :
|
||||
|
||||
QmakeRunConfigurationFactory *QmakeRunConfigurationFactory::find(ProjectExplorer::Target *t)
|
||||
{
|
||||
if (!t)
|
||||
if (t) {
|
||||
for (auto factory : IRunConfigurationFactory::allRunConfigurationFactories()) {
|
||||
if (auto qmakeFactory = qobject_cast<QmakeRunConfigurationFactory *>(factory)) {
|
||||
if (qmakeFactory->canHandle(t))
|
||||
return qmakeFactory;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
return ExtensionSystem::PluginManager::getObject<QmakeRunConfigurationFactory>(
|
||||
[&t](QmakeRunConfigurationFactory *factory) {
|
||||
return factory->canHandle(t);
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace QmakeProjectManager
|
||||
|
@@ -30,7 +30,7 @@
|
||||
//temp
|
||||
#include "qmljsquickfix.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
using namespace QmlJSTools;
|
||||
using namespace TextEditor;
|
||||
@@ -85,10 +85,9 @@ IAssistProcessor *QmlJSQuickFixAssistProvider::createProcessor() const
|
||||
|
||||
QList<QuickFixFactory *> QmlJSQuickFixAssistProvider::quickFixFactories() const
|
||||
{
|
||||
QList<QuickFixFactory *> results;
|
||||
foreach (QmlJSQuickFixFactory *f, ExtensionSystem::PluginManager::getObjects<QmlJSQuickFixFactory>())
|
||||
results.append(f);
|
||||
return results;
|
||||
return Utils::filtered(QuickFixFactory::allQuickFixFactories(), [](QuickFixFactory *f) {
|
||||
return qobject_cast<QmlJSQuickFixFactory *>(f) != nullptr;
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace QmlJSEditor
|
||||
|
@@ -176,4 +176,22 @@ void BasicBundleProvider::mergeBundlesForKit(ProjectExplorer::Kit *kit
|
||||
}
|
||||
}
|
||||
|
||||
static QList<IBundleProvider *> g_bundleProviders;
|
||||
|
||||
IBundleProvider::IBundleProvider(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
g_bundleProviders.append(this);
|
||||
}
|
||||
|
||||
IBundleProvider::~IBundleProvider()
|
||||
{
|
||||
g_bundleProviders.removeOne(this);
|
||||
}
|
||||
|
||||
const QList<IBundleProvider *> IBundleProvider::allBundleProviders()
|
||||
{
|
||||
return g_bundleProviders;
|
||||
}
|
||||
|
||||
} // end namespace QmlJSTools
|
||||
|
@@ -47,9 +47,10 @@ class QMLJSTOOLS_EXPORT IBundleProvider : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit IBundleProvider(QObject *parent = 0)
|
||||
: QObject(parent)
|
||||
{ }
|
||||
explicit IBundleProvider(QObject *parent = 0);
|
||||
~IBundleProvider();
|
||||
|
||||
static const QList<IBundleProvider *> allBundleProviders();
|
||||
|
||||
virtual void mergeBundlesForKit(ProjectExplorer::Kit *kit, QmlJS::QmlLanguageBundles &bundles
|
||||
, const QHash<QString,QString> &replacements) = 0;
|
||||
|
@@ -88,10 +88,8 @@ TextEditor::Indenter *QmlJSCodeStylePreferencesFactory::createIndenter() const
|
||||
|
||||
TextEditor::SnippetProvider *QmlJSCodeStylePreferencesFactory::snippetProvider() const
|
||||
{
|
||||
return ExtensionSystem::PluginManager::getObject<TextEditor::SnippetProvider>(
|
||||
[](TextEditor::SnippetProvider *provider) {
|
||||
return provider->groupId() == QLatin1String(QmlJSEditor::Constants::QML_SNIPPETS_GROUP_ID);
|
||||
});
|
||||
return TextEditor::SnippetProvider::snippetProviderForGroupId
|
||||
(QmlJSEditor::Constants::QML_SNIPPETS_GROUP_ID);
|
||||
}
|
||||
|
||||
QString QmlJSCodeStylePreferencesFactory::previewText() const
|
||||
|
@@ -80,13 +80,10 @@ void QmlJSCodeStylePreferencesWidget::setPreferences(ICodeStylePreferences *pref
|
||||
updatePreview();
|
||||
}
|
||||
|
||||
|
||||
void QmlJSCodeStylePreferencesWidget::decorateEditor(const FontSettings &fontSettings)
|
||||
{
|
||||
const SnippetProvider *provider = ExtensionSystem::PluginManager::getObject<SnippetProvider>(
|
||||
[](SnippetProvider *current) {
|
||||
return current->groupId() == QLatin1String(QmlJSEditor::Constants::QML_SNIPPETS_GROUP_ID);
|
||||
});
|
||||
const SnippetProvider *provider =
|
||||
SnippetProvider::snippetProviderForGroupId(QmlJSEditor::Constants::QML_SNIPPETS_GROUP_ID);
|
||||
|
||||
m_ui->previewTextEdit->textDocument()->setFontSettings(fontSettings);
|
||||
if (provider)
|
||||
|
@@ -33,8 +33,9 @@
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <coreplugin/progressmanager/progressmanager.h>
|
||||
|
||||
#include <cpptools/cppmodelmanager.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <projectexplorer/buildconfiguration.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
@@ -152,13 +153,9 @@ void setupProjectInfoQmlBundles(ModelManagerInterface::ProjectInfo &projectInfo)
|
||||
replacements.insert(QLatin1String("$(QT_INSTALL_IMPORTS)"), projectInfo.qtImportsPath);
|
||||
replacements.insert(QLatin1String("$(QT_INSTALL_QML)"), projectInfo.qtQmlPath);
|
||||
|
||||
QList<IBundleProvider *> bundleProviders =
|
||||
ExtensionSystem::PluginManager::getObjects<IBundleProvider>();
|
||||
|
||||
foreach (IBundleProvider *bp, bundleProviders) {
|
||||
if (bp)
|
||||
for (IBundleProvider *bp : IBundleProvider::allBundleProviders())
|
||||
bp->mergeBundlesForKit(activeKit, projectInfo.activeBundle, replacements);
|
||||
}
|
||||
|
||||
projectInfo.extendedBundle = projectInfo.activeBundle;
|
||||
|
||||
if (projectInfo.project) {
|
||||
@@ -167,8 +164,7 @@ void setupProjectInfoQmlBundles(ModelManagerInterface::ProjectInfo &projectInfo)
|
||||
currentKits.insert(t->kit());
|
||||
currentKits.remove(activeKit);
|
||||
foreach (Kit *kit, currentKits) {
|
||||
foreach (IBundleProvider *bp, bundleProviders)
|
||||
if (bp)
|
||||
for (IBundleProvider *bp : IBundleProvider::allBundleProviders())
|
||||
bp->mergeBundlesForKit(kit, projectInfo.extendedBundle, replacements);
|
||||
}
|
||||
}
|
||||
|
@@ -36,13 +36,22 @@
|
||||
using namespace QtSupport;
|
||||
using namespace QtSupport::Internal;
|
||||
|
||||
static QList<QtVersionFactory *> g_qtVersionFactories;
|
||||
|
||||
QtVersionFactory::QtVersionFactory(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
g_qtVersionFactories.append(this);
|
||||
}
|
||||
|
||||
QtVersionFactory::~QtVersionFactory()
|
||||
{
|
||||
g_qtVersionFactories.removeOne(this);
|
||||
}
|
||||
|
||||
const QList<QtVersionFactory *> QtVersionFactory::allQtVersionFactories()
|
||||
{
|
||||
return g_qtVersionFactories;
|
||||
}
|
||||
|
||||
BaseQtVersion *QtVersionFactory::createQtVersionFromQMakePath(const Utils::FileName &qmakePath, bool isAutoDetected, const QString &autoDetectionSource, QString *error)
|
||||
@@ -62,7 +71,7 @@ BaseQtVersion *QtVersionFactory::createQtVersionFromQMakePath(const Utils::FileN
|
||||
ProFileEvaluator evaluator(&globals, &parser, &vfs, &msgHandler);
|
||||
evaluator.loadNamedSpec(mkspec.toString(), false);
|
||||
|
||||
QList<QtVersionFactory *> factories = ExtensionSystem::PluginManager::getObjects<QtVersionFactory>();
|
||||
QList<QtVersionFactory *> factories = g_qtVersionFactories;
|
||||
Utils::sort(factories, [](const QtVersionFactory *l, const QtVersionFactory *r) {
|
||||
return l->priority() > r->priority();
|
||||
});
|
||||
|
@@ -49,6 +49,8 @@ public:
|
||||
explicit QtVersionFactory(QObject *parent = 0);
|
||||
~QtVersionFactory();
|
||||
|
||||
static const QList<QtVersionFactory *> allQtVersionFactories();
|
||||
|
||||
virtual bool canRestore(const QString &type) = 0;
|
||||
virtual BaseQtVersion *restore(const QString &type, const QVariantMap &data) = 0;
|
||||
|
||||
|
@@ -179,7 +179,7 @@ static bool restoreQtVersions()
|
||||
m_writer = new PersistentSettingsWriter(settingsFileName(QLatin1String(QTVERSION_FILENAME)),
|
||||
QLatin1String("QtCreatorQtVersions"));
|
||||
|
||||
QList<QtVersionFactory *> factories = ExtensionSystem::PluginManager::getObjects<QtVersionFactory>();
|
||||
const QList<QtVersionFactory *> factories = QtVersionFactory::allQtVersionFactories();
|
||||
|
||||
PersistentSettingsReader reader;
|
||||
FileName filename = settingsFileName(QLatin1String(QTVERSION_FILENAME));
|
||||
@@ -208,7 +208,7 @@ static bool restoreQtVersions()
|
||||
const QString type = qtversionMap.value(QLatin1String(QTVERSION_TYPE_KEY)).toString();
|
||||
|
||||
bool restored = false;
|
||||
foreach (QtVersionFactory *f, factories) {
|
||||
for (QtVersionFactory *f : factories) {
|
||||
if (f->canRestore(type)) {
|
||||
if (BaseQtVersion *qtv = f->restore(type, qtversionMap)) {
|
||||
if (m_versions.contains(qtv->uniqueId())) {
|
||||
@@ -249,7 +249,7 @@ void QtVersionManager::updateFromInstaller(bool emitSignal)
|
||||
QList<int> removed;
|
||||
QList<int> changed;
|
||||
|
||||
QList<QtVersionFactory *> factories = ExtensionSystem::PluginManager::getObjects<QtVersionFactory>();
|
||||
const QList<QtVersionFactory *> factories = QtVersionFactory::allQtVersionFactories();
|
||||
PersistentSettingsReader reader;
|
||||
QVariantMap data;
|
||||
if (reader.load(path))
|
||||
|
@@ -46,9 +46,14 @@ public:
|
||||
virtual QVariantMap settings() const { return QVariantMap(); }
|
||||
};
|
||||
|
||||
class TEXTEDITOR_EXPORT IOutlineWidgetFactory : public QObject {
|
||||
class TEXTEDITOR_EXPORT IOutlineWidgetFactory : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IOutlineWidgetFactory();
|
||||
~IOutlineWidgetFactory() override;
|
||||
|
||||
virtual bool supportsEditor(Core::IEditor *editor) const = 0;
|
||||
virtual IOutlineWidget *createWidget(Core::IEditor *editor) = 0;
|
||||
};
|
||||
|
@@ -38,6 +38,19 @@
|
||||
#include <QDebug>
|
||||
|
||||
namespace TextEditor {
|
||||
|
||||
static QList<IOutlineWidgetFactory *> g_outlineWidgetFactories;
|
||||
|
||||
IOutlineWidgetFactory::IOutlineWidgetFactory()
|
||||
{
|
||||
g_outlineWidgetFactories.append(this);
|
||||
}
|
||||
|
||||
IOutlineWidgetFactory::~IOutlineWidgetFactory()
|
||||
{
|
||||
g_outlineWidgetFactories.removeOne(this);
|
||||
}
|
||||
|
||||
namespace Internal {
|
||||
|
||||
OutlineWidgetStack::OutlineWidgetStack(OutlineFactory *factory) :
|
||||
@@ -153,7 +166,7 @@ void OutlineWidgetStack::updateCurrentEditor(Core::IEditor *editor)
|
||||
IOutlineWidget *newWidget = 0;
|
||||
|
||||
if (editor) {
|
||||
foreach (IOutlineWidgetFactory *widgetFactory, m_factory->widgetFactories()) {
|
||||
for (IOutlineWidgetFactory *widgetFactory : g_outlineWidgetFactories) {
|
||||
if (widgetFactory->supportsEditor(editor)) {
|
||||
newWidget = widgetFactory->createWidget(editor);
|
||||
break;
|
||||
@@ -189,16 +202,6 @@ OutlineFactory::OutlineFactory()
|
||||
setPriority(600);
|
||||
}
|
||||
|
||||
QList<IOutlineWidgetFactory*> OutlineFactory::widgetFactories() const
|
||||
{
|
||||
return m_factories;
|
||||
}
|
||||
|
||||
void OutlineFactory::setWidgetFactories(QList<IOutlineWidgetFactory*> factories)
|
||||
{
|
||||
m_factories = factories;
|
||||
}
|
||||
|
||||
Core::NavigationView OutlineFactory::createWidget()
|
||||
{
|
||||
Core::NavigationView n;
|
||||
|
@@ -72,15 +72,10 @@ class OutlineFactory : public Core::INavigationWidgetFactory
|
||||
public:
|
||||
OutlineFactory();
|
||||
|
||||
QList<IOutlineWidgetFactory*> widgetFactories() const;
|
||||
void setWidgetFactories(QList<IOutlineWidgetFactory*> factories);
|
||||
|
||||
// from INavigationWidgetFactory
|
||||
virtual Core::NavigationView createWidget();
|
||||
virtual void saveSettings(QSettings *settings, int position, QWidget *widget);
|
||||
virtual void restoreSettings(QSettings *settings, int position, QWidget *widget);
|
||||
private:
|
||||
QList<IOutlineWidgetFactory*> m_factories;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -56,11 +56,20 @@ void QuickFixOperation::setDescription(const QString &description)
|
||||
_description = description;
|
||||
}
|
||||
|
||||
static QList<QuickFixFactory *> g_quickFixFactories;
|
||||
|
||||
QuickFixFactory::QuickFixFactory(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
g_quickFixFactories.append(this);
|
||||
}
|
||||
|
||||
QuickFixFactory::~QuickFixFactory()
|
||||
{
|
||||
g_quickFixFactories.removeOne(this);
|
||||
}
|
||||
|
||||
const QList<QuickFixFactory *> QuickFixFactory::allQuickFixFactories()
|
||||
{
|
||||
return g_quickFixFactories;
|
||||
}
|
||||
|
@@ -114,6 +114,8 @@ public:
|
||||
QuickFixFactory(QObject *parent = 0);
|
||||
~QuickFixFactory();
|
||||
|
||||
static const QList<QuickFixFactory *> allQuickFixFactories();
|
||||
|
||||
virtual void matchingOperations(const QuickFixInterface &interface, QuickFixOperations &result) = 0;
|
||||
};
|
||||
|
||||
|
@@ -27,8 +27,33 @@
|
||||
|
||||
#include "texteditorplugin.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
using namespace TextEditor;
|
||||
|
||||
static QList<SnippetProvider *> g_snippetProviders;
|
||||
|
||||
const QList<SnippetProvider *> SnippetProvider::snippetProviders()
|
||||
{
|
||||
return g_snippetProviders;
|
||||
}
|
||||
|
||||
SnippetProvider *SnippetProvider::snippetProviderForGroupId(const QString &groupId)
|
||||
{
|
||||
return Utils::findOrDefault(g_snippetProviders,
|
||||
Utils::equal(&SnippetProvider::groupId, groupId));
|
||||
}
|
||||
|
||||
SnippetProvider::SnippetProvider()
|
||||
{
|
||||
g_snippetProviders.append(this);
|
||||
}
|
||||
|
||||
SnippetProvider::~SnippetProvider()
|
||||
{
|
||||
g_snippetProviders.removeOne(this);
|
||||
}
|
||||
|
||||
/*!
|
||||
\group Snippets
|
||||
\title Snippets for Editors
|
||||
|
@@ -41,6 +41,9 @@ class TEXTEDITOR_EXPORT SnippetProvider : public QObject
|
||||
public:
|
||||
using EditorDecorator = std::function<void(TextEditorWidget *)>;
|
||||
|
||||
static const QList<SnippetProvider *> snippetProviders();
|
||||
static SnippetProvider *snippetProviderForGroupId(const QString &groupId);
|
||||
|
||||
static void registerGroup(const QString &groupId, const QString &displayName,
|
||||
EditorDecorator editorDecorator = EditorDecorator());
|
||||
|
||||
@@ -51,7 +54,8 @@ public:
|
||||
void decorateEditor(TextEditorWidget *editor) const;
|
||||
|
||||
private:
|
||||
SnippetProvider() = default;
|
||||
SnippetProvider();
|
||||
~SnippetProvider() override;
|
||||
|
||||
QString m_groupId;
|
||||
QString m_displayName;
|
||||
|
@@ -409,9 +409,7 @@ int SnippetsCollection::groupIndex(const QString &groupId) const
|
||||
|
||||
void SnippetsCollection::identifyGroups()
|
||||
{
|
||||
const QList<SnippetProvider *> &providers =
|
||||
ExtensionSystem::PluginManager::getObjects<SnippetProvider>();
|
||||
foreach (SnippetProvider *provider, providers) {
|
||||
for (SnippetProvider *provider : SnippetProvider::snippetProviders()) {
|
||||
const int groupIndex = m_groupIndexById.size();
|
||||
m_groupIndexById.insert(provider->groupId(), groupIndex);
|
||||
m_snippets.resize(groupIndex + 1);
|
||||
|
@@ -328,9 +328,8 @@ void SnippetsSettingsPagePrivate::configureUi(QWidget *w)
|
||||
{
|
||||
m_ui.setupUi(w);
|
||||
|
||||
const QList<SnippetProvider *> &providers =
|
||||
ExtensionSystem::PluginManager::getObjects<SnippetProvider>();
|
||||
foreach (SnippetProvider *provider, providers) {
|
||||
const QList<SnippetProvider *> &providers = SnippetProvider::snippetProviders();
|
||||
for (SnippetProvider *provider : providers) {
|
||||
m_ui.groupCombo->addItem(provider->displayName(), provider->groupId());
|
||||
SnippetEditorWidget *snippetEditor = new SnippetEditorWidget(w);
|
||||
provider->decorateEditor(snippetEditor);
|
||||
@@ -537,8 +536,7 @@ void SnippetsSettingsPagePrivate::setSnippetContent()
|
||||
|
||||
void SnippetsSettingsPagePrivate::decorateEditors(const TextEditor::FontSettings &fontSettings)
|
||||
{
|
||||
const QList<SnippetProvider *> &providers =
|
||||
ExtensionSystem::PluginManager::getObjects<SnippetProvider>();
|
||||
const QList<SnippetProvider *> &providers = SnippetProvider::snippetProviders();
|
||||
for (int i = 0; i < m_ui.groupCombo->count(); ++i) {
|
||||
SnippetEditorWidget *snippetEditor = editorAt(i);
|
||||
snippetEditor->textDocument()->setFontSettings(fontSettings);
|
||||
|
@@ -147,8 +147,6 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
|
||||
|
||||
void TextEditorPlugin::extensionsInitialized()
|
||||
{
|
||||
m_outlineFactory->setWidgetFactories(ExtensionSystem::PluginManager::getObjects<TextEditor::IOutlineWidgetFactory>());
|
||||
|
||||
connect(m_settings, &TextEditorSettings::fontSettingsChanged,
|
||||
this, &TextEditorPlugin::updateSearchResultsFont);
|
||||
|
||||
|
@@ -83,10 +83,13 @@ VcsEditorFactory::VcsEditorFactory(const VcsBaseEditorParameters *parameters,
|
||||
|
||||
VcsBaseEditor *VcsEditorFactory::createEditorById(const char *id)
|
||||
{
|
||||
auto factory = ExtensionSystem::PluginManager::getObject<VcsEditorFactory>(
|
||||
[id](QObject *ob) { return ob->property("VcsEditorFactoryName").toByteArray() == id; });
|
||||
QTC_ASSERT(factory, return 0);
|
||||
for (IEditorFactory *factory : allEditorFactories()) {
|
||||
if (auto vcsFactory = qobject_cast<VcsEditorFactory *>(factory)) {
|
||||
if (vcsFactory->property("VcsEditorFactoryName").toByteArray() == id)
|
||||
return qobject_cast<VcsBaseEditor *>(factory->createEditor());
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace VcsBase
|
||||
|
@@ -343,8 +343,7 @@ void WelcomeMode::initPlugins()
|
||||
QSettings *settings = ICore::settings();
|
||||
m_activePage = Id::fromSetting(settings->value(currentPageSettingsKeyC));
|
||||
|
||||
const QList<IWelcomePage *> availablePages = PluginManager::getObjects<IWelcomePage>();
|
||||
for (IWelcomePage *page : availablePages)
|
||||
for (IWelcomePage *page : IWelcomePage::allWelcomePages())
|
||||
addPage(page);
|
||||
|
||||
// make sure later added pages are made available too:
|
||||
|
Reference in New Issue
Block a user