aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer
diff options
context:
space:
mode:
authordt <qtc-committer@nokia.com>2010-03-25 16:16:38 +0100
committerdt <qtc-committer@nokia.com>2010-03-25 18:02:14 +0100
commit70dc75990f7d827e27d49fb981ff648a7d08a0ca (patch)
tree038a7b4c64626fd14d17612012c5d6bd25f5298e /src/plugins/projectexplorer
parent184fd353d294d9688919b8861b370ffa0733e046 (diff)
Simplfy code dealing with the projects page
Distinguish between pages that are target specific and project specific. Do the magic hierarchy reduction if only one target is supported just in the projectwindow. Treat the targets page specially. Reviewed-By: hunger
Diffstat (limited to 'src/plugins/projectexplorer')
-rw-r--r--src/plugins/projectexplorer/buildsettingspropertiespage.cpp12
-rw-r--r--src/plugins/projectexplorer/buildsettingspropertiespage.h5
-rw-r--r--src/plugins/projectexplorer/dependenciespanel.cpp12
-rw-r--r--src/plugins/projectexplorer/dependenciespanel.h5
-rw-r--r--src/plugins/projectexplorer/editorsettingspropertiespage.cpp12
-rw-r--r--src/plugins/projectexplorer/editorsettingspropertiespage.h6
-rw-r--r--src/plugins/projectexplorer/iprojectproperties.h17
-rw-r--r--src/plugins/projectexplorer/projectexplorer.cpp1
-rw-r--r--src/plugins/projectexplorer/projectwindow.cpp117
-rw-r--r--src/plugins/projectexplorer/projectwindow.h1
-rw-r--r--src/plugins/projectexplorer/runsettingspropertiespage.cpp11
-rw-r--r--src/plugins/projectexplorer/runsettingspropertiespage.h4
-rw-r--r--src/plugins/projectexplorer/targetsettingspanel.cpp67
-rw-r--r--src/plugins/projectexplorer/targetsettingspanel.h29
14 files changed, 91 insertions, 208 deletions
diff --git a/src/plugins/projectexplorer/buildsettingspropertiespage.cpp b/src/plugins/projectexplorer/buildsettingspropertiespage.cpp
index deaac21513..273366a195 100644
--- a/src/plugins/projectexplorer/buildsettingspropertiespage.cpp
+++ b/src/plugins/projectexplorer/buildsettingspropertiespage.cpp
@@ -65,23 +65,11 @@ QString BuildSettingsPanelFactory::displayName() const
return QCoreApplication::translate("BuildSettingsPanelFactory", "Build Settings");
}
-bool BuildSettingsPanelFactory::supports(Project *project)
-{
- return project->targets().count() == 1;
-}
-
bool BuildSettingsPanelFactory::supports(Target *target)
{
return target->buildConfigurationFactory();
}
-
-IPropertiesPanel *BuildSettingsPanelFactory::createPanel(Project *project)
-{
- Q_ASSERT(supports(project));
- return new BuildSettingsPanel(project->activeTarget());
-}
-
IPropertiesPanel *BuildSettingsPanelFactory::createPanel(Target *target)
{
return new BuildSettingsPanel(target);
diff --git a/src/plugins/projectexplorer/buildsettingspropertiespage.h b/src/plugins/projectexplorer/buildsettingspropertiespage.h
index 05ceb15876..5a38dba627 100644
--- a/src/plugins/projectexplorer/buildsettingspropertiespage.h
+++ b/src/plugins/projectexplorer/buildsettingspropertiespage.h
@@ -51,14 +51,13 @@ namespace Internal {
const char * const BUILDSETTINGS_PANEL_ID("ProjectExplorer.BuildSettingsPanel");
-class BuildSettingsPanelFactory : public IPanelFactory
+class BuildSettingsPanelFactory : public ITargetPanelFactory
{
public:
QString id() const;
QString displayName() const;
- bool supports(Project *project);
+
bool supports(Target *target);
- IPropertiesPanel *createPanel(Project *project);
IPropertiesPanel *createPanel(Target *target);
};
diff --git a/src/plugins/projectexplorer/dependenciespanel.cpp b/src/plugins/projectexplorer/dependenciespanel.cpp
index ea1846d659..d5177af9a7 100644
--- a/src/plugins/projectexplorer/dependenciespanel.cpp
+++ b/src/plugins/projectexplorer/dependenciespanel.cpp
@@ -308,22 +308,10 @@ bool DependenciesPanelFactory::supports(Project *project)
return true;
}
-bool DependenciesPanelFactory::supports(Target *target)
-{
- Q_UNUSED(target);
- return false;
-}
-
IPropertiesPanel *DependenciesPanelFactory::createPanel(Project *project)
{
return new DependenciesPanel(m_session, project);
}
-IPropertiesPanel *DependenciesPanelFactory::createPanel(Target *target)
-{
- Q_UNUSED(target);
- return 0;
-}
-
} // namespace Internal
} // namespace ProjectExplorer
diff --git a/src/plugins/projectexplorer/dependenciespanel.h b/src/plugins/projectexplorer/dependenciespanel.h
index 549251164e..8d6833a3b3 100644
--- a/src/plugins/projectexplorer/dependenciespanel.h
+++ b/src/plugins/projectexplorer/dependenciespanel.h
@@ -51,7 +51,7 @@ const char * const DEPENDENCIES_PANEL_ID("ProjectExplorer.DependenciesPanel");
class DependenciesWidget;
-class DependenciesPanelFactory : public IPanelFactory
+class DependenciesPanelFactory : public IProjectPanelFactory
{
public:
DependenciesPanelFactory(SessionManager *session);
@@ -59,10 +59,7 @@ public:
QString id() const;
QString displayName() const;
bool supports(Project *project);
- bool supports(Target *target);
IPropertiesPanel *createPanel(Project *project);
- IPropertiesPanel *createPanel(Target *target);
-
private:
SessionManager *m_session;
};
diff --git a/src/plugins/projectexplorer/editorsettingspropertiespage.cpp b/src/plugins/projectexplorer/editorsettingspropertiespage.cpp
index 129cc20dfd..aa341aeb92 100644
--- a/src/plugins/projectexplorer/editorsettingspropertiespage.cpp
+++ b/src/plugins/projectexplorer/editorsettingspropertiespage.cpp
@@ -54,23 +54,11 @@ bool EditorSettingsPanelFactory::supports(Project *project)
return true;
}
-bool EditorSettingsPanelFactory::supports(Target *target)
-{
- Q_UNUSED(target);
- return false;
-}
-
IPropertiesPanel *EditorSettingsPanelFactory::createPanel(Project *project)
{
return new EditorSettingsPanel(project);
}
-IPropertiesPanel *EditorSettingsPanelFactory::createPanel(Target *target)
-{
- Q_UNUSED(target);
- return 0;
-}
-
EditorSettingsPanel::EditorSettingsPanel(Project *project) :
m_widget(new EditorSettingsWidget(project)),
m_icon(":/projectexplorer/images/EditorSettings.png")
diff --git a/src/plugins/projectexplorer/editorsettingspropertiespage.h b/src/plugins/projectexplorer/editorsettingspropertiespage.h
index de49357a86..e47c2ec78d 100644
--- a/src/plugins/projectexplorer/editorsettingspropertiespage.h
+++ b/src/plugins/projectexplorer/editorsettingspropertiespage.h
@@ -39,15 +39,13 @@ namespace Internal {
const char * const EDITORSETTINGS_PANEL_ID("ProjectExplorer.EditorSettingsPanel");
-class EditorSettingsPanelFactory : public IPanelFactory
+class EditorSettingsPanelFactory : public IProjectPanelFactory
{
public:
QString id() const;
QString displayName() const;
- bool supports(Project *project);
- bool supports(Target *target);
IPropertiesPanel *createPanel(Project *project);
- IPropertiesPanel *createPanel(Target *target);
+ bool supports(Project *project);
};
class EditorSettingsWidget;
diff --git a/src/plugins/projectexplorer/iprojectproperties.h b/src/plugins/projectexplorer/iprojectproperties.h
index 9ca68c4c39..63b7df301f 100644
--- a/src/plugins/projectexplorer/iprojectproperties.h
+++ b/src/plugins/projectexplorer/iprojectproperties.h
@@ -47,8 +47,7 @@ class PROJECTEXPLORER_EXPORT IPropertiesPanel
public:
enum PanelFlag {
NoFlag = 0x00,
- NoLeftMargin = 0x01,
- NoAutomaticStyle = 0x02
+ NoLeftMargin = 0x01
};
Q_DECLARE_FLAGS(PanelFlags, PanelFlag)
@@ -69,9 +68,21 @@ class PROJECTEXPLORER_EXPORT IPanelFactory : public QObject
public:
virtual QString id() const = 0;
virtual QString displayName() const = 0;
+};
+
+class PROJECTEXPLORER_EXPORT IProjectPanelFactory : public IPanelFactory
+{
+ Q_OBJECT
+public:
virtual bool supports(Project *project) = 0;
- virtual bool supports(Target *target) = 0;
virtual IPropertiesPanel *createPanel(Project *project) = 0;
+};
+
+class PROJECTEXPLORER_EXPORT ITargetPanelFactory : public IPanelFactory
+{
+ Q_OBJECT
+public:
+ virtual bool supports(Target *target) = 0;
virtual IPropertiesPanel *createPanel(Target *target) = 0;
};
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp
index 40be6f84bc..ea5d2727f4 100644
--- a/src/plugins/projectexplorer/projectexplorer.cpp
+++ b/src/plugins/projectexplorer/projectexplorer.cpp
@@ -304,7 +304,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
addAutoReleasedObject(new BuildSettingsPanelFactory);
addAutoReleasedObject(new RunSettingsPanelFactory);
- addAutoReleasedObject(new TargetSettingsPanelFactory);
addAutoReleasedObject(new EditorSettingsPanelFactory);
addAutoReleasedObject(new DependenciesPanelFactory(d->m_session));
diff --git a/src/plugins/projectexplorer/projectwindow.cpp b/src/plugins/projectexplorer/projectwindow.cpp
index c2cb2c28bc..b1cd90e9d3 100644
--- a/src/plugins/projectexplorer/projectwindow.cpp
+++ b/src/plugins/projectexplorer/projectwindow.cpp
@@ -72,28 +72,7 @@ const int ABOVE_HEADING_MARGIN(10);
const int ABOVE_CONTENTS_MARGIN(4);
const int BELOW_CONTENTS_MARGIN(16);
-bool skipPanelFactory(Project *project, IPanelFactory *factory)
-{
- bool simplifyTargets(project->supportedTargetIds().count() <= 1);
- if (simplifyTargets) {
- // Do not show the targets list:
- if (factory->id() == QLatin1String(TARGETSETTINGS_PANEL_ID))
- return true;
- // Skip build settigns if none are available anyway:
- if (project->activeTarget() &&
- !project->activeTarget()->buildConfigurationFactory() &&
- factory->id() == QLatin1String(BUILDSETTINGS_PANEL_ID))
- return true;
- } else {
- // Skip panels embedded into the targets panel:
- if (factory->id() == QLatin1String(BUILDSETTINGS_PANEL_ID) ||
- factory->id() == QLatin1String(RUNSETTINGS_PANEL_ID))
- return true;
- }
- return false;
-}
-
-} // namespace
+} // anonymous namespace
///
// OnePixelBlackLine
@@ -251,8 +230,7 @@ void PanelsWidget::addPanelWidget(IPropertiesPanel *panel, int row)
ProjectWindow::ProjectWindow(QWidget *parent)
: QWidget(parent),
- m_currentWidget(0),
- m_currentPanel(0)
+ m_currentWidget(0)
{
ProjectExplorer::SessionManager *session = ProjectExplorerPlugin::instance()->session();
@@ -314,10 +292,26 @@ void ProjectWindow::registerProject(ProjectExplorer::Project *project)
}
QStringList subtabs;
- foreach (IPanelFactory *panelFactory, ExtensionSystem::PluginManager::instance()->getObjects<IPanelFactory>()) {
- if (skipPanelFactory(project, panelFactory))
- continue;
- subtabs << panelFactory->displayName();
+ if (project->supportedTargetIds().count() <= 1) {
+ // Show the target specific pages directly
+ QList<ITargetPanelFactory *> factories =
+ ExtensionSystem::PluginManager::instance()->getObjects<ITargetPanelFactory>();
+
+ foreach (ITargetPanelFactory *factory, factories) {
+ if (factory->supports(project->activeTarget()))
+ subtabs << factory->displayName();
+ }
+ } else {
+ // Use the Targets page
+ subtabs << QCoreApplication::translate("TargetSettingsPanelFactory", "Targets");
+ }
+
+ // Add the project specific pages
+
+ QList<IProjectPanelFactory *> factories = ExtensionSystem::PluginManager::instance()->getObjects<IProjectPanelFactory>();
+ foreach (IProjectPanelFactory *panelFactory, factories) {
+ if (panelFactory->supports(project))
+ subtabs << panelFactory->displayName();
}
m_tabIndexToProject.insert(index, project);
@@ -378,26 +372,59 @@ void ProjectWindow::showProperties(int index, int subIndex)
// Set up custom panels again:
int pos = 0;
- foreach (IPanelFactory *panelFactory, ExtensionSystem::PluginManager::instance()->getObjects<IPanelFactory>()) {
- if (skipPanelFactory(project, panelFactory))
- continue;
- if (pos == subIndex) {
+ IPanelFactory *fac = 0;
+ if (project->supportedTargetIds().count() > 1) {
+ if (subIndex == 0) {
+ // Targets page
removeCurrentWidget();
- IPropertiesPanel *panel(panelFactory->createPanel(project));
- if (panel->flags() & IPropertiesPanel::NoAutomaticStyle) {
- m_currentWidget = panel->widget();
- m_currentPanel = panel;
- } else {
- PanelsWidget *panelsWidget = new PanelsWidget(m_centralWidget);
- panelsWidget->addPropertiesPanel(panel);
- m_currentWidget = panelsWidget;
- }
+ m_currentWidget = new TargetSettingsPanelWidget(project);
m_centralWidget->addWidget(m_currentWidget);
m_centralWidget->setCurrentWidget(m_currentWidget);
- break;
}
++pos;
+ } else {
+ // No Targets page, target specific pages are first in the list
+ foreach (ITargetPanelFactory *panelFactory, ExtensionSystem::PluginManager::instance()->getObjects<ITargetPanelFactory>()) {
+ if (panelFactory->supports(project->activeTarget())) {
+ if (subIndex == pos) {
+ fac = panelFactory;
+ break;
+ }
+ ++pos;
+ }
+ }
+ }
+
+ if (!fac) {
+ foreach (IProjectPanelFactory *panelFactory, ExtensionSystem::PluginManager::instance()->getObjects<IProjectPanelFactory>()) {
+ if (panelFactory->supports(project)) {
+ if (subIndex == pos) {
+ fac = panelFactory;
+ break;
+ }
+ ++pos;
+ }
+ }
}
+
+ if (fac) {
+ removeCurrentWidget();
+
+ IPropertiesPanel *panel;
+ if (ITargetPanelFactory *ipf = qobject_cast<ITargetPanelFactory *>(fac))
+ panel = ipf->createPanel(project->activeTarget());
+ else if (IProjectPanelFactory *ipf = qobject_cast<IProjectPanelFactory *>(fac))
+ panel = ipf->createPanel(project);
+ Q_ASSERT(panel);
+
+ PanelsWidget *panelsWidget = new PanelsWidget(m_centralWidget);
+ panelsWidget->addPropertiesPanel(panel);
+ m_currentWidget = panelsWidget;
+ m_centralWidget->addWidget(m_currentWidget);
+ m_centralWidget->setCurrentWidget(m_currentWidget);
+
+ }
+
ProjectExplorerPlugin::instance()->session()->setStartupProject(project);
}
@@ -405,11 +432,7 @@ void ProjectWindow::removeCurrentWidget()
{
if (m_currentWidget) {
m_centralWidget->removeWidget(m_currentWidget);
- if (m_currentPanel) {
- delete m_currentPanel;
- m_currentPanel = 0;
- m_currentWidget = 0; // is deleted by the panel
- } else if (m_currentWidget) {
+ if (m_currentWidget) {
delete m_currentWidget;
m_currentWidget = 0;
}
diff --git a/src/plugins/projectexplorer/projectwindow.h b/src/plugins/projectexplorer/projectwindow.h
index cb3a81892a..571aeccbe7 100644
--- a/src/plugins/projectexplorer/projectwindow.h
+++ b/src/plugins/projectexplorer/projectwindow.h
@@ -102,7 +102,6 @@ private:
DoubleTabWidget *m_tabWidget;
QStackedWidget *m_centralWidget;
QWidget *m_currentWidget;
- IPropertiesPanel *m_currentPanel;
QList<ProjectExplorer::Project *> m_tabIndexToProject;
};
diff --git a/src/plugins/projectexplorer/runsettingspropertiespage.cpp b/src/plugins/projectexplorer/runsettingspropertiespage.cpp
index 7384076972..a53e2eea60 100644
--- a/src/plugins/projectexplorer/runsettingspropertiespage.cpp
+++ b/src/plugins/projectexplorer/runsettingspropertiespage.cpp
@@ -74,23 +74,12 @@ QString RunSettingsPanelFactory::displayName() const
return QCoreApplication::translate("RunSettingsPanelFactory", "Run Settings");
}
-bool RunSettingsPanelFactory::supports(Project *project)
-{
- return project->targets().count() == 1;
-}
-
bool RunSettingsPanelFactory::supports(Target *target)
{
Q_UNUSED(target);
return true;
}
-IPropertiesPanel *RunSettingsPanelFactory::createPanel(Project *project)
-{
- Q_ASSERT(supports(project));
- return new RunSettingsPanel(project->activeTarget());
-}
-
IPropertiesPanel *RunSettingsPanelFactory::createPanel(Target *target)
{
return new RunSettingsPanel(target);
diff --git a/src/plugins/projectexplorer/runsettingspropertiespage.h b/src/plugins/projectexplorer/runsettingspropertiespage.h
index 033d61e8a9..9393437a5a 100644
--- a/src/plugins/projectexplorer/runsettingspropertiespage.h
+++ b/src/plugins/projectexplorer/runsettingspropertiespage.h
@@ -55,14 +55,12 @@ class RunSettingsPropertiesPage;
class RunConfigurationsModel;
class RunSettingsWidget;
-class RunSettingsPanelFactory : public IPanelFactory
+class RunSettingsPanelFactory : public ITargetPanelFactory
{
public:
QString id() const;
QString displayName() const;
- bool supports(Project *project);
bool supports(Target *target);
- IPropertiesPanel *createPanel(Project *project);
IPropertiesPanel *createPanel(Target *target);
};
diff --git a/src/plugins/projectexplorer/targetsettingspanel.cpp b/src/plugins/projectexplorer/targetsettingspanel.cpp
index 7d289574d2..e988996846 100644
--- a/src/plugins/projectexplorer/targetsettingspanel.cpp
+++ b/src/plugins/projectexplorer/targetsettingspanel.cpp
@@ -47,71 +47,6 @@
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;
-///
-// TargetSettingsPanelFactory
-///
-
-QString TargetSettingsPanelFactory::id() const
-{
- return QLatin1String(TARGETSETTINGS_PANEL_ID);
-}
-
-QString TargetSettingsPanelFactory::displayName() const
-{
- return QCoreApplication::translate("TargetSettingsPanelFactory", "Targets");
-}
-
-bool TargetSettingsPanelFactory::supports(Project *project)
-{
- Q_UNUSED(project);
- return true;
-}
-
-bool TargetSettingsPanelFactory::supports(Target *target)
-{
- Q_UNUSED(target);
- return false;
-}
-
-IPropertiesPanel *TargetSettingsPanelFactory::createPanel(Project *project)
-{
- return new TargetSettingsPanel(project);
-}
-
-IPropertiesPanel *TargetSettingsPanelFactory::createPanel(Target *target)
-{
- Q_UNUSED(target);
- return 0;
-}
-
-///
-// TargetSettingsPanel
-///
-
-TargetSettingsPanel::TargetSettingsPanel(Project *project) :
- m_widget(new TargetSettingsPanelWidget(project))
-{
-}
-
-TargetSettingsPanel::~TargetSettingsPanel()
-{
- delete m_widget;
-}
-
-QString TargetSettingsPanel::displayName() const
-{
- return QCoreApplication::translate("TargetSettingsPanel", "Targets");
-}
-
-QWidget *TargetSettingsPanel::widget() const
-{
- return m_widget;
-}
-
-QIcon TargetSettingsPanel::icon() const
-{
- return QIcon();
-}
///
// TargetSettingsWidget
@@ -223,7 +158,7 @@ void TargetSettingsPanelWidget::currentTargetChanged(int targetIndex, int subInd
PanelsWidget *buildPanel(new PanelsWidget(m_centralWidget));
PanelsWidget *runPanel(new PanelsWidget(m_centralWidget));
- foreach (IPanelFactory *panelFactory, ExtensionSystem::PluginManager::instance()->getObjects<IPanelFactory>()) {
+ foreach (ITargetPanelFactory *panelFactory, ExtensionSystem::PluginManager::instance()->getObjects<ITargetPanelFactory>()) {
if (panelFactory->id() == QLatin1String(BUILDSETTINGS_PANEL_ID)) {
IPropertiesPanel *panel = panelFactory->createPanel(target);
buildPanel->addPropertiesPanel(panel);
diff --git a/src/plugins/projectexplorer/targetsettingspanel.h b/src/plugins/projectexplorer/targetsettingspanel.h
index 704854344e..4b26c768fb 100644
--- a/src/plugins/projectexplorer/targetsettingspanel.h
+++ b/src/plugins/projectexplorer/targetsettingspanel.h
@@ -41,38 +41,9 @@ class Target;
namespace Internal {
-const char * const TARGETSETTINGS_PANEL_ID("ProjectExplorer.TargetSettingsPanel");
-
class TargetSettingsWidget;
class PanelsWidget;
-class TargetSettingsPanelFactory : public IPanelFactory
-{
-public:
- QString id() const;
- QString displayName() const;
- bool supports(Project *project);
- bool supports(Target *target);
- IPropertiesPanel *createPanel(Project *project);
- IPropertiesPanel *createPanel(Target *target);
-};
-
-class TargetSettingsPanelWidget;
-
-class TargetSettingsPanel : public IPropertiesPanel
-{
-public:
- TargetSettingsPanel(Project *project);
- ~TargetSettingsPanel();
- QString displayName() const;
- QWidget *widget() const;
- QIcon icon() const;
- PanelFlags flags() const { return IPropertiesPanel::NoAutomaticStyle; }
-
-private:
- TargetSettingsPanelWidget *m_widget;
-};
-
class TargetSettingsPanelWidget : public QWidget
{
Q_OBJECT