forked from qt-creator/qt-creator
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: Marco Bubke <marco.bubke@digia.com> Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user