Commit 15fcdabc authored by hjk's avatar hjk

ProjectExplorer: Further clean up of IProjectPanelFactory

Rename to ProjectPanelFactory, hide list of factories from .h,
rename include guards.

Change-Id: I2e0befcaf847e5c3a0b493b58e7bcf3e9263f4f9
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 1a1ddf1d
......@@ -41,7 +41,7 @@
#include <cpptools/cppmodelmanager.h>
#include <projectexplorer/iprojectpanelfactory.h>
#include <projectexplorer/projectpanelfactory.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/session.h>
......@@ -55,12 +55,12 @@ bool ClangCodeModelPlugin::initialize(const QStringList &arguments, QString *err
Q_UNUSED(arguments)
Q_UNUSED(errorMessage)
auto panelFactory = new ProjectExplorer::IProjectPanelFactory();
auto panelFactory = new ProjectExplorer::ProjectPanelFactory();
panelFactory->setPriority(60);
panelFactory->setDisplayName(ClangProjectSettingsWidget::tr("Clang Settings"));
panelFactory->setSimpleCreateWidgetFunction<ClangProjectSettingsWidget>(QIcon());
ProjectExplorer::IProjectPanelFactory::registerFactory(panelFactory);
ProjectExplorer::ProjectPanelFactory::registerFactory(panelFactory);
ClangCodeModel::Internal::initializeClang();
......
......@@ -84,7 +84,7 @@
#include "devicesupport/devicemanager.h"
#include "devicesupport/devicesettingspage.h"
#include "targetsettingspanel.h"
#include "iprojectpanelfactory.h"
#include "projectpanelfactory.h"
#ifdef Q_OS_WIN
# include "windebuginterface.h"
......@@ -321,7 +321,7 @@ ProjectExplorerPlugin::~ProjectExplorerPlugin()
// Force sequence of deletion:
delete d->m_kitManager; // remove all the profile informations
delete d->m_toolChainManager;
IProjectPanelFactory::destroyFactories();
ProjectPanelFactory::destroyFactories();
delete d;
}
......@@ -471,31 +471,31 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
addAutoReleasedObject(new CurrentProjectFilter);
// ProjectPanelFactories
auto editorSettingsPanelFactory = new IProjectPanelFactory;
auto editorSettingsPanelFactory = new ProjectPanelFactory;
editorSettingsPanelFactory->setPriority(30);
QString displayName = QCoreApplication::translate("EditorSettingsPanelFactory", "Editor");
editorSettingsPanelFactory->setDisplayName(displayName);
QIcon icon = QIcon(QLatin1String(":/projectexplorer/images/EditorSettings.png"));
editorSettingsPanelFactory->setSimpleCreateWidgetFunction<EditorSettingsWidget>(icon);
IProjectPanelFactory::registerFactory(editorSettingsPanelFactory);
ProjectPanelFactory::registerFactory(editorSettingsPanelFactory);
auto codeStyleSettingsPanelFactory = new IProjectPanelFactory;
auto codeStyleSettingsPanelFactory = new ProjectPanelFactory;
codeStyleSettingsPanelFactory->setPriority(40);
displayName = QCoreApplication::translate("CodeStyleSettingsPanelFactory", "Code Style");
codeStyleSettingsPanelFactory->setDisplayName(displayName);
icon = QIcon(QLatin1String(":/projectexplorer/images/CodeStyleSettings.png"));
codeStyleSettingsPanelFactory->setSimpleCreateWidgetFunction<CodeStyleSettingsWidget>(icon);
IProjectPanelFactory::registerFactory(codeStyleSettingsPanelFactory);
ProjectPanelFactory::registerFactory(codeStyleSettingsPanelFactory);
auto dependenciesPanelFactory = new IProjectPanelFactory;
auto dependenciesPanelFactory = new ProjectPanelFactory;
dependenciesPanelFactory->setPriority(50);
displayName = QCoreApplication::translate("DependenciesPanelFactory", "Dependencies");
dependenciesPanelFactory->setDisplayName(displayName);
icon = QIcon(QLatin1String(":/projectexplorer/images/ProjectDependencies.png"));
dependenciesPanelFactory->setSimpleCreateWidgetFunction<DependenciesWidget>(icon);
IProjectPanelFactory::registerFactory(dependenciesPanelFactory);
ProjectPanelFactory::registerFactory(dependenciesPanelFactory);
auto unconfiguredProjectPanel = new IProjectPanelFactory;
auto unconfiguredProjectPanel = new ProjectPanelFactory;
unconfiguredProjectPanel->setPriority(-10);
unconfiguredProjectPanel->setDisplayName(tr("Configure Project"));
unconfiguredProjectPanel->setSupportsFunction([](Project *project){
......@@ -503,9 +503,9 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
});
icon = QIcon(QLatin1String(":/projectexplorer/images/unconfigured.png"));
unconfiguredProjectPanel->setSimpleCreateWidgetFunction<TargetSetupPageWrapper>(icon);
IProjectPanelFactory::registerFactory(unconfiguredProjectPanel);
ProjectPanelFactory::registerFactory(unconfiguredProjectPanel);
auto targetSettingsPanelFactory = new IProjectPanelFactory;
auto targetSettingsPanelFactory = new ProjectPanelFactory;
targetSettingsPanelFactory->setPriority(-10);
displayName = QCoreApplication::translate("TargetSettingsPanelFactory", "Build & Run");
targetSettingsPanelFactory->setDisplayName(displayName);
......@@ -516,7 +516,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
targetSettingsPanelFactory->setCreateWidgetFunction([](Project *project) {
return new TargetSettingsPanelWidget(project);
});
IProjectPanelFactory::registerFactory(targetSettingsPanelFactory);
ProjectPanelFactory::registerFactory(targetSettingsPanelFactory);
addAutoReleasedObject(new ProcessStepFactory);
......
......@@ -149,7 +149,7 @@ HEADERS += projectexplorer.h \
xcodebuildparser.h \
propertiespanel.h \
panelswidget.h \
iprojectpanelfactory.h
projectpanelfactory.h
SOURCES += projectexplorer.cpp \
abi.cpp \
......@@ -286,7 +286,7 @@ SOURCES += projectexplorer.cpp \
xcodebuildparser.cpp \
propertiespanel.cpp \
panelswidget.cpp \
iprojectpanelfactory.cpp
projectpanelfactory.cpp
FORMS += processstep.ui \
editorsettingspropertiespage.ui \
......
......@@ -85,7 +85,6 @@ QtcPlugin {
"ipotentialkit.cpp",
"ipotentialkit.h",
"iprojectmanager.h",
"iprojectpanelfactory.cpp", "iprojectpanelfactory.h",
"itaskhandler.h",
"kit.cpp", "kit.h",
"kitchooser.cpp", "kitchooser.h",
......@@ -122,6 +121,7 @@ QtcPlugin {
"projectmacroexpander.cpp", "projectmacroexpander.h",
"projectmodels.cpp", "projectmodels.h",
"projectnodes.cpp", "projectnodes.h",
"projectpanelfactory.cpp", "projectpanelfactory.h",
"projecttreewidget.cpp", "projecttreewidget.h",
"projectwindow.cpp", "projectwindow.h",
"projectwizardpage.cpp", "projectwizardpage.h", "projectwizardpage.ui",
......
......@@ -27,74 +27,71 @@
**
****************************************************************************/
#include "iprojectpanelfactory.h"
#include "projectpanelfactory.h"
using namespace ProjectExplorer;
namespace ProjectExplorer {
QList<IProjectPanelFactory *> IProjectPanelFactory::s_factories;
static QList<ProjectPanelFactory *> s_factories;
IProjectPanelFactory::IProjectPanelFactory()
ProjectPanelFactory::ProjectPanelFactory()
: m_priority(0),
m_supportsFunction(&supportsAllProjects)
m_supportsFunction([] (Project *) { return true; })
{}
int IProjectPanelFactory::priority() const
int ProjectPanelFactory::priority() const
{
return m_priority;
}
void IProjectPanelFactory::setPriority(int priority)
void ProjectPanelFactory::setPriority(int priority)
{
m_priority = priority;
}
QString IProjectPanelFactory::displayName() const
QString ProjectPanelFactory::displayName() const
{
return m_displayName;
}
void IProjectPanelFactory::setDisplayName(const QString &name)
void ProjectPanelFactory::setDisplayName(const QString &name)
{
m_displayName = name;
}
bool IProjectPanelFactory::supportsAllProjects(Project *)
{
return true;
}
void IProjectPanelFactory::registerFactory(IProjectPanelFactory *factory)
void ProjectPanelFactory::registerFactory(ProjectPanelFactory *factory)
{
auto it = std::lower_bound(s_factories.begin(), s_factories.end(), factory,
[](IProjectPanelFactory *a, IProjectPanelFactory *b) {
[](ProjectPanelFactory *a, ProjectPanelFactory *b) {
return (a->priority() == b->priority() && a < b) || a->priority() < b->priority();
});
s_factories.insert(it, factory);
}
QList<IProjectPanelFactory *> IProjectPanelFactory::factories()
QList<ProjectPanelFactory *> ProjectPanelFactory::factories()
{
return s_factories;
}
void IProjectPanelFactory::destroyFactories()
void ProjectPanelFactory::destroyFactories()
{
qDeleteAll(s_factories);
s_factories.clear();
}
bool IProjectPanelFactory::supports(Project *project)
bool ProjectPanelFactory::supports(Project *project)
{
return m_supportsFunction(project);
}
void IProjectPanelFactory::setSupportsFunction(std::function<bool (Project *)> function)
void ProjectPanelFactory::setSupportsFunction(std::function<bool (Project *)> function)
{
m_supportsFunction = function;
}
QWidget *IProjectPanelFactory::createWidget(Project *project)
QWidget *ProjectPanelFactory::createWidget(Project *project)
{
return m_createWidgetFunction(project);
}
} // namespace ProjectExplorer
......@@ -27,27 +27,24 @@
**
****************************************************************************/
#ifndef IPROJECTPROPERTIES_H
#define IPROJECTPROPERTIES_H
#ifndef PROJECTPANELFACTORY_H
#define PROJECTPANELFACTORY_H
#include "projectexplorer_export.h"
#include "propertiespanel.h"
#include "panelswidget.h"
#include <QIcon>
#include <QWidget>
#include <functional>
namespace ProjectExplorer {
class Project;
class ProjectExplorerPlugin;
class Target;
class PROJECTEXPLORER_EXPORT IProjectPanelFactory
class PROJECTEXPLORER_EXPORT ProjectPanelFactory
{
public:
IProjectPanelFactory();
ProjectPanelFactory();
// simple properties
QString displayName() const;
......@@ -55,11 +52,11 @@ public:
int priority() const;
void setPriority(int priority);
// interface for users of IProjectPanelFactory
// interface for users of ProjectPanelFactory
bool supports(Project *project);
QWidget *createWidget(ProjectExplorer::Project *project);
QWidget *createWidget(Project *project);
// interface for "implementations" of IProjectPanelFactory
// interface for "implementations" of ProjectPanelFactory
// by default all projects are supported, only set a custom supports function
// if you need something different
void setSupportsFunction(std::function<bool (Project *)> function);
......@@ -88,11 +85,10 @@ public:
m_createWidgetFunction = function;
}
static bool supportsAllProjects(Project *);
static void registerFactory(IProjectPanelFactory *factory);
// This takes ownership.
static void registerFactory(ProjectPanelFactory *factory);
static QList<IProjectPanelFactory *> factories();
static QList<ProjectPanelFactory *> factories();
private:
friend class ProjectExplorerPlugin;
......@@ -102,9 +98,8 @@ private:
QString m_displayName;
std::function<bool (Project *)> m_supportsFunction;
std::function<QWidget *(Project *)> m_createWidgetFunction;
static QList<IProjectPanelFactory *> s_factories;
};
} // namespace ProjectExplorer
#endif // IPROJECTPROPERTIES_H
#endif // PROJECTPANELFACTORY_H
......@@ -34,7 +34,7 @@
#include "kitmanager.h"
#include "project.h"
#include "projectexplorer.h"
#include "iprojectpanelfactory.h"
#include "projectpanelfactory.h"
#include "session.h"
#include "target.h"
......@@ -121,7 +121,7 @@ void ProjectWindow::projectUpdated(Project *p)
QStringList ProjectWindow::tabDisplayNamesFor(Project *project)
{
QStringList subTabs;
foreach (IProjectPanelFactory *panelFactory, IProjectPanelFactory::factories()) {
foreach (ProjectPanelFactory *panelFactory, ProjectPanelFactory::factories()) {
if (panelFactory->supports(project))
subTabs << panelFactory->displayName();
}
......@@ -214,9 +214,9 @@ void ProjectWindow::showProperties(int index, int subIndex)
// Set up custom panels again:
int pos = 0;
IProjectPanelFactory *fac = 0;
ProjectPanelFactory *fac = 0;
foreach (IProjectPanelFactory *panelFactory, IProjectPanelFactory::factories()) {
foreach (ProjectPanelFactory *panelFactory, ProjectPanelFactory::factories()) {
if (panelFactory->supports(project)) {
if (subIndex == pos) {
fac = panelFactory;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment