ProjectExplorer: Remove IPanelFactory

This was the common base class of IProjectPanelFactory and
ITargetPanelFactory. Nothing was using the IPanelFactory interface, and
there's actually no common interface between those classes.

Of the old interface IPanelFactory:
id() => only used in ITargetPanelFactory
displayName() => only used in IProjectPanelFactory
priority() => only used in IProjectPanelFactory

This removes lots of boiler plate code for the unused functions.

Change-Id: I8488a4e5134fd451907f02c45b7847673e4dc714
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
Daniel Teske
2014-07-11 13:20:40 +02:00
parent f42358a16e
commit 96d9f05fad
17 changed files with 12 additions and 80 deletions

View File

@@ -38,14 +38,6 @@
using namespace ProjectExplorer;
using namespace ClangCodeModel::Internal;
static const char CLANGPROJECTSETTINGS_PANEL_ID[] = "ClangCodeModel.ProjectPanel";
QString ClangProjectSettingsPanelFactory::id() const
{
return QLatin1String(CLANGPROJECTSETTINGS_PANEL_ID);
}
QString ClangProjectSettingsPanelFactory::displayName() const
{
return ClangProjectSettingsWidget::tr("Clang Settings");

View File

@@ -42,7 +42,6 @@ namespace Internal {
class ClangProjectSettingsPanelFactory: public ProjectExplorer::IProjectPanelFactory
{
public:
QString id() const;
QString displayName() const;
int priority() const;
bool supports(ProjectExplorer::Project *project);

View File

@@ -62,16 +62,6 @@ QString BuildSettingsPanelFactory::id() const
return QLatin1String(BUILDSETTINGS_PANEL_ID);
}
QString BuildSettingsPanelFactory::displayName() const
{
return QCoreApplication::translate("BuildSettingsPanelFactory", "Build Settings");
}
int BuildSettingsPanelFactory::priority() const
{
return 10;
}
bool BuildSettingsPanelFactory::supports(Target *target)
{
return IBuildConfigurationFactory::find(target);

View File

@@ -56,8 +56,6 @@ class BuildSettingsPanelFactory : public ITargetPanelFactory
{
public:
QString id() const;
QString displayName() const;
int priority() const;
bool supports(Target *target);
PropertiesPanel *createPanel(Target *target);

View File

@@ -38,11 +38,6 @@ using namespace TextEditor;
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;
QString CodeStyleSettingsPanelFactory::id() const
{
return QLatin1String(CODESTYLESETTINGS_PANEL_ID);
}
QString CodeStyleSettingsPanelFactory::displayName() const
{
return QCoreApplication::translate("CodeStyleSettingsPanelFactory", "Code Style");

View File

@@ -39,12 +39,9 @@ class EditorConfiguration;
namespace Internal {
const char CODESTYLESETTINGS_PANEL_ID[] = "ProjectExplorer.CodeStyleSettingsPanel";
class CodeStyleSettingsPanelFactory : public IProjectPanelFactory
{
public:
QString id() const;
QString displayName() const;
int priority() const;
PropertiesPanel *createPanel(Project *project);

View File

@@ -235,11 +235,6 @@ DependenciesWidget::DependenciesWidget(Project *project, QWidget *parent)
// DependenciesPanelFactory
//
QString DependenciesPanelFactory::id() const
{
return QLatin1String("ProjectExplorer.DependenciesPanel");
}
QString DependenciesPanelFactory::displayName() const
{
return QCoreApplication::translate("DependenciesPanelFactory", "Dependencies");

View File

@@ -49,7 +49,6 @@ class DependenciesPanelFactory : public IProjectPanelFactory
public:
DependenciesPanelFactory() {}
QString id() const;
QString displayName() const;
int priority() const;
bool supports(Project *project);

View File

@@ -37,11 +37,6 @@
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;
QString EditorSettingsPanelFactory::id() const
{
return QLatin1String(EDITORSETTINGS_PANEL_ID);
}
QString EditorSettingsPanelFactory::displayName() const
{
return QCoreApplication::translate("EditorSettingsPanelFactory", "Editor");

View File

@@ -39,12 +39,9 @@ class EditorConfiguration;
namespace Internal {
const char EDITORSETTINGS_PANEL_ID[] = "ProjectExplorer.EditorSettingsPanel";
class EditorSettingsPanelFactory : public IProjectPanelFactory
{
public:
QString id() const;
QString displayName() const;
int priority() const;
PropertiesPanel *createPanel(Project *project);

View File

@@ -66,32 +66,28 @@ private:
QIcon m_icon;
};
class PROJECTEXPLORER_EXPORT IPanelFactory : public QObject
{
Q_OBJECT
public:
virtual QString id() const = 0;
virtual QString displayName() const = 0;
virtual int priority() const = 0;
static bool prioritySort(IPanelFactory *a, IPanelFactory *b)
{ return (a->priority() == b->priority() && a->id() < b->id())
|| a->priority() < b->priority(); }
};
class PROJECTEXPLORER_EXPORT IProjectPanelFactory : public IPanelFactory
class PROJECTEXPLORER_EXPORT IProjectPanelFactory : public QObject
{
Q_OBJECT
public:
virtual bool supports(Project *project) = 0;
virtual PropertiesPanel *createPanel(Project *project) = 0;
virtual QString displayName() const = 0;
virtual int priority() const = 0;
static bool prioritySort(IProjectPanelFactory *a, IProjectPanelFactory *b)
{ return (a->priority() == b->priority() && a < b)
|| a->priority() < b->priority(); }
};
class PROJECTEXPLORER_EXPORT ITargetPanelFactory : public IPanelFactory
class PROJECTEXPLORER_EXPORT ITargetPanelFactory : public QObject
{
Q_OBJECT
public:
virtual bool supports(Target *target) = 0;
virtual PropertiesPanel *createPanel(Target *target) = 0;
virtual QString id() const = 0;
};
} // namespace ProjectExplorer

View File

@@ -258,9 +258,6 @@ const char HIDE_FILE_FILTER_DEFAULT[] = "Makefile*; *.o; *.lo; *.la; *.obj; *~;
const char SHOW_FILE_FILTER_SETTING[] = "GenericProject/ShowFileFilter";
const char SHOW_FILE_FILTER_DEFAULT[] = "*.c; *.cc; *.cpp; *.cp; *.cxx; *.c++; *.h; *.hh; *.hpp; *.hxx;";
// Unconfigured Panel
const char UNCONFIGURED_PANEL_PAGE_ID[] = "UnconfiguredPanel";
} // namespace Constants
// Run modes

View File

@@ -340,7 +340,7 @@ void ProjectWindow::registerProject(ProjectExplorer::Project *project)
// Add the project specific pages
QList<IProjectPanelFactory *> factories = ExtensionSystem::PluginManager::getObjects<IProjectPanelFactory>();
Utils::sort(factories, &IPanelFactory::prioritySort);
Utils::sort(factories, &IProjectPanelFactory::prioritySort);
foreach (IProjectPanelFactory *panelFactory, factories) {
if (panelFactory->supports(project))
subtabs << panelFactory->displayName();
@@ -399,7 +399,7 @@ void ProjectWindow::showProperties(int index, int subIndex)
}
QList<IProjectPanelFactory *> factories = ExtensionSystem::PluginManager::getObjects<IProjectPanelFactory>();
Utils::sort(factories, &IPanelFactory::prioritySort);
Utils::sort(factories, &IProjectPanelFactory::prioritySort);
foreach (IProjectPanelFactory *panelFactory, factories) {
if (panelFactory->supports(project)) {
if (subIndex == pos) {

View File

@@ -91,16 +91,6 @@ QString RunSettingsPanelFactory::id() const
return QLatin1String(RUNSETTINGS_PANEL_ID);
}
QString RunSettingsPanelFactory::displayName() const
{
return RunSettingsWidget::tr("Run Settings");
}
int RunSettingsPanelFactory::priority() const
{
return 20;
}
bool RunSettingsPanelFactory::supports(Target *target)
{
Q_UNUSED(target);

View File

@@ -62,8 +62,6 @@ class RunSettingsPanelFactory : public ITargetPanelFactory
{
public:
QString id() const;
QString displayName() const;
int priority() const;
bool supports(Target *target);
PropertiesPanel *createPanel(Target *target);
};

View File

@@ -52,11 +52,6 @@ UnconfiguredProjectPanel::UnconfiguredProjectPanel()
{
}
QString UnconfiguredProjectPanel::id() const
{
return QLatin1String(Constants::UNCONFIGURED_PANEL_PAGE_ID);
}
QString UnconfiguredProjectPanel::displayName() const
{
return tr("Configure Project");

View File

@@ -47,7 +47,6 @@ class UnconfiguredProjectPanel : public IProjectPanelFactory
Q_OBJECT
public:
UnconfiguredProjectPanel();
virtual QString id() const;
virtual QString displayName() const;
int priority() const;
virtual bool supports(Project *project);