forked from qt-creator/qt-creator
QmlDesigner: copy and paste fixes
imports are now properly forwarded and we catch exceptions.
This commit is contained in:
@@ -47,6 +47,7 @@
|
|||||||
#include <componentaction.h>
|
#include <componentaction.h>
|
||||||
#include <qmlobjectnode.h>
|
#include <qmlobjectnode.h>
|
||||||
#include <rewriterview.h>
|
#include <rewriterview.h>
|
||||||
|
#include <rewritingexception.h>
|
||||||
#include <nodelistproperty.h>
|
#include <nodelistproperty.h>
|
||||||
#include <toolbox.h>
|
#include <toolbox.h>
|
||||||
|
|
||||||
@@ -462,6 +463,8 @@ void DesignDocumentController::copySelected()
|
|||||||
QScopedPointer<Model> model(Model::create("Qt/Rectangle"));
|
QScopedPointer<Model> model(Model::create("Qt/Rectangle"));
|
||||||
model->setMetaInfo(m_d->model->metaInfo());
|
model->setMetaInfo(m_d->model->metaInfo());
|
||||||
model->setFileUrl(m_d->model->fileUrl());
|
model->setFileUrl(m_d->model->fileUrl());
|
||||||
|
foreach (const Import &import, m_d->model->imports())
|
||||||
|
model->addImport(import);
|
||||||
|
|
||||||
Q_ASSERT(model);
|
Q_ASSERT(model);
|
||||||
|
|
||||||
@@ -557,6 +560,8 @@ void DesignDocumentController::paste()
|
|||||||
QScopedPointer<Model> model(Model::create("empty"));
|
QScopedPointer<Model> model(Model::create("empty"));
|
||||||
model->setMetaInfo(m_d->model->metaInfo());
|
model->setMetaInfo(m_d->model->metaInfo());
|
||||||
model->setFileUrl(m_d->model->fileUrl());
|
model->setFileUrl(m_d->model->fileUrl());
|
||||||
|
foreach (const Import &import, m_d->model->imports())
|
||||||
|
model->addImport(import);
|
||||||
Q_ASSERT(model);
|
Q_ASSERT(model);
|
||||||
|
|
||||||
if (!m_d->model)
|
if (!m_d->model)
|
||||||
@@ -601,6 +606,7 @@ void DesignDocumentController::paste()
|
|||||||
|
|
||||||
QList<ModelNode> pastedNodeList;
|
QList<ModelNode> pastedNodeList;
|
||||||
|
|
||||||
|
try {
|
||||||
RewriterTransaction transaction(m_d->formEditorView.data());
|
RewriterTransaction transaction(m_d->formEditorView.data());
|
||||||
|
|
||||||
int offset = double(qrand()) / RAND_MAX * 20 - 10;
|
int offset = double(qrand()) / RAND_MAX * 20 - 10;
|
||||||
@@ -614,7 +620,11 @@ void DesignDocumentController::paste()
|
|||||||
}
|
}
|
||||||
|
|
||||||
view.setSelectedModelNodes(pastedNodeList);
|
view.setSelectedModelNodes(pastedNodeList);
|
||||||
|
} catch (RewritingException &e) {
|
||||||
|
qWarning() << e.description(); //silent error
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
RewriterTransaction transaction(m_d->formEditorView.data());
|
RewriterTransaction transaction(m_d->formEditorView.data());
|
||||||
|
|
||||||
model->detachView(&view);
|
model->detachView(&view);
|
||||||
@@ -643,6 +653,9 @@ void DesignDocumentController::paste()
|
|||||||
}
|
}
|
||||||
|
|
||||||
view.setSelectedModelNodes(QList<ModelNode>() << pastedNode);
|
view.setSelectedModelNodes(QList<ModelNode>() << pastedNode);
|
||||||
|
} catch (RewritingException &e) {
|
||||||
|
qWarning() << e.description(); //silent error
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
#include <qgraphicswidget.h>
|
#include <qgraphicswidget.h>
|
||||||
#include <abstractview.h>
|
#include <abstractview.h>
|
||||||
#include <invalididexception.h>
|
#include <invalididexception.h>
|
||||||
|
#include <rewritingexception.h>
|
||||||
|
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|||||||
Reference in New Issue
Block a user