From 27f261f0b711c7d3d7e9fbb36b37763dfabc49e2 Mon Sep 17 00:00:00 2001
From: Marco Bubke <marco.bubke@digia.com>
Date: Tue, 19 Mar 2013 13:35:43 +0100
Subject: [PATCH] QmlDesigner: Refactor designer actions

Change-Id: Ie9c71e564e66874b0715ed35cfacc578ad8b58b0
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
---
 .../componentcore/abstractdesigneraction.h    |  2 +-
 .../componentcore/defaultdesigneraction.cpp   |  2 +-
 .../componentcore/defaultdesigneraction.h     |  6 +-
 .../componentcore/designeractionmanager.cpp   |  6 +-
 .../componentcore/modelnodecontextmenu.cpp    |  4 +-
 .../modelnodecontextmenu_helper.h             |  8 +-
 .../componentcore/modelnodeoperations.cpp     | 84 ++++++++---------
 .../componentcore/selectioncontext.cpp        | 89 ++++++++++++++++---
 .../componentcore/selectioncontext.h          | 56 ++++--------
 9 files changed, 150 insertions(+), 107 deletions(-)

diff --git a/src/plugins/qmldesigner/components/componentcore/abstractdesigneraction.h b/src/plugins/qmldesigner/components/componentcore/abstractdesigneraction.h
index f50fa16d560..10d92cff15a 100644
--- a/src/plugins/qmldesigner/components/componentcore/abstractdesigneraction.h
+++ b/src/plugins/qmldesigner/components/componentcore/abstractdesigneraction.h
@@ -61,7 +61,7 @@ public:
     virtual QString menuId() const = 0;
     virtual int priority() const = 0;
     virtual Type type() const = 0;
-    virtual void setCurrentContext(const SelectionContext &selectionState) = 0;
+    virtual void currentContextChanged(const SelectionContext &selectionState) = 0;
 
 };
 
diff --git a/src/plugins/qmldesigner/components/componentcore/defaultdesigneraction.cpp b/src/plugins/qmldesigner/components/componentcore/defaultdesigneraction.cpp
index e9a15009486..5ae93e46f62 100644
--- a/src/plugins/qmldesigner/components/componentcore/defaultdesigneraction.cpp
+++ b/src/plugins/qmldesigner/components/componentcore/defaultdesigneraction.cpp
@@ -42,7 +42,7 @@ DefaultDesignerAction::DefaultDesignerAction(DefaultAction *action)
 {
 }
 
-void DefaultDesignerAction::setCurrentContext(const SelectionContext &selectionContext)
+void DefaultDesignerAction::currentContextChanged(const SelectionContext &selectionContext)
 {
     m_selectionContext = selectionContext;
     updateContext();
diff --git a/src/plugins/qmldesigner/components/componentcore/defaultdesigneraction.h b/src/plugins/qmldesigner/components/componentcore/defaultdesigneraction.h
index 780dd343616..52df2302501 100644
--- a/src/plugins/qmldesigner/components/componentcore/defaultdesigneraction.h
+++ b/src/plugins/qmldesigner/components/componentcore/defaultdesigneraction.h
@@ -59,12 +59,12 @@ public:
     DefaultDesignerAction(DefaultAction *action);
 
     QAction *action() const { return m_action; }
-    void setCurrentContext(const SelectionContext &selectionContext);
+    void currentContextChanged(const SelectionContext &selectionContext);
 
 protected:
     virtual void updateContext();
-    virtual bool isVisible(const SelectionContext &selectionState) const = 0;
-    virtual bool isEnabled(const SelectionContext &selectionState) const = 0;
+    virtual bool isVisible(const SelectionContext &selectionContext) const = 0;
+    virtual bool isEnabled(const SelectionContext &selectionContext) const = 0;
     DefaultAction *defaultAction() const;
     SelectionContext selectionContext() const;
 
diff --git a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp
index 788eb7b7d82..2861e41808b 100644
--- a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp
+++ b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp
@@ -195,7 +195,7 @@ protected:
         }
         SelectionContext selectionContext(this);
         foreach (AbstractDesignerAction* action, m_designerActionList) {
-            action->setCurrentContext(selectionContext);
+            action->currentContextChanged(selectionContext);
         }
         m_setupContextDirty = false;
     }
@@ -270,7 +270,7 @@ public:
         }
         if (m_action->isEnabled()) {
             ModelNode parentNode;
-            if (m_selectionContext.singleSelected() && !m_selectionContext.currentSingleSelectedNode().isRootNode()) {
+            if (m_selectionContext.isSingleNodeIsSelected() && !m_selectionContext.currentSingleSelectedNode().isRootNode()) {
                 ActionTemplate *selectionAction = new ActionTemplate(QString(), &ModelNodeOperations::select);
                 selectionAction->setParent(m_menu.data());
 
@@ -282,7 +282,7 @@ public:
 
                 m_menu->addAction(selectionAction);
             }
-            foreach (const ModelNode &node, m_selectionContext.view()->allModelNodes()) {
+            foreach (const ModelNode &node, m_selectionContext.qmlModelView()->allModelNodes()) {
                 if (node != m_selectionContext.currentSingleSelectedNode()
                         && node != parentNode
                         && contains(node, m_selectionContext.scenePos())
diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu.cpp b/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu.cpp
index e3e9a708f70..909bf2bfab6 100644
--- a/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu.cpp
+++ b/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu.cpp
@@ -89,7 +89,7 @@ void populateMenu(QSet<AbstractDesignerAction* > &abstractDesignerActions,
 
     foreach (AbstractDesignerAction* designerAction, matchingFactoriesList) {
        if (designerAction->type() == AbstractDesignerAction::Menu) {
-           designerAction->setCurrentContext(selectionContext);
+           designerAction->currentContextChanged(selectionContext);
            QMenu *newMenu = designerAction->action()->menu();
            menu->addMenu(newMenu);
 
@@ -98,7 +98,7 @@ void populateMenu(QSet<AbstractDesignerAction* > &abstractDesignerActions,
            populateMenu(abstractDesignerActions, designerAction->menuId(), newMenu, selectionContext);
        } else if (designerAction->type() == AbstractDesignerAction::Action) {
            QAction* action = designerAction->action();
-           designerAction->setCurrentContext(selectionContext);
+           designerAction->currentContextChanged(selectionContext);
            menu->addAction(action);
        }
     }
diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.h b/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.h
index 02399226c17..4e67b310884 100644
--- a/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.h
+++ b/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.h
@@ -56,7 +56,7 @@ inline bool inBaseState(const SelectionContext &selectionState)
 
 inline bool singleSelection(const SelectionContext &selectionState)
 {
-    return selectionState.singleSelected();
+    return selectionState.isSingleNodeIsSelected();
 }
 
 inline bool selectionEnabled(const SelectionContext &selectionState)
@@ -71,7 +71,7 @@ inline bool selectionNotEmpty(const SelectionContext &selectionState)
 
 inline bool singleSelectionNotRoot(const SelectionContext &selectionState)
 {
-    return selectionState.singleSelected()
+    return selectionState.isSingleNodeIsSelected()
         && !selectionState.currentSingleSelectedNode().isRootNode();
 }
 
@@ -144,7 +144,7 @@ public:
     AbstractDesignerAction::Type type() const { return AbstractDesignerAction::Menu; }
     QAction *action() const { return m_action; }
 
-    virtual void setCurrentContext(const SelectionContext &selectionContext)
+    virtual void currentContextChanged(const SelectionContext &selectionContext)
     {
         m_selectionContext = selectionContext;
         updateContext();
@@ -184,7 +184,7 @@ public:
     QString menuId() const { return QString(); }
     int priority() const { return m_priority; }
     Type type() const { return Action; }
-    void setCurrentContext(const SelectionContext &) {}
+    void currentContextChanged(const SelectionContext &) {}
 
 private:
     const QString m_category;
diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp
index 1ca3d332647..c7159094175 100644
--- a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp
+++ b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp
@@ -122,19 +122,19 @@ void goIntoComponent(const ModelNode &modelNode)
 
 void select(const SelectionContext &selectionState)
 {
-    if (selectionState.view())
-        selectionState.view()->setSelectedModelNodes(QList<ModelNode>() << selectionState.targetNode());
+    if (selectionState.qmlModelView())
+        selectionState.qmlModelView()->setSelectedModelNodes(QList<ModelNode>() << selectionState.targetNode());
 }
 
 void deSelect(const SelectionContext &selectionState)
 {
-    if (selectionState.view()) {
-        QList<ModelNode> selectedNodes = selectionState.view()->selectedModelNodes();
+    if (selectionState.qmlModelView()) {
+        QList<ModelNode> selectedNodes = selectionState.qmlModelView()->selectedModelNodes();
         foreach (const ModelNode &node, selectionState.selectedModelNodes()) {
             if (selectedNodes.contains(node))
                 selectedNodes.removeAll(node);
         }
-        selectionState.view()->setSelectedModelNodes(selectedNodes);
+        selectionState.qmlModelView()->setSelectedModelNodes(selectedNodes);
     }
 }
 
@@ -153,7 +153,7 @@ void deleteSelection(const SelectionContext &)
 
 void toFront(const SelectionContext &selectionState)
 {
-    if (!selectionState.view())
+    if (!selectionState.qmlModelView())
         return;
 
     try {
@@ -171,7 +171,7 @@ void toFront(const SelectionContext &selectionState)
 
 void toBack(const SelectionContext &selectionState)
 {
-    if (!selectionState.view())
+    if (!selectionState.qmlModelView())
         return;
     try {
         QmlItemNode node = selectionState.selectedModelNodes().first();
@@ -188,11 +188,11 @@ void toBack(const SelectionContext &selectionState)
 
 void raise(const SelectionContext &selectionState)
 {
-    if (!selectionState.view())
+    if (!selectionState.qmlModelView())
         return;
 
     try {
-        RewriterTransaction transaction(selectionState.view());
+        RewriterTransaction transaction(selectionState.qmlModelView());
         foreach (ModelNode modelNode, selectionState.selectedModelNodes()) {
             QmlItemNode node = modelNode;
             if (node.isValid()) {
@@ -209,11 +209,11 @@ void raise(const SelectionContext &selectionState)
 void lower(const SelectionContext &selectionState)
 {
 
-    if (!selectionState.view())
+    if (!selectionState.qmlModelView())
         return;
 
     try {
-        RewriterTransaction transaction(selectionState.view());
+        RewriterTransaction transaction(selectionState.qmlModelView());
         foreach (ModelNode modelNode, selectionState.selectedModelNodes()) {
             QmlItemNode node = modelNode;
             if (node.isValid()) {
@@ -241,7 +241,7 @@ void redo(const SelectionContext &)
 
 void setVisible(const SelectionContext &selectionState)
 {
-    if (!selectionState.view())
+    if (!selectionState.qmlModelView())
         return;
 
     try {
@@ -254,11 +254,11 @@ void setVisible(const SelectionContext &selectionState)
 
 void resetSize(const SelectionContext &selectionState)
 {
-    if (!selectionState.view())
+    if (!selectionState.qmlModelView())
         return;
 
     try {
-        RewriterTransaction transaction(selectionState.view());
+        RewriterTransaction transaction(selectionState.qmlModelView());
         foreach (ModelNode node, selectionState.selectedModelNodes()) {
             node.removeProperty("width");
             node.removeProperty("height");
@@ -270,11 +270,11 @@ void resetSize(const SelectionContext &selectionState)
 
 void resetPosition(const SelectionContext &selectionState)
 {
-    if (!selectionState.view())
+    if (!selectionState.qmlModelView())
         return;
 
     try {
-        RewriterTransaction transaction(selectionState.view());
+        RewriterTransaction transaction(selectionState.qmlModelView());
         foreach (ModelNode node, selectionState.selectedModelNodes()) {
             node.removeProperty("x");
             node.removeProperty("y");
@@ -295,10 +295,10 @@ void setId(const SelectionContext &)
 
 void resetZ(const SelectionContext &selectionState)
 {
-    if (!selectionState.view())
+    if (!selectionState.qmlModelView())
         return;
 
-    RewriterTransaction transaction(selectionState.view());
+    RewriterTransaction transaction(selectionState.qmlModelView());
     foreach (ModelNode node, selectionState.selectedModelNodes()) {
         node.removeProperty("z");
     }
@@ -326,10 +326,10 @@ static inline void restoreProperty(ModelNode node, const PropertyName &propertyN
 
 void anchorsFill(const SelectionContext &selectionState)
 {
-    if (!selectionState.view())
+    if (!selectionState.qmlModelView())
         return;
 
-    RewriterTransaction transaction(selectionState.view());
+    RewriterTransaction transaction(selectionState.qmlModelView());
 
     ModelNode modelNode = selectionState.currentSingleSelectedNode();
 
@@ -345,10 +345,10 @@ void anchorsFill(const SelectionContext &selectionState)
 
 void anchorsReset(const SelectionContext &selectionState)
 {
-    if (!selectionState.view())
+    if (!selectionState.qmlModelView())
         return;
 
-    RewriterTransaction transaction(selectionState.view());
+    RewriterTransaction transaction(selectionState.qmlModelView());
 
     ModelNode modelNode = selectionState.currentSingleSelectedNode();
 
@@ -428,10 +428,10 @@ static inline QPoint getUpperLeftPosition(const QList<ModelNode> &modelNodeList)
 
 void layoutRow(const SelectionContext &selectionState)
 {
-    if (!selectionState.view())
+    if (!selectionState.qmlModelView())
         return;
 
-    NodeMetaInfo rowMetaInfo = selectionState.view()->model()->metaInfo("QtQuick.Row");
+    NodeMetaInfo rowMetaInfo = selectionState.qmlModelView()->model()->metaInfo("QtQuick.Row");
 
     if (!rowMetaInfo.isValid())
         return;
@@ -440,7 +440,7 @@ void layoutRow(const SelectionContext &selectionState)
 
     ModelNode row;
     {
-        RewriterTransaction transaction(selectionState.view());
+        RewriterTransaction transaction(selectionState.qmlModelView());
 
         QmlItemNode parent = QmlItemNode(modelNodeList.first()).instanceParent().toQmlItemNode();
         if (!parent.isValid())
@@ -448,13 +448,13 @@ void layoutRow(const SelectionContext &selectionState)
 
         qDebug() << parent.modelNode().majorQtQuickVersion();
 
-        row = selectionState.view()->createModelNode("QtQuick.Row", rowMetaInfo.majorVersion(), rowMetaInfo.minorVersion());
+        row = selectionState.qmlModelView()->createModelNode("QtQuick.Row", rowMetaInfo.majorVersion(), rowMetaInfo.minorVersion());
 
         reparentTo(row, parent);
     }
 
     {
-        RewriterTransaction transaction(selectionState.view());
+        RewriterTransaction transaction(selectionState.qmlModelView());
 
         QPoint pos = getUpperLeftPosition(modelNodeList);
         row.variantProperty("x") = pos.x();
@@ -473,10 +473,10 @@ void layoutRow(const SelectionContext &selectionState)
 
 void layoutColumn(const SelectionContext &selectionState)
 {
-    if (!selectionState.view())
+    if (!selectionState.qmlModelView())
         return;
 
-    NodeMetaInfo columnMetaInfo = selectionState.view()->model()->metaInfo("QtQuick.Column");
+    NodeMetaInfo columnMetaInfo = selectionState.qmlModelView()->model()->metaInfo("QtQuick.Column");
 
     if (!columnMetaInfo.isValid())
         return;
@@ -485,19 +485,19 @@ void layoutColumn(const SelectionContext &selectionState)
 
     ModelNode column;
     {
-        RewriterTransaction transaction(selectionState.view());
+        RewriterTransaction transaction(selectionState.qmlModelView());
 
         QmlItemNode parent = QmlItemNode(modelNodeList.first()).instanceParent().toQmlItemNode();
         if (!parent.isValid())
             return;
 
-        column = selectionState.view()->createModelNode("QtQuick.Column", columnMetaInfo.majorVersion(), columnMetaInfo.minorVersion());
+        column = selectionState.qmlModelView()->createModelNode("QtQuick.Column", columnMetaInfo.majorVersion(), columnMetaInfo.minorVersion());
 
         reparentTo(column, parent);
     }
 
     {
-        RewriterTransaction transaction(selectionState.view());
+        RewriterTransaction transaction(selectionState.qmlModelView());
 
         QPoint pos = getUpperLeftPosition(modelNodeList);
         column.variantProperty("x") = pos.x();
@@ -516,10 +516,10 @@ void layoutColumn(const SelectionContext &selectionState)
 
 void layoutGrid(const SelectionContext &selectionState)
 {
-    if (!selectionState.view())
+    if (!selectionState.qmlModelView())
         return;
 
-    NodeMetaInfo gridMetaInfo = selectionState.view()->model()->metaInfo("QtQuick.Grid");
+    NodeMetaInfo gridMetaInfo = selectionState.qmlModelView()->model()->metaInfo("QtQuick.Grid");
 
     if (!gridMetaInfo.isValid())
         return;
@@ -528,20 +528,20 @@ void layoutGrid(const SelectionContext &selectionState)
 
     ModelNode grid;
     {
-        RewriterTransaction transaction(selectionState.view());
+        RewriterTransaction transaction(selectionState.qmlModelView());
 
         QmlItemNode parent = QmlItemNode(modelNodeList.first()).instanceParent().toQmlItemNode();
         if (!parent.isValid())
             return;
 
-        grid = selectionState.view()->createModelNode("QtQuick.Grid", gridMetaInfo.majorVersion(), gridMetaInfo.minorVersion());
+        grid = selectionState.qmlModelView()->createModelNode("QtQuick.Grid", gridMetaInfo.majorVersion(), gridMetaInfo.minorVersion());
         grid.variantProperty("columns") = int(sqrt(double(modelNodeList.count())));
 
         reparentTo(grid, parent);
     }
 
     {
-        RewriterTransaction transaction(selectionState.view());
+        RewriterTransaction transaction(selectionState.qmlModelView());
 
         QPoint pos = getUpperLeftPosition(modelNodeList);
         grid.variantProperty("x") = pos.x();
@@ -560,10 +560,10 @@ void layoutGrid(const SelectionContext &selectionState)
 
 void layoutFlow(const SelectionContext &selectionState)
 {
-    if (!selectionState.view())
+    if (!selectionState.qmlModelView())
         return;
 
-    NodeMetaInfo flowMetaInfo = selectionState.view()->model()->metaInfo("QtQuick.Flow");
+    NodeMetaInfo flowMetaInfo = selectionState.qmlModelView()->model()->metaInfo("QtQuick.Flow");
 
     if (!flowMetaInfo.isValid())
         return;
@@ -572,19 +572,19 @@ void layoutFlow(const SelectionContext &selectionState)
 
     ModelNode flow;
     {
-        RewriterTransaction transaction(selectionState.view());
+        RewriterTransaction transaction(selectionState.qmlModelView());
 
         QmlItemNode parent = QmlItemNode(modelNodeList.first()).instanceParent().toQmlItemNode();
         if (!parent.isValid())
             return;
 
-        flow = selectionState.view()->createModelNode("QtQuick.Flow", flowMetaInfo.majorVersion(), flowMetaInfo.minorVersion());
+        flow = selectionState.qmlModelView()->createModelNode("QtQuick.Flow", flowMetaInfo.majorVersion(), flowMetaInfo.minorVersion());
 
         reparentTo(flow, parent);
     }
 
     {
-        RewriterTransaction transaction(selectionState.view());
+        RewriterTransaction transaction(selectionState.qmlModelView());
 
         QPoint pos = getUpperLeftPosition(modelNodeList);
         flow.variantProperty("x") = pos.x();
diff --git a/src/plugins/qmldesigner/components/componentcore/selectioncontext.cpp b/src/plugins/qmldesigner/components/componentcore/selectioncontext.cpp
index 7d9c8e9d27a..42f045f2342 100644
--- a/src/plugins/qmldesigner/components/componentcore/selectioncontext.cpp
+++ b/src/plugins/qmldesigner/components/componentcore/selectioncontext.cpp
@@ -33,27 +33,92 @@ namespace QmlDesigner {
 
 
 SelectionContext::SelectionContext() :
-    m_view(0),
     m_isInBaseState(false),
     m_toggled(false)
 {
 
 }
 
-SelectionContext::SelectionContext(QmlModelView *view) :
-    m_view(view),
-    m_isInBaseState(view->currentState().isBaseState()),
+SelectionContext::SelectionContext(QmlModelView *qmlModelView) :
+    m_qmlModelView(qmlModelView),
+    m_isInBaseState(qmlModelView->currentState().isBaseState()),
     m_toggled(false)
 {
-    if (m_view && m_view->model())
-        m_selectedModelNodes = view->selectedModelNodes();
+    if (qmlModelView && qmlModelView->model())
+        m_selectedModelNodes = qmlModelView->selectedModelNodes();
+}
+
+void SelectionContext::setTargetNode(const ModelNode &modelNode)
+{
+    m_targetNode = modelNode;
+}
+
+ModelNode SelectionContext::targetNode() const
+{
+    return m_targetNode;
+}
+
+bool SelectionContext::isSingleNodeIsSelected() const
+{
+    return m_selectedModelNodes.count() == 1;
+}
+
+bool SelectionContext::isInBaseState() const
+{
+    return m_isInBaseState;
+}
+
+ModelNode SelectionContext::currentSingleSelectedNode() const
+{
+    if (m_selectedModelNodes.count() != 1)
+        return ModelNode();
+
+    return m_selectedModelNodes.first();
+}
+
+QList<ModelNode> SelectionContext::selectedModelNodes() const
+{
+    return m_selectedModelNodes;
+}
+
+QmlModelView *SelectionContext::qmlModelView() const
+{
+    return m_qmlModelView.data();
+}
+
+void SelectionContext::setShowSelectionTools(bool show)
+{
+    m_showSelectionTools = show;
+}
+
+bool SelectionContext::showSelectionTools() const
+{
+    return m_showSelectionTools;
+}
+
+void SelectionContext::setScenePos(const QPoint &postition)
+{
+    m_scenePosition = postition;
+}
 
-    if (m_selectedModelNodes.count()== 1) {
-        m_singleSelected = true;
-        m_currentSingleSelectedNode = m_selectedModelNodes.first();
-    } else {
-        m_singleSelected = false;
-    }
+QPoint SelectionContext::scenePos() const
+{
+    return m_scenePosition;
+}
+
+void SelectionContext::setToggled(bool toggled)
+{
+    m_toggled = toggled;
+}
+
+bool SelectionContext::toggled() const
+{
+    return m_toggled;
+}
+
+bool SelectionContext::isValid() const
+{
+    return qmlModelView() && qmlModelView()->model() && qmlModelView()->nodeInstanceView();
 }
 
 } //QmlDesigner
diff --git a/src/plugins/qmldesigner/components/componentcore/selectioncontext.h b/src/plugins/qmldesigner/components/componentcore/selectioncontext.h
index 8cea6da0710..4144d1d028d 100644
--- a/src/plugins/qmldesigner/components/componentcore/selectioncontext.h
+++ b/src/plugins/qmldesigner/components/componentcore/selectioncontext.h
@@ -39,59 +39,37 @@ class QMLDESIGNERCORE_EXPORT SelectionContext {
 
 public:
     SelectionContext();
-    SelectionContext(QmlModelView *view);
+    SelectionContext(QmlModelView *qmlModelView);
 
-    void setTargetNode(const ModelNode &modelNode)
-    { m_targetNode = modelNode; }
+    void setTargetNode(const ModelNode &modelNode);
+    ModelNode targetNode() const;
 
-    bool singleSelected() const
-    { return m_singleSelected; }
+    bool isSingleNodeIsSelected() const;
+    bool isInBaseState() const;
 
-    bool isInBaseState() const
-    { return m_isInBaseState; }
+    ModelNode currentSingleSelectedNode() const;
+    QList<ModelNode> selectedModelNodes() const;
 
-    ModelNode targetNode() const
-    { return m_targetNode; }
+    QmlModelView *qmlModelView() const;
 
-    ModelNode currentSingleSelectedNode() const
-    { return m_currentSingleSelectedNode; }
+    void setShowSelectionTools(bool show);
+    bool showSelectionTools() const;
 
-    QList<ModelNode> selectedModelNodes() const
-    { return m_selectedModelNodes; }
+    void setScenePos(const QPoint &postition);
+    QPoint scenePos() const;
 
-    QmlModelView *view() const
-    { return m_view; }
+    void setToggled(bool toggled);
+    bool toggled() const;
 
-    void setShowSelectionTools(bool show)
-    { m_showSelectionTools = show; }
-
-    bool showSelectionTools() const
-    { return m_showSelectionTools; }
-
-    QPoint scenePos() const
-    { return m_scenePos; }
-
-    void setScenePos(const QPoint &pos)
-    { m_scenePos = pos; }
-
-    void setToggled(bool b)
-    { m_toggled = b; }
-
-    bool toggled() const
-    { return m_toggled; }
-
-    bool isValid() const
-    { return view() && view()->model() && view()->nodeInstanceView(); }
+    bool isValid() const;
 
 private:
-    QmlModelView *m_view;
-    bool m_singleSelected;
-    ModelNode m_currentSingleSelectedNode;
+    QWeakPointer<QmlModelView> m_qmlModelView;
     ModelNode m_targetNode;
     bool m_isInBaseState;
     QList<ModelNode> m_selectedModelNodes;
     bool m_showSelectionTools;
-    QPoint m_scenePos;
+    QPoint m_scenePosition;
     bool m_toggled;
 };
 
-- 
GitLab