Commit bd319da2 authored by Jochen Becher's avatar Jochen Becher

ModelEditor: Introduce factory for properties view class

The factory allows usage of inherited view class for easy properties
extensions.

Change-Id: I73303a9c6f96df48dea508eadb9e829af32cdbe5
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 9bfd7826
......@@ -43,6 +43,7 @@ PropertiesView::PropertiesView(QObject *parent)
m_diagramController(0),
m_stereotypeController(0),
m_styleController(0),
m_viewFactory([=](PropertiesView *propertiesView) { return new MView(propertiesView); }),
m_selectedDiagram(0),
m_widget(0)
{
......@@ -149,6 +150,11 @@ void PropertiesView::setStyleController(StyleController *styleController)
m_styleController = styleController;
}
void PropertiesView::setMViewFactory(std::function<MView *(PropertiesView *)> factory)
{
m_viewFactory = factory;
}
void PropertiesView::setSelectedModelElements(const QList<MElement *> &modelElements)
{
QMT_CHECK(modelElements.size() > 0);
......@@ -157,7 +163,7 @@ void PropertiesView::setSelectedModelElements(const QList<MElement *> &modelElem
m_selectedModelElements = modelElements;
m_selectedDiagramElements.clear();
m_selectedDiagram = 0;
m_mview.reset(new MView(this));
m_mview.reset(m_viewFactory(this));
m_mview->update(m_selectedModelElements);
m_widget = m_mview->topLevelWidget();
}
......@@ -172,7 +178,7 @@ void PropertiesView::setSelectedDiagramElements(const QList<DElement *> &diagram
m_selectedDiagramElements = diagramElements;
m_selectedDiagram = diagram;
m_selectedModelElements.clear();
m_mview.reset(new MView(this));
m_mview.reset(m_viewFactory(this));
m_mview->update(m_selectedDiagramElements, m_selectedDiagram);
m_widget = m_mview->topLevelWidget();
}
......
......@@ -31,6 +31,7 @@
#include "qmt/infrastructure/qmt_global.h"
#include <QScopedPointer>
#include <functional>
QT_BEGIN_NAMESPACE
class QWidget;
......@@ -51,9 +52,10 @@ class StyleController;
class QMT_EXPORT PropertiesView : public QObject
{
Q_OBJECT
class MView;
public:
class MView;
explicit PropertiesView(QObject *parent = 0);
~PropertiesView() override;
......@@ -65,6 +67,7 @@ public:
void setStereotypeController(StereotypeController *stereotypeController);
StyleController *styleController() const { return m_styleController; }
void setStyleController(StyleController *styleController);
void setMViewFactory(std::function<MView *(PropertiesView *)> factory);
QList<MElement *> selectedModelElements() const { return m_selectedModelElements; }
void setSelectedModelElements(const QList<MElement *> &modelElements);
......@@ -118,6 +121,7 @@ private:
DiagramController *m_diagramController;
StereotypeController *m_stereotypeController;
StyleController *m_styleController;
std::function<MView *(PropertiesView *)> m_viewFactory;
QList<MElement *> m_selectedModelElements;
QList<DElement *> m_selectedDiagramElements;
MDiagram *m_selectedDiagram;
......
......@@ -98,7 +98,7 @@ public:
void update(QList<DElement *> &diagramElements, MDiagram *diagram);
void edit();
private:
protected:
void onStereotypesChanged(const QString &stereotypes);
void onObjectNameChanged(const QString &name);
void onNamespaceChanged(const QString &umlNamespace);
......
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