From f133d0ac8c40cb1b74ce3969c2b63b19addc2279 Mon Sep 17 00:00:00 2001
From: Marco Bubke <marco.bubke@nokia.com>
Date: Mon, 8 Feb 2010 16:51:23 +0100
Subject: [PATCH] Improve undo/redo for move by cursor key

---
 .../components/formeditor/movemanipulator.cpp          | 10 ++++++++++
 .../components/formeditor/movemanipulator.h            |  3 +++
 .../qmldesigner/components/formeditor/movetool.cpp     |  2 ++
 3 files changed, 15 insertions(+)

diff --git a/src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp b/src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp
index 4ce6ae605c6..9e51b66b338 100644
--- a/src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp
+++ b/src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp
@@ -345,6 +345,16 @@ void MoveManipulator::moveBy(double deltaX, double deltaY)
     }
 }
 
+void MoveManipulator::beginRewriterTransaction()
+{
+    m_rewriterTransaction = m_view->beginRewriterTransaction();
+}
+
+void MoveManipulator::endRewriterTransaction()
+{
+    m_rewriterTransaction.commit();
+}
+
 void MoveManipulator::setOpacityForAllElements(qreal opacity)
 {
     foreach (FormEditorItem* item, m_itemList)
diff --git a/src/plugins/qmldesigner/components/formeditor/movemanipulator.h b/src/plugins/qmldesigner/components/formeditor/movemanipulator.h
index 7c6445bc43b..c82aa1e0b1c 100644
--- a/src/plugins/qmldesigner/components/formeditor/movemanipulator.h
+++ b/src/plugins/qmldesigner/components/formeditor/movemanipulator.h
@@ -69,6 +69,9 @@ public:
 
     void moveBy(double deltaX, double deltaY);
 
+    void beginRewriterTransaction();
+    void endRewriterTransaction();
+
     QPointF beginPoint() const;
 
     void clear();
diff --git a/src/plugins/qmldesigner/components/formeditor/movetool.cpp b/src/plugins/qmldesigner/components/formeditor/movetool.cpp
index 6126c77ae3a..c72805736b2 100644
--- a/src/plugins/qmldesigner/components/formeditor/movetool.cpp
+++ b/src/plugins/qmldesigner/components/formeditor/movetool.cpp
@@ -156,6 +156,7 @@ void MoveTool::keyPressEvent(QKeyEvent *event)
         m_moveManipulator.setItems(movableItems);
 //        m_selectionIndicator.hide();
         m_resizeIndicator.hide();
+        m_moveManipulator.beginRewriterTransaction();
     }
 
     switch(event->key()) {
@@ -180,6 +181,7 @@ void MoveTool::keyReleaseEvent(QKeyEvent *keyEvent)
     }
 
     if (!keyEvent->isAutoRepeat()) {
+        m_moveManipulator.beginRewriterTransaction();
         m_moveManipulator.clear();
 //        m_selectionIndicator.show();
         m_resizeIndicator.show();
-- 
GitLab