Initialize the undo/redo actions from QUndoStack. That automatically takes care of...
authorhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Nov 2007 14:30:11 +0000 (14:30 +0000)
committerhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Nov 2007 14:30:11 +0000 (14:30 +0000)
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27542 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/qt/Api/qwebpage.cpp
WebKit/qt/Api/qwebpage.h
WebKit/qt/ChangeLog

index f4f6be72ba53b70cfcad0e1f50783d12d9dad7bd..6a356b36db71ef11c36743bf7e922a5af253f59b 100644 (file)
@@ -231,6 +231,10 @@ void QWebPagePrivate::updateAction(QWebPage::WebAction action)
         case QWebPage::Paste:
             enabled = editor->canPaste();
             break;
+        case QWebPage::Undo:
+        case QWebPage::Redo:
+            // those two are handled by QUndoStack
+            break;
         default: break;
     }
 
@@ -631,12 +635,16 @@ QAction *QWebPage::webAction(WebAction action) const
             text = contextMenuItemTagPaste();
             break;
 
-        case Undo:
-            text = tr("Undo");
-            break;
-        case Redo:
-            text = tr("Redo");
-            break;
+        case Undo: {
+            QAction *a = undoStack()->createUndoAction(d->q);
+            d->actions[action] = a;
+            return a;
+        }
+        case Redo: {
+            QAction *a = undoStack()->createRedoAction(d->q);
+            d->actions[action] = a;
+            return a;
+        }
         case MoveToNextChar:
         case MoveToPreviousChar:
         case MoveToNextWord:
@@ -693,10 +701,10 @@ bool QWebPage::isModified() const
 }
 
 
-QUndoStack *QWebPage::undoStack()
+QUndoStack *QWebPage::undoStack() const
 {
     if (!d->undoStack)
-        d->undoStack = new QUndoStack(this);
+        d->undoStack = new QUndoStack(const_cast<QWebPage *>(this));
 
     return d->undoStack;
 }
index 28559f851b0b87a5fcb4f3ff7915dc7dd48117a4..29691d263247a83a043f253154621d96211e8f54 100644 (file)
@@ -146,7 +146,7 @@ public:
     QPixmap icon() const;
 
     bool isModified() const;
-    QUndoStack *undoStack();
+    QUndoStack *undoStack() const;
     
     void setNetworkInterface(QWebNetworkInterface *interface);
     QWebNetworkInterface *networkInterface() const;
index 0a1d3b14d7be0cc78dc5c1bd48fbd044e967ee61..9e366c724657ad56c7fffce8c2a79e27a23509bc 100644 (file)
@@ -1,3 +1,15 @@
+2007-11-07  Simon Hausmann  <hausmann@kde.org>
+
+        Reviewed by Lars.
+
+        Initialize the undo/redo actions from QUndoStack. That automatically takes care of enabling/disabling them as well as the activation/trigger.
+
+        * Api/qwebpage.cpp:
+        (QWebPagePrivate::updateAction):
+        (QWebPage::webAction):
+        (QWebPage::undoStack):
+        * Api/qwebpage.h:
+
 2007-11-07  Simon Hausmann  <hausmann@kde.org>
 
         Reviewed by Lars.