forked from qt-creator/qt-creator
ProjectExplorer: Let ProjectPanelFactories auto-register
Change-Id: Iaca1438f1199c2dd112b61a8ff74f4707867e7c5 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -162,7 +162,6 @@ public:
|
||||
setCreateWidgetFunction([](Project *project) {
|
||||
return new ProjectTestSettingsWidget(project);
|
||||
});
|
||||
ProjectPanelFactory::registerFactory(this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -259,7 +259,6 @@ public:
|
||||
setCreateWidgetFunction([](ProjectExplorer::Project *project) {
|
||||
return new AxivionProjectSettingsWidget(project);
|
||||
});
|
||||
ProjectExplorer::ProjectPanelFactory::registerFactory(this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -251,9 +251,9 @@ public:
|
||||
setPriority(100);
|
||||
setId(Constants::PROJECT_PANEL_ID);
|
||||
setDisplayName(Tr::tr("Clang Tools"));
|
||||
setCreateWidgetFunction(
|
||||
[](Project *project) { return new ClangToolsProjectSettingsWidget(project); });
|
||||
ProjectPanelFactory::registerFactory(this);
|
||||
setCreateWidgetFunction([](Project *project) {
|
||||
return new ClangToolsProjectSettingsWidget(project);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -65,7 +65,6 @@ public:
|
||||
setPriority(1000);
|
||||
setDisplayName(Tr::tr("Copilot"));
|
||||
setCreateWidgetFunction(&createCopilotProjectPanel);
|
||||
ProjectPanelFactory::registerFactory(this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -637,7 +637,6 @@ public:
|
||||
setCreateWidgetFunction([](Project *project) {
|
||||
return new ClangdProjectSettingsWidget(project);
|
||||
});
|
||||
ProjectPanelFactory::registerFactory(this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -597,7 +597,6 @@ public:
|
||||
setCreateWidgetFunction([](Project *project) {
|
||||
return new CppFileSettingsForProjectWidget(project);
|
||||
});
|
||||
ProjectPanelFactory::registerFactory(this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -115,7 +115,6 @@ public:
|
||||
setCreateWidgetFunction([](Project *project) {
|
||||
return new CppQuickFixProjectSettingsWidget(project);
|
||||
});
|
||||
ProjectPanelFactory::registerFactory(this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -339,7 +339,6 @@ public:
|
||||
setCreateWidgetFunction([](ProjectExplorer::Project *project) {
|
||||
return new GitLabProjectSettingsWidget(project);
|
||||
});
|
||||
ProjectExplorer::ProjectPanelFactory::registerFactory(this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1151,7 +1151,6 @@ public:
|
||||
setCreateWidgetFunction([](Project *project) {
|
||||
return new LanguageClientProjectSettingsWidget(project);
|
||||
});
|
||||
ProjectPanelFactory::registerFactory(this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -70,7 +70,6 @@ public:
|
||||
setPriority(40);
|
||||
setDisplayName(Tr::tr("Code Style"));
|
||||
setCreateWidgetFunction([](Project *project) { return new CodeStyleSettingsWidget(project); });
|
||||
ProjectPanelFactory::registerFactory(this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -271,7 +271,6 @@ public:
|
||||
setPriority(50);
|
||||
setDisplayName(Tr::tr("Dependencies"));
|
||||
setCreateWidgetFunction([](Project *project) { return new DependenciesWidget(project); });
|
||||
ProjectPanelFactory::registerFactory(this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -167,7 +167,6 @@ public:
|
||||
setPriority(30);
|
||||
setDisplayName(Tr::tr("Editor"));
|
||||
setCreateWidgetFunction([](Project *project) { return new EditorSettingsWidget(project); });
|
||||
ProjectPanelFactory::registerFactory(this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -142,7 +142,6 @@ public:
|
||||
TextEditor::TextEditorSettings::setCommentsSettingsRetriever([](const FilePath &filePath) {
|
||||
return ProjectCommentsSettings(ProjectManager::projectForFile(filePath)).settings();
|
||||
});
|
||||
ProjectPanelFactory::registerFactory(this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -411,7 +411,6 @@ public:
|
||||
setCreateWidgetFunction([](Project *project) {
|
||||
return new ProjectEnvironmentWidget(project);
|
||||
});
|
||||
ProjectPanelFactory::registerFactory(this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "projectpanelfactory.h"
|
||||
|
||||
#include "project.h"
|
||||
#include "projectsettingswidget.h"
|
||||
#include "projectwindow.h"
|
||||
|
||||
#include <utils/layoutbuilder.h>
|
||||
@@ -14,10 +15,14 @@ using namespace Utils;
|
||||
namespace ProjectExplorer {
|
||||
|
||||
static QList<ProjectPanelFactory *> s_factories;
|
||||
bool s_sorted = false;
|
||||
|
||||
ProjectPanelFactory::ProjectPanelFactory()
|
||||
: m_supportsFunction([] (Project *) { return true; })
|
||||
{ }
|
||||
{
|
||||
s_factories.append(this);
|
||||
s_sorted = false;
|
||||
}
|
||||
|
||||
int ProjectPanelFactory::priority() const
|
||||
{
|
||||
@@ -39,27 +44,24 @@ void ProjectPanelFactory::setDisplayName(const QString &name)
|
||||
m_displayName = name;
|
||||
}
|
||||
|
||||
void ProjectPanelFactory::registerFactory(ProjectPanelFactory *factory)
|
||||
QList<ProjectPanelFactory *> ProjectPanelFactory::factories()
|
||||
{
|
||||
auto it = std::lower_bound(s_factories.begin(), s_factories.end(), factory,
|
||||
if (!s_sorted) {
|
||||
s_sorted = true;
|
||||
std::sort(s_factories.begin(), s_factories.end(),
|
||||
[](ProjectPanelFactory *a, ProjectPanelFactory *b) {
|
||||
return (a->priority() == b->priority() && a < b) || a->priority() < b->priority();
|
||||
});
|
||||
|
||||
s_factories.insert(it, factory);
|
||||
}
|
||||
|
||||
QList<ProjectPanelFactory *> ProjectPanelFactory::factories()
|
||||
{
|
||||
return s_factories;
|
||||
}
|
||||
|
||||
Utils::Id ProjectPanelFactory::id() const
|
||||
Id ProjectPanelFactory::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void ProjectPanelFactory::setId(Utils::Id id)
|
||||
void ProjectPanelFactory::setId(Id id)
|
||||
{
|
||||
m_id = id;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
namespace ProjectExplorer {
|
||||
|
||||
class Project;
|
||||
class ProjectExplorerPlugin;
|
||||
|
||||
class PROJECTEXPLORER_EXPORT ProjectPanelFactory
|
||||
{
|
||||
@@ -42,9 +41,6 @@ public:
|
||||
using SupportsFunction = std::function<bool (Project *)>;
|
||||
void setSupportsFunction(std::function<bool (Project *)> function);
|
||||
|
||||
// This takes ownership.
|
||||
static void registerFactory(ProjectPanelFactory *factory);
|
||||
|
||||
static QList<ProjectPanelFactory *> factories();
|
||||
|
||||
Utils::TreeItem *createPanelItem(Project *project);
|
||||
|
||||
@@ -179,7 +179,6 @@ public:
|
||||
provider, [project, provider] { provider->projectSettingsChanged(project); });
|
||||
return widget;
|
||||
});
|
||||
ProjectPanelFactory::registerFactory(this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user