Introduced a central virtual void webActionTriggered(WebAction action) method that...
authorhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Nov 2007 14:29:25 +0000 (14:29 +0000)
committerhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Nov 2007 14:29:25 +0000 (14:29 +0000)
convenience methods such as cut()/copy()/paste().

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27534 268f45cc-cd09-0410-ab3c-d52691b4dbfc

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

index 951c45e3bf54c16c20a3bb7682a87f18a640dc45..ccbbb4f823f6f2a46c34792d71ac720980783bbe 100644 (file)
@@ -244,8 +244,7 @@ QSize QWebPage::sizeHint() const
 
 void QWebPage::stop()
 {
-    FrameLoader *f = mainFrame()->d->frame->loader();
-    f->stopForUserCancel();
+    webActionTriggered(Stop);
 }
 
 QWebPageHistory *QWebPage::history() const
@@ -255,12 +254,12 @@ QWebPageHistory *QWebPage::history() const
 
 void QWebPage::goBack()
 {
-    d->page->goBack();
+    webActionTriggered(GoBack);
 }
 
 void QWebPage::goForward()
 {
-    d->page->goForward();
+    webActionTriggered(GoForward);
 }
 
 void QWebPage::goToHistoryItem(const QWebHistoryItem &item)
@@ -316,6 +315,43 @@ QObject *QWebPage::createPlugin(const QString &classid, const QUrl &url, const Q
     return 0;
 }
 
+void QWebPage::webActionTriggered(WebAction action, bool checked)
+{
+    switch (action) {
+        // ### these need a context...
+        case OpenLinkInNewWindow:
+        case OpenFrameInNewWindow:
+        case DownloadLinkToDisk:
+        case CopyLinkToClipboard:
+        case OpenImageInNewWindow:
+        case DownloadImageToDisk:
+        case CopyImageToClipboard:
+            break;
+        case GoBack:
+            d->page->goBack();
+            break;
+        case GoForward:
+            d->page->goForward();
+            break;
+        case Stop:
+            mainFrame()->d->frame->loader()->stopForUserCancel();
+            break;
+        case Reload:
+            mainFrame()->d->frame->loader()->reload();
+            break;
+        case Cut:
+            d->page->focusController()->focusedOrMainFrame()->editor()->cut();
+            break;
+        case Copy:
+            d->page->focusController()->focusedOrMainFrame()->editor()->copy();
+            break;
+        case Paste:
+            d->page->focusController()->focusedOrMainFrame()->editor()->paste();
+            break;
+        default: break;
+    }
+}
+
 QWebPage::NavigationRequestResponse QWebPage::navigationRequested(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type)
 {
     Q_UNUSED(request)
@@ -344,17 +380,17 @@ bool QWebPage::canPaste() const
 
 void QWebPage::cut()
 {
-    d->page->focusController()->focusedOrMainFrame()->editor()->cut();
+    webActionTriggered(Cut);
 }
 
 void QWebPage::copy()
 {
-    d->page->focusController()->focusedOrMainFrame()->editor()->copy();
+    webActionTriggered(Copy);
 }
 
 void QWebPage::paste()
 {
-    d->page->focusController()->focusedOrMainFrame()->editor()->paste();
+    webActionTriggered(Paste);
 }
 
 /*!
index 7f9b60d1ed9adcaa2d41c61fcacb857982a42679..4105f223151d42a617212a91834c68714afdb1e6 100644 (file)
@@ -67,6 +67,32 @@ public:
         NavigationTypeOther
     };
 
+    enum WebAction {
+        NoWebAction = - 1,
+
+        OpenLinkInNewWindow,
+        OpenFrameInNewWindow,
+
+        DownloadLinkToDisk,
+        CopyLinkToClipboard,
+
+        OpenImageInNewWindow,
+        DownloadImageToDisk,
+        CopyImageToClipboard,
+
+        GoBack,
+        GoForward,
+        Stop,
+        Reload,
+
+        Cut,
+        Copy,
+        Paste,
+
+        NumWebActions = Paste
+    };
+
+
     QWebPage(QWidget *parent);
     ~QWebPage();
 
@@ -183,6 +209,8 @@ protected:
     virtual QWebPage *createModalDialog();
     virtual QObject *createPlugin(const QString &classid, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues);
 
+    virtual void webActionTriggered(WebAction action, bool checked = false);
+
     virtual NavigationRequestResponse navigationRequested(QWebFrame *frame, const QWebNetworkRequest &request, NavigationType type);
     // ### what does this do?
     virtual QString chooseFile(QWebFrame *frame, const QString& oldFile);
index 09cf3f503c9296e88f48882d7667837c9c46da15..3536c4fa99ff6f42723c7585e69a60c6ab927f60 100644 (file)
@@ -1,3 +1,17 @@
+2007-11-07  Simon Hausmann  <hausmann@kde.org>
+
+        Reviewed by Lars.
+
+        Introduced a central virtual void webActionTriggered(WebAction action) method that is called from various
+        convenience methods such as cut()/copy()/paste().
+
+        * Api/qwebpage.cpp:
+        (QWebPage::goBack):
+        (QWebPage::webActionTriggered):
+        (QWebPage::cut):
+        (QWebPage::copy):
+        * Api/qwebpage.h:
+
 2007-11-07  Simon Hausmann  <hausmann@kde.org>
 
         Reviewed by Lars.