Commit 426890b7 authored by Tobias Hunger's avatar Tobias Hunger

Change PropertiesPanel interface.

 * Rename it to IPropertiesPanel in accordance with new naming standards.
 * Do not derive from Context. That is not needed.
 * Add an icon() method.
 * Fix all usages of this interface.

Reviewed-By: dt
parent 53a30715
...@@ -37,8 +37,8 @@ ...@@ -37,8 +37,8 @@
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/QPair> #include <QtCore/QPair>
#include <QtGui/QApplication>
#include <QtGui/QInputDialog> #include <QtGui/QInputDialog>
#include <QtGui/QLabel> #include <QtGui/QLabel>
#include <QtGui/QVBoxLayout> #include <QtGui/QVBoxLayout>
...@@ -56,7 +56,7 @@ bool BuildSettingsPanelFactory::supports(Project *project) ...@@ -56,7 +56,7 @@ bool BuildSettingsPanelFactory::supports(Project *project)
return project->hasBuildSettings(); return project->hasBuildSettings();
} }
PropertiesPanel *BuildSettingsPanelFactory::createPanel(Project *project) IPropertiesPanel *BuildSettingsPanelFactory::createPanel(Project *project)
{ {
return new BuildSettingsPanel(project); return new BuildSettingsPanel(project);
} }
...@@ -65,9 +65,9 @@ PropertiesPanel *BuildSettingsPanelFactory::createPanel(Project *project) ...@@ -65,9 +65,9 @@ PropertiesPanel *BuildSettingsPanelFactory::createPanel(Project *project)
/// BuildSettingsPanel /// BuildSettingsPanel
/// ///
BuildSettingsPanel::BuildSettingsPanel(Project *project) BuildSettingsPanel::BuildSettingsPanel(Project *project) :
: PropertiesPanel(), m_widget(new BuildSettingsWidget(project)),
m_widget(new BuildSettingsWidget(project)) m_icon(":/projectexplorer/images/rebuild.png")
{ {
} }
...@@ -78,14 +78,19 @@ BuildSettingsPanel::~BuildSettingsPanel() ...@@ -78,14 +78,19 @@ BuildSettingsPanel::~BuildSettingsPanel()
QString BuildSettingsPanel::name() const QString BuildSettingsPanel::name() const
{ {
return tr("Build Settings"); return QApplication::tr("Build Settings");
} }
QWidget *BuildSettingsPanel::widget() QWidget *BuildSettingsPanel::widget() const
{ {
return m_widget; return m_widget;
} }
QIcon BuildSettingsPanel::icon() const
{
return m_icon;
}
/// ///
// BuildSettingsSubWidgets // BuildSettingsSubWidgets
/// ///
......
...@@ -64,22 +64,23 @@ class BuildSettingsPanelFactory : public IPanelFactory ...@@ -64,22 +64,23 @@ class BuildSettingsPanelFactory : public IPanelFactory
{ {
public: public:
bool supports(Project *project); bool supports(Project *project);
PropertiesPanel *createPanel(Project *project); IPropertiesPanel *createPanel(Project *project);
}; };
class BuildSettingsWidget; class BuildSettingsWidget;
class BuildSettingsPanel : public PropertiesPanel class BuildSettingsPanel : public IPropertiesPanel
{ {
Q_OBJECT
public: public:
BuildSettingsPanel(Project *project); BuildSettingsPanel(Project *project);
~BuildSettingsPanel(); ~BuildSettingsPanel();
QString name() const; QString name() const;
QWidget *widget(); QWidget *widget() const;
QIcon icon() const;
private: private:
BuildSettingsWidget *m_widget; BuildSettingsWidget *m_widget;
const QIcon m_icon;
}; };
class BuildConfigurationsWidget; class BuildConfigurationsWidget;
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtCore/QAbstractListModel> #include <QtCore/QAbstractListModel>
#include <QtGui/QLabel> #include <QtGui/QLabel>
#include <QtGui/QApplication>
#include <QtGui/QHBoxLayout> #include <QtGui/QHBoxLayout>
#include <QtGui/QTreeView> #include <QtGui/QTreeView>
#include <QtGui/QSpacerItem> #include <QtGui/QSpacerItem>
...@@ -275,9 +276,9 @@ void DependenciesWidget::updateDetails() ...@@ -275,9 +276,9 @@ void DependenciesWidget::updateDetails()
// DependenciesPanel // DependenciesPanel
// //
DependenciesPanel::DependenciesPanel(SessionManager *session, Project *project) DependenciesPanel::DependenciesPanel(SessionManager *session, Project *project) :
: PropertiesPanel() m_widget(new DependenciesWidget(session, project)),
, m_widget(new DependenciesWidget(session, project)) m_icon(":/projectexplorer/images/session.png")
{ {
} }
...@@ -288,14 +289,19 @@ DependenciesPanel::~DependenciesPanel() ...@@ -288,14 +289,19 @@ DependenciesPanel::~DependenciesPanel()
QString DependenciesPanel::name() const QString DependenciesPanel::name() const
{ {
return tr("Dependencies"); return QApplication::tr("Dependencies");
} }
QWidget *DependenciesPanel::widget() QWidget *DependenciesPanel::widget() const
{ {
return m_widget; return m_widget;
} }
QIcon DependenciesPanel::icon() const
{
return m_icon;
}
// //
// DependenciesPanelFactory // DependenciesPanelFactory
// //
...@@ -310,7 +316,7 @@ bool DependenciesPanelFactory::supports(Project * /* project */) ...@@ -310,7 +316,7 @@ bool DependenciesPanelFactory::supports(Project * /* project */)
return true; return true;
} }
PropertiesPanel *DependenciesPanelFactory::createPanel(Project *project) IPropertiesPanel *DependenciesPanelFactory::createPanel(Project *project)
{ {
return new DependenciesPanel(m_session, project); return new DependenciesPanel(m_session, project);
} }
......
...@@ -53,24 +53,25 @@ public: ...@@ -53,24 +53,25 @@ public:
DependenciesPanelFactory(SessionManager *session); DependenciesPanelFactory(SessionManager *session);
bool supports(Project *project); bool supports(Project *project);
PropertiesPanel *createPanel(Project *project); IPropertiesPanel *createPanel(Project *project);
private: private:
SessionManager *m_session; SessionManager *m_session;
}; };
class DependenciesPanel : public PropertiesPanel class DependenciesPanel : public IPropertiesPanel
{ {
Q_OBJECT
public: public:
DependenciesPanel(SessionManager *session, Project *project); DependenciesPanel(SessionManager *session, Project *project);
~DependenciesPanel(); ~DependenciesPanel();
QString name() const; QString name() const;
QWidget *widget(); QWidget *widget() const;
QIcon icon() const;
private: private:
DependenciesWidget *m_widget; DependenciesWidget *m_widget;
const QIcon m_icon;
}; };
// //
......
...@@ -42,14 +42,15 @@ bool EditorSettingsPanelFactory::supports(Project * /*project*/) ...@@ -42,14 +42,15 @@ bool EditorSettingsPanelFactory::supports(Project * /*project*/)
{ {
return true; return true;
} }
PropertiesPanel *EditorSettingsPanelFactory::createPanel(Project *project)
IPropertiesPanel *EditorSettingsPanelFactory::createPanel(Project *project)
{ {
return new EditorSettingsPanel(project); return new EditorSettingsPanel(project);
} }
EditorSettingsPanel::EditorSettingsPanel(Project *project) EditorSettingsPanel::EditorSettingsPanel(Project *project) :
: PropertiesPanel(), m_widget(new EditorSettingsWidget(project)),
m_widget(new EditorSettingsWidget(project)) m_icon(":/projectexplorer/images/rebuild.png")
{ {
} }
...@@ -60,14 +61,19 @@ EditorSettingsPanel::~EditorSettingsPanel() ...@@ -60,14 +61,19 @@ EditorSettingsPanel::~EditorSettingsPanel()
QString EditorSettingsPanel::name() const QString EditorSettingsPanel::name() const
{ {
return tr("Editor Settings"); return QApplication::tr("Editor Settings");
} }
QWidget *EditorSettingsPanel::widget() QWidget *EditorSettingsPanel::widget() const
{ {
return m_widget; return m_widget;
} }
QIcon EditorSettingsPanel::icon() const
{
return m_icon;
}
EditorSettingsWidget::EditorSettingsWidget(Project *project) EditorSettingsWidget::EditorSettingsWidget(Project *project)
: QWidget(), : QWidget(),
m_project(project) m_project(project)
......
...@@ -41,22 +41,23 @@ class EditorSettingsPanelFactory : public IPanelFactory ...@@ -41,22 +41,23 @@ class EditorSettingsPanelFactory : public IPanelFactory
{ {
public: public:
bool supports(Project *project); bool supports(Project *project);
PropertiesPanel *createPanel(Project *project); IPropertiesPanel *createPanel(Project *project);
}; };
class EditorSettingsWidget; class EditorSettingsWidget;
class EditorSettingsPanel : public PropertiesPanel class EditorSettingsPanel : public IPropertiesPanel
{ {
Q_OBJECT
public: public:
EditorSettingsPanel(Project *project); EditorSettingsPanel(Project *project);
~EditorSettingsPanel(); ~EditorSettingsPanel();
QString name() const; QString name() const;
QWidget *widget(); QWidget *widget() const;
QIcon icon() const;
private: private:
EditorSettingsWidget *m_widget; EditorSettingsWidget *m_widget;
const QIcon m_icon;
}; };
class EditorSettingsWidget : public QWidget class EditorSettingsWidget : public QWidget
......
...@@ -32,29 +32,30 @@ ...@@ -32,29 +32,30 @@
#include "projectexplorer_export.h" #include "projectexplorer_export.h"
#include <coreplugin/icontext.h> #include <QtGui/QIcon>
namespace ProjectExplorer { namespace ProjectExplorer {
class Project; class Project;
class PropertiesPanel;
class PROJECTEXPLORER_EXPORT IPanelFactory : public QObject class PROJECTEXPLORER_EXPORT IPropertiesPanel
{ {
Q_OBJECT
public: public:
virtual bool supports(Project *project) = 0; IPropertiesPanel()
virtual PropertiesPanel *createPanel(Project *project) = 0; { }
virtual ~IPropertiesPanel()
{ }
virtual QString name() const = 0;
virtual QIcon icon() const = 0;
virtual QWidget *widget() const = 0;
}; };
class PROJECTEXPLORER_EXPORT PropertiesPanel : public Core::IContext class PROJECTEXPLORER_EXPORT IPanelFactory : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
virtual void finish() {} virtual bool supports(Project *project) = 0;
virtual QString name() const = 0; virtual IPropertiesPanel *createPanel(Project *project) = 0;
// IContext
virtual QList<int> context() const { return QList<int>(); }
}; };
} // namespace ProjectExplorer } // namespace ProjectExplorer
......
...@@ -258,7 +258,6 @@ RunConfigurationComboBox::RunConfigurationComboBox(QWidget *parent) ...@@ -258,7 +258,6 @@ RunConfigurationComboBox::RunConfigurationComboBox(QWidget *parent)
connectToProject(p); connectToProject(p);
} }
connect(session, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)), connect(session, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
this, SLOT(activeRunConfigurationChanged())); this, SLOT(activeRunConfigurationChanged()));
...@@ -556,7 +555,6 @@ void ProjectLabel::setProject(ProjectExplorer::Project *p) ...@@ -556,7 +555,6 @@ void ProjectLabel::setProject(ProjectExplorer::Project *p)
setText(tr("No Project loaded")); setText(tr("No Project loaded"));
} }
/// ///
// ProjectPushButton // ProjectPushButton
/// ///
...@@ -745,9 +743,6 @@ void ProjectWindow::saveStatus() ...@@ -745,9 +743,6 @@ void ProjectWindow::saveStatus()
void ProjectWindow::showProperties(Project *project) void ProjectWindow::showProperties(Project *project)
{ {
if (debug)
qDebug() << "ProjectWindow - showProperties called";
// Remove all existing panels: // Remove all existing panels:
m_panelsWidget->clear(); m_panelsWidget->clear();
...@@ -755,7 +750,7 @@ void ProjectWindow::showProperties(Project *project) ...@@ -755,7 +750,7 @@ void ProjectWindow::showProperties(Project *project)
qDeleteAll(m_panels); qDeleteAll(m_panels);
m_panels.clear(); m_panels.clear();
// Set up our default panels again: // Set up our default panels:
m_panelsWidget->addWidget(tr("Active Build and Run Configurations"), m_activeConfigurationWidget); m_panelsWidget->addWidget(tr("Active Build and Run Configurations"), m_activeConfigurationWidget);
m_panelsWidget->addWidget(m_spacerBetween); m_panelsWidget->addWidget(m_spacerBetween);
m_panelsWidget->addWidget(m_projectChooser); m_panelsWidget->addWidget(m_projectChooser);
...@@ -766,9 +761,7 @@ void ProjectWindow::showProperties(Project *project) ...@@ -766,9 +761,7 @@ void ProjectWindow::showProperties(Project *project)
ExtensionSystem::PluginManager::instance()->getObjects<IPanelFactory>(); ExtensionSystem::PluginManager::instance()->getObjects<IPanelFactory>();
foreach (IPanelFactory *panelFactory, pages) { foreach (IPanelFactory *panelFactory, pages) {
if (panelFactory->supports(project)) { if (panelFactory->supports(project)) {
PropertiesPanel *panel = panelFactory->createPanel(project); IPropertiesPanel *panel = panelFactory->createPanel(project);
if (debug)
qDebug() << "ProjectWindow - setting up project properties tab " << panel->name();
m_panelsWidget->addWidget(panel->name(), panel->widget()); m_panelsWidget->addWidget(panel->name(), panel->widget());
m_panels.push_back(panel); m_panels.push_back(panel);
} }
......
...@@ -52,8 +52,8 @@ QT_END_NAMESPACE ...@@ -52,8 +52,8 @@ QT_END_NAMESPACE
namespace ProjectExplorer { namespace ProjectExplorer {
class IPropertiesPanel;
class Project; class Project;
class PropertiesPanel;
class ProjectExplorerPlugin; class ProjectExplorerPlugin;
class SessionManager; class SessionManager;
...@@ -195,7 +195,7 @@ private: ...@@ -195,7 +195,7 @@ private:
QWidget *m_projectChooser; QWidget *m_projectChooser;
QLabel *m_noprojectLabel; QLabel *m_noprojectLabel;
PanelsWidget *m_panelsWidget; PanelsWidget *m_panelsWidget;
QList<PropertiesPanel *> m_panels; QList<IPropertiesPanel *> m_panels;
}; };
......
...@@ -94,7 +94,7 @@ bool RunSettingsPanelFactory::supports(Project * /* project */) ...@@ -94,7 +94,7 @@ bool RunSettingsPanelFactory::supports(Project * /* project */)
return true; return true;
} }
PropertiesPanel *RunSettingsPanelFactory::createPanel(Project *project) IPropertiesPanel *RunSettingsPanelFactory::createPanel(Project *project)
{ {
return new RunSettingsPanel(project); return new RunSettingsPanel(project);
} }
...@@ -103,9 +103,9 @@ PropertiesPanel *RunSettingsPanelFactory::createPanel(Project *project) ...@@ -103,9 +103,9 @@ PropertiesPanel *RunSettingsPanelFactory::createPanel(Project *project)
/// RunSettingsPanel /// RunSettingsPanel
/// ///
RunSettingsPanel::RunSettingsPanel(Project *project) RunSettingsPanel::RunSettingsPanel(Project *project) :
: PropertiesPanel(), m_widget(new RunSettingsWidget(project)),
m_widget(new RunSettingsWidget(project)) m_icon(":/projectexplorer/images/run.png")
{ {
} }
...@@ -116,14 +116,19 @@ RunSettingsPanel::~RunSettingsPanel() ...@@ -116,14 +116,19 @@ RunSettingsPanel::~RunSettingsPanel()
QString RunSettingsPanel::name() const QString RunSettingsPanel::name() const
{ {
return tr("Run Settings"); return QApplication::tr("Run Settings");
} }
QWidget *RunSettingsPanel::widget() QWidget *RunSettingsPanel::widget() const
{ {
return m_widget; return m_widget;
} }
QIcon RunSettingsPanel::icon() const
{
return m_icon;
}
/// ///
/// RunConfigurationsModel /// RunConfigurationsModel
/// ///
......
...@@ -53,20 +53,22 @@ class RunSettingsPanelFactory : public IPanelFactory ...@@ -53,20 +53,22 @@ class RunSettingsPanelFactory : public IPanelFactory
{ {
public: public:
virtual bool supports(Project *project); virtual bool supports(Project *project);
PropertiesPanel *createPanel(Project *project); IPropertiesPanel *createPanel(Project *project);
}; };
class RunSettingsPanel : public PropertiesPanel class RunSettingsPanel : public IPropertiesPanel
{ {
Q_OBJECT
public: public:
RunSettingsPanel(Project *project); RunSettingsPanel(Project *project);
~RunSettingsPanel(); ~RunSettingsPanel();
QString name() const; QString name() const;
QWidget *widget(); QWidget *widget() const;
QIcon icon() const;
private: private:
RunSettingsWidget *m_widget; RunSettingsWidget *m_widget;
QIcon m_icon;
}; };
class RunSettingsWidget : public QWidget class RunSettingsWidget : public QWidget
......
...@@ -54,7 +54,7 @@ bool EmbeddedPropertiesPanelFactory::supports(Project *project) ...@@ -54,7 +54,7 @@ bool EmbeddedPropertiesPanelFactory::supports(Project *project)
return false; return false;
} }