aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer/projectpanelfactory.cpp
diff options
context:
space:
mode:
authorhjk <hjk@theqtcompany.com>2016-09-14 12:55:04 +0200
committerhjk <hjk@qt.io>2016-09-14 12:31:12 +0000
commit734c348700f0a8730791b7f3f39051a5a4917c65 (patch)
treebbf4ab17ccb6440eec07bb26b7acb0eb58eb85d0 /src/plugins/projectexplorer/projectpanelfactory.cpp
parent129591cb52598696e65d9a8b5be72a6d78f1df0d (diff)
ProjectExplorer: Some polishing of the new ProjectWindow layout
This moves all non-Build&Run entries under a separate 'Project settings' entry. Internally, this mainly makes the information flow on what item a user selected and in which direction in the tree information needs updated a bit more explicit. Change-Id: I4583151356ef50b244b1d05dd77f04de2355105f Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'src/plugins/projectexplorer/projectpanelfactory.cpp')
-rw-r--r--src/plugins/projectexplorer/projectpanelfactory.cpp98
1 files changed, 4 insertions, 94 deletions
diff --git a/src/plugins/projectexplorer/projectpanelfactory.cpp b/src/plugins/projectexplorer/projectpanelfactory.cpp
index 43a7fde73b1..d734b8d336d 100644
--- a/src/plugins/projectexplorer/projectpanelfactory.cpp
+++ b/src/plugins/projectexplorer/projectpanelfactory.cpp
@@ -27,97 +27,14 @@
#include "project.h"
#include "projectwindow.h"
-#include "propertiespanel.h"
using namespace ProjectExplorer::Internal;
using namespace Utils;
namespace ProjectExplorer {
-namespace Internal {
static QList<ProjectPanelFactory *> s_factories;
-// Standard second level for the generic case: i.e. all except for the Build/Run page
-class ProjectPanelItem : public TreeItem
-{
-public:
- using WidgetCreator = std::function<QWidget *(Project *Project)>;
-
- ProjectPanelItem(ProjectPanelFactory *factory, Project *project,
- const WidgetCreator &widgetCreator)
- : m_factory(factory), m_project(project), m_widgetCreator(widgetCreator)
- {}
-
- ~ProjectPanelItem() { delete m_widget; }
-
- QVariant data(int column, int role) const override;
- Qt::ItemFlags flags(int column) const override;
- bool setData(int column, const QVariant &, int role) override;
-
-protected:
- ProjectPanelFactory *m_factory = nullptr;
- QPointer<Project> m_project;
- WidgetCreator m_widgetCreator;
-
- mutable QPointer<QWidget> m_widget = nullptr;
-};
-
-QVariant ProjectPanelItem::data(int column, int role) const
-{
- Q_UNUSED(column)
- if (role == Qt::DisplayRole) {
- if (m_factory)
- return m_factory->displayName();
- }
-
-// if (role == Qt::DecorationRole) {
-// if (m_factory)
-// return QIcon(m_factory->icon());
-// }
-
- if (role == ActiveWidgetRole) {
- if (!m_widget) {
- auto panelsWidget = new PanelsWidget;
- auto panel = new PropertiesPanel;
- panel->setDisplayName(m_factory->displayName());
- QWidget *widget = m_widgetCreator(m_project);
- panel->setWidget(widget);
- panel->setIcon(QIcon(m_factory->icon()));
- panelsWidget->addPropertiesPanel(panel);
- panelsWidget->setFocusProxy(widget);
- m_widget = panelsWidget;
- }
-
- return QVariant::fromValue<QWidget *>(m_widget.data());
- }
-
- if (role == ActiveIndexRole) // We are the active one.
- return QVariant::fromValue(index());
-
- return QVariant();
-}
-
-Qt::ItemFlags ProjectPanelItem::flags(int column) const
-{
- if (m_factory && m_project) {
- if (!m_factory->supports(m_project))
- return Qt::ItemIsSelectable;
- }
- return TreeItem::flags(column);
-}
-
-bool ProjectPanelItem::setData(int column, const QVariant &, int role)
-{
- if (role == ItemActivaterRole) {
- // Bubble up
- return parent()->setData(column, QVariant::fromValue(static_cast<TreeItem *>(this)), role);
- }
-
- return false;
-}
-
-} // Internal
-
ProjectPanelFactory::ProjectPanelFactory()
: m_supportsFunction([] (Project *) { return true; })
{ }
@@ -157,13 +74,6 @@ QList<ProjectPanelFactory *> ProjectPanelFactory::factories()
return s_factories;
}
-TreeItem *ProjectPanelFactory::createSelectorItem(Project *project)
-{
- if (m_selectorItemCreator)
- return m_selectorItemCreator(project);
- return new Internal::ProjectPanelItem(this, project, m_widgetCreator);
-}
-
void ProjectPanelFactory::destroyFactories()
{
qDeleteAll(s_factories);
@@ -180,14 +90,14 @@ void ProjectPanelFactory::setIcon(const QString &icon)
m_icon = icon;
}
-void ProjectPanelFactory::setCreateWidgetFunction(const WidgetCreator &createWidgetFunction)
+QWidget *ProjectPanelFactory::createWidget(Project *project) const
{
- m_widgetCreator = createWidgetFunction;
+ return m_widgetCreator(project);
}
-void ProjectPanelFactory::setSelectorItemCreator(const SelectorItemCreator &selectorCreator)
+void ProjectPanelFactory::setCreateWidgetFunction(const WidgetCreator &createWidgetFunction)
{
- m_selectorItemCreator = selectorCreator;
+ m_widgetCreator = createWidgetFunction;
}
bool ProjectPanelFactory::supports(Project *project)