webengine/osswebengine/WebKit/qt/Api/qwebpage.h
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2     Copyright (C) 2007 Trolltech ASA
       
     3     Copyright (C) 2007 Staikos Computing Services Inc.
       
     4 
       
     5     This library is free software; you can redistribute it and/or
       
     6     modify it under the terms of the GNU Library General Public
       
     7     License as published by the Free Software Foundation; either
       
     8     version 2 of the License, or (at your option) any later version.
       
     9 
       
    10     This library is distributed in the hope that it will be useful,
       
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    13     Library General Public License for more details.
       
    14 
       
    15     You should have received a copy of the GNU Library General Public License
       
    16     along with this library; see the file COPYING.LIB.  If not, write to
       
    17     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
       
    18     Boston, MA 02110-1301, USA.
       
    19 
       
    20     This class provides all functionality needed for loading images, style sheets and html
       
    21     pages from the web. It has a memory cache for these objects.
       
    22 */
       
    23 
       
    24 #ifndef QWEBPAGE_H
       
    25 #define QWEBPAGE_H
       
    26 
       
    27 #include "qwebpagehistory.h"
       
    28 #include "qwebsettings.h"
       
    29 #include <qwebkitglobal.h>
       
    30 
       
    31 #include <qwidget.h>
       
    32 class QNetworkProxy;
       
    33 class QUndoStack;
       
    34 class QUrl;
       
    35 class QWebFrame;
       
    36 class QWebNetworkRequest;
       
    37 
       
    38 class QWebPagePrivate;
       
    39 class QWebFrameData;
       
    40 class QWebNetworkInterface;
       
    41 
       
    42 namespace WebCore {
       
    43     class ChromeClientQt;
       
    44     class FrameLoaderClientQt;
       
    45     class FrameLoadRequest;
       
    46     class EditorClientQt;
       
    47     class ResourceHandle;
       
    48 }
       
    49 
       
    50 class QWEBKIT_EXPORT QWebPage : public QWidget
       
    51 {
       
    52     Q_OBJECT
       
    53 
       
    54     Q_PROPERTY(bool modified READ isModified)
       
    55 public:
       
    56     enum NavigationRequestResponse {
       
    57         AcceptNavigationRequest,
       
    58         IgnoreNavigationRequest
       
    59     };
       
    60 
       
    61     enum NavigationType {
       
    62         NavigationTypeLinkClicked,
       
    63         NavigationTypeFormSubmitted,
       
    64         NavigationTypeBackForward,
       
    65         NavigationTypeReload,
       
    66         NavigationTypeFormResubmitted,
       
    67         NavigationTypeOther
       
    68     };
       
    69 
       
    70     QWebPage(QWidget *parent);
       
    71     ~QWebPage();
       
    72 
       
    73     void open(const QUrl &url);
       
    74     void open(const QWebNetworkRequest &request);
       
    75 
       
    76     QWebFrame *mainFrame() const;
       
    77 
       
    78     QWebPageHistory history() const;
       
    79 
       
    80     void setSettings(const QWebSettings &settings);
       
    81     QWebSettings settings() const;
       
    82 
       
    83     QSize sizeHint() const;
       
    84 
       
    85     QString title() const;
       
    86 
       
    87     QUrl url() const;
       
    88 
       
    89     bool isModified() const;
       
    90 
       
    91     QUndoStack *undoStack();
       
    92     
       
    93     void setNetworkInterface(QWebNetworkInterface *interface);
       
    94     QWebNetworkInterface *networkInterface() const;
       
    95 
       
    96     QPixmap icon() const;
       
    97 
       
    98 #ifndef QT_NO_NETWORKPROXY
       
    99     void setNetworkProxy(const QNetworkProxy& proxy);
       
   100     QNetworkProxy networkProxy() const;
       
   101 #endif
       
   102 
       
   103     bool canCut() const;
       
   104     bool canCopy() const;
       
   105     bool canPaste() const;
       
   106 
       
   107     quint64 totalBytes() const;
       
   108     quint64 bytesReceived() const;
       
   109 
       
   110 public slots:
       
   111     /**
       
   112      * Stops loading of the page, if loading.
       
   113      */
       
   114     void stop();
       
   115 
       
   116     void goBack();
       
   117     void goForward();
       
   118     void goToHistoryItem(const QWebHistoryItem &item);
       
   119 
       
   120     virtual void setWindowGeometry(const QRect& geom);
       
   121 
       
   122     void cut();
       
   123     void copy();
       
   124     void paste();
       
   125 
       
   126 signals:
       
   127     /**
       
   128      * Signal is emitted when load is started on one of the child
       
   129      * frames of the page. The frame on which the load started
       
   130      * is passed.
       
   131      */
       
   132     void loadStarted(QWebFrame *frame);
       
   133     /**
       
   134      * Signal is emitted when the global progress status changes.
       
   135      * It accumulates changes from all the child frames.
       
   136      */
       
   137     void loadProgressChanged(int progress);
       
   138     /**
       
   139      * Signal is emitted when load has been finished on one of
       
   140      * the child frames of the page. The frame on which the
       
   141      * load finished is passed as an argument.
       
   142      */
       
   143     void loadFinished(QWebFrame *frame);
       
   144     /**
       
   145      * Signal is emitted when the title of this page has changed.
       
   146      * Applies only to the main frame.  Sub-frame titles do not trigger this.
       
   147      */
       
   148     void titleChanged(const QString& title);
       
   149     /**
       
   150      * Signal is emitted when the mouse is hovering over a link.
       
   151      * The first parameter is the link url, the second is the link title
       
   152      * if any. Method is emitter with both empty parameters when the mouse
       
   153      * isn't hovering over any link element.
       
   154      */
       
   155     void hoveringOverLink(const QString &link, const QString &title);
       
   156     /**
       
   157      * Signal is emitted when the statusbar text is changed by the page.
       
   158      */
       
   159     void statusBarTextChanged(const QString& text);
       
   160     /**
       
   161      * Signal is emitted when an icon ("favicon") is loaded from the site.
       
   162      */
       
   163     void iconLoaded();
       
   164 
       
   165     void selectionChanged();
       
   166 
       
   167     /**
       
   168       * Signal is emitted when the mainframe()'s initial layout is completed.
       
   169      */
       
   170     void initialLayoutComplete();
       
   171 
       
   172     void addToHistory(const QUrl&);
       
   173 
       
   174 private slots:
       
   175     void onLoadProgressChanged(int);
       
   176 
       
   177 protected:
       
   178     virtual QWebFrame *createFrame(QWebFrame *parentFrame, QWebFrameData *frameData);
       
   179     virtual QWebPage *createWindow();
       
   180     virtual QWebPage *createModalDialog();
       
   181     virtual QObject *createPlugin(const QString &classid, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues);
       
   182 
       
   183     virtual NavigationRequestResponse navigationRequested(QWebFrame *frame, const QWebNetworkRequest &request, NavigationType type);
       
   184     virtual QString chooseFile(QWebFrame *frame, const QString& oldFile);
       
   185     virtual void javaScriptAlert(QWebFrame *frame, const QString& msg);
       
   186     virtual bool javaScriptConfirm(QWebFrame *frame, const QString& msg);
       
   187     virtual bool javaScriptPrompt(QWebFrame *frame, const QString& msg, const QString& defaultValue, QString* result);
       
   188     virtual void javaScriptConsoleMessage(const QString& message, unsigned int lineNumber, const QString& sourceID);
       
   189     virtual QString userAgentStringForUrl(const QUrl& forUrl) const;
       
   190 
       
   191     virtual void resizeEvent(QResizeEvent*);
       
   192     virtual void paintEvent(QPaintEvent*);
       
   193     virtual void mouseMoveEvent(QMouseEvent*);
       
   194     virtual void mousePressEvent(QMouseEvent*);
       
   195     virtual void mouseDoubleClickEvent(QMouseEvent*);
       
   196     virtual void mouseReleaseEvent(QMouseEvent*);
       
   197     virtual void wheelEvent(QWheelEvent*);
       
   198     virtual void keyPressEvent(QKeyEvent*);
       
   199     virtual void keyReleaseEvent(QKeyEvent*);
       
   200     virtual void focusInEvent(QFocusEvent*);
       
   201     virtual void focusOutEvent(QFocusEvent*);
       
   202     virtual bool focusNextPrevChild(bool next);
       
   203 
       
   204     virtual void dragEnterEvent(QDragEnterEvent *);
       
   205     virtual void dragLeaveEvent(QDragLeaveEvent *);
       
   206     virtual void dragMoveEvent(QDragMoveEvent *);
       
   207     virtual void dropEvent(QDropEvent *);
       
   208 
       
   209 private:
       
   210     friend class QWebFrame;
       
   211     friend class QWebPagePrivate;
       
   212     friend class WebCore::ChromeClientQt;
       
   213     friend class WebCore::EditorClientQt;
       
   214     friend class WebCore::FrameLoaderClientQt;
       
   215     friend class WebCore::ResourceHandle;
       
   216     QWebPagePrivate *d;
       
   217 };
       
   218 
       
   219 
       
   220 
       
   221 #endif