Commit 50ed6fbb authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.DragTool: refactor committing of transaction



I created commitTransaction() which is called whenever we change
to the selection tool.

Task-number: QTCREATORBUG-11134

Change-Id: I1b98c8ff45864decd36f24b219f7d952e44de8fc
Reviewed-by: default avatarMarco Bubke <marco.bubke@digia.com>
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 2f5bae02
......@@ -97,6 +97,7 @@ void DragTool::keyPressEvent(QKeyEvent *event)
if (event->key() == Qt::Key_Escape) {
abort();
event->accept();
commitTransaction();
view()->changeToSelectionTool();
}
}
......@@ -264,10 +265,15 @@ void DragTool::abort()
m_dragNode.destroy();
QmlDesignerItemLibraryDragAndDrop::CustomDragAndDrop::hide();
}
if (m_rewriterTransaction.isValid())
void DragTool::commitTransaction()
{
try {
m_rewriterTransaction.commit();
} catch (RewritingException &e) {
QMessageBox::warning(0, "Error", e.description());
}
}
void DragTool::dropEvent(QGraphicsSceneDragDropEvent * event)
......@@ -277,11 +283,8 @@ void DragTool::dropEvent(QGraphicsSceneDragDropEvent * event)
event->accept();
end(generateUseSnapping(event->modifiers()));
try {
m_rewriterTransaction.commit();
} catch (RewritingException &e) {
QMessageBox::warning(0, "Error", e.description());
}
commitTransaction();
if (m_dragNode.isValid()) {
QList<QmlItemNode> nodeList;
nodeList.append(m_dragNode);
......@@ -337,11 +340,7 @@ void DragTool::dragLeaveEvent(QGraphicsSceneDragDropEvent * event)
m_moveManipulator.end();
clear();
try {
m_rewriterTransaction.commit();
} catch (RewritingException &e) {
QMessageBox::warning(0, "Error", e.description());
}
commitTransaction();
QmlDesignerItemLibraryDragAndDrop::CustomDragAndDrop::show();
QList<QmlItemNode> nodeList;
......
......@@ -109,7 +109,7 @@ protected:
private:
void commitTransaction();
void createQmlItemNode(const ItemLibraryEntry &itemLibraryEntry, QmlItemNode parentNode, QPointF scenePos);
void createQmlItemNodeFromImage(const QString &imageName, QmlItemNode parentNode, QPointF scenePos);
FormEditorItem* calculateContainer(const QPointF &point, FormEditorItem * currentItem = 0);
......
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