Skip to content
Snippets Groups Projects
Commit a574edb3 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.DesignDocument: fixes delete and cut


For deleting Items we need a QmlModelView to delete
dangling property changes.
In the past we "missused" the FormEditorView.
For now VewManager will expose the form editor as
a QmlModelView.

I also cleaned some includes and removed debugs.

Task-number: QTCREATORBUG-8650
Change-Id: I22ca7c5f741324532e81918571be39babd12d2e4
Reviewed-by: default avatarMarco Bubke <marco.bubke@digia.com>
parent 811e05f8
No related branches found
No related tags found
No related merge requests found
......@@ -46,6 +46,7 @@
#include <rewritingexception.h>
#include <modelnodeoperations.h>
#include <qmldesignerplugin.h>
#include <viewmanager.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/project.h>
......@@ -220,6 +221,11 @@ bool DesignDocument::loadInFileComponent(const ModelNode &componentNode)
return true;
}
QmlModelView *DesignDocument::qmlModelView()
{
return viewManager().qmlModelView();
}
/*!
Returns any errors that happened when parsing the latest qml file.
*/
......@@ -362,7 +368,7 @@ void DesignDocument::goIntoComponent()
QList<ModelNode> selectedNodes;
if (rewriterView())
selectedNodes = rewriterView()->selectedModelNodes();
selectedNodes = qmlModelView()->selectedModelNodes();
if (selectedNodes.count() == 1) {
viewManager().setComponentNode(selectedNodes.first());
......@@ -433,7 +439,7 @@ void DesignDocument::deleteSelected()
try {
RewriterTransaction transaction(rewriterView());
QList<ModelNode> toDelete = rewriterView()->selectedModelNodes();
QList<ModelNode> toDelete = qmlModelView()->selectedModelNodes();
foreach (ModelNode node, toDelete) {
if (node.isValid() && !node.isRootNode() && QmlObjectNode(node).isValid())
QmlObjectNode(node).destroy();
......@@ -562,8 +568,6 @@ void DesignDocument::paste()
if (rootNode.id() == "designer__Selection") {
QList<ModelNode> selectedNodes = rootNode.allDirectSubModelNodes();
qDebug() << rootNode;
qDebug() << selectedNodes;
pasteModel->detachView(&view);
m_currentModel->attachView(&view);
......
......@@ -30,21 +30,12 @@
#ifndef DesignDocument_h
#define DesignDocument_h
#include "rewriterview.h"
#include <model.h>
#include <rewriterview.h>
#include <itemlibraryview.h>
#include <navigatorview.h>
#include <stateseditorview.h>
#include <formeditorview.h>
#include <propertyeditor.h>
#include <componentview.h>
#include <basetexteditmodifier.h>
#include <componenttextmodifier.h>
#include <subcomponentmanager.h>
#include <model/viewlogger.h>
#include <viewmanager.h>
#include <QObject>
#include <QString>
......@@ -66,6 +57,8 @@ class ModelNode;
class TextModifier;
class QmlObjectNode;
class CrumbleBarInfo;
class ViewManager;
class QmlModelView;
class DesignDocument: public QObject
{
......@@ -147,6 +140,8 @@ private: // functions
bool loadInFileComponent(const ModelNode &componentNode);
QmlModelView *qmlModelView();
private: // variables
QWeakPointer<QStackedWidget> m_stackedWidget;
QWeakPointer<Model> m_documentModel;
......
......@@ -80,6 +80,9 @@ public:
void pushInFileComponentOnCrambleBar(const QString &componentId);
void nextFileIsCalledInternally();
//used by DesignDocument ### find a better solution
QmlModelView *qmlModelView();
private: // functions
Q_DISABLE_COPY(ViewManager)
......
......@@ -188,6 +188,11 @@ void ViewManager::nextFileIsCalledInternally()
m_formEditorView.formEditorWidget()->formEditorCrumbleBar()->nextFileIsCalledInternally();
}
QmlModelView *ViewManager::qmlModelView()
{
return &m_formEditorView;
}
Model *ViewManager::currentModel() const
{
return currentDesignDocument()->currentModel();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment