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