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