2 Copyright (C) 2007 Trolltech ASA
3 Copyright (C) 2007 Staikos Computing Services Inc.
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.
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.
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.
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.
27 #include "qwebpagehistory.h"
28 #include "qwebsettings.h"
29 #include <qwebkitglobal.h>
36 class QWebNetworkRequest;
38 class QWebPagePrivate;
40 class QWebNetworkInterface;
44 class FrameLoaderClientQt;
45 class FrameLoadRequest;
51 class QWEBKIT_EXPORT QWebPage : public QWidget
55 Q_PROPERTY(bool modified READ isModified)
56 Q_PROPERTY(QString selectedText READ selectedText)
58 enum NavigationRequestResponse {
59 AcceptNavigationRequest,
60 IgnoreNavigationRequest
64 NavigationTypeLinkClicked,
65 NavigationTypeFormSubmitted,
66 NavigationTypeBackForward,
68 NavigationTypeFormResubmitted,
108 MoveToStartOfDocument,
120 SelectStartOfDocument,
125 NumWebActions = DeleteEndOfWord
129 QWebPage(QWidget *parent);
132 void open(const QUrl &url);
133 void open(const QWebNetworkRequest &request);
135 QWebFrame *mainFrame() const;
137 QWebPageHistory *history() const;
139 QWebSettings *settings();
141 QSize sizeHint() const;
143 // ### should be windowTitle
144 QString title() const;
146 // ### should be QWidget::icon
147 QPixmap icon() const;
149 bool isModified() const;
150 QUndoStack *undoStack() const;
152 void setNetworkInterface(QWebNetworkInterface *interface);
153 QWebNetworkInterface *networkInterface() const;
155 #ifndef QT_NO_NETWORKPROXY
156 void setNetworkProxy(const QNetworkProxy& proxy);
157 QNetworkProxy networkProxy() const;
160 // #### remove after adding editor actions
162 bool canCopy() const;
163 bool canPaste() const;
165 quint64 totalBytes() const;
166 quint64 bytesReceived() const;
168 QString selectedText() const;
170 QAction *webAction(WebAction action) const;
174 * Stops loading of the page, if loading.
178 // #### should these be actions?
181 void goToHistoryItem(const QWebHistoryItem &item);
183 // ### should be a signal: void geometryChangeRequest(const QRect &geom);
184 virtual void setWindowGeometry(const QRect& geom);
189 // ### should we have execCommand() or something similar?
193 * Signal is emitted when load is started on one of the child
194 * frames of the page. The frame on which the load started
197 void loadStarted(QWebFrame *frame);
199 * Signal is emitted when the global progress status changes.
200 * It accumulates changes from all the child frames.
202 void loadProgressChanged(int progress);
204 * Signal is emitted when load has been finished on one of
205 * the child frames of the page. The frame on which the
206 * load finished is passed as an argument.
208 void loadFinished(QWebFrame *frame);
210 * Signal is emitted when the title of this page has changed.
211 * Applies only to the main frame. Sub-frame titles do not trigger this.
213 void titleChanged(const QString& title);
215 * Signal is emitted when the mouse is hovering over a link.
216 * The first parameter is the link url, the second is the link title
217 * if any. Method is emitter with both empty parameters when the mouse
218 * isn't hovering over any link element.
220 void hoveringOverLink(const QString &link, const QString &title);
222 * Signal is emitted when the statusbar text is changed by the page.
224 void statusBarTextChanged(const QString& text);
226 * Signal is emitted when an icon ("favicon") is loaded from the site.
230 void selectionChanged();
233 * Signal is emitted when the mainframe()'s initial layout is completed.
235 void initialLayoutComplete();
237 void addToHistory(const QUrl&);
239 void frameCreated(QWebFrame *frame);
242 virtual QWebPage *createWindow();
243 virtual QWebPage *createModalDialog();
244 virtual QObject *createPlugin(const QString &classid, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues);
246 virtual void webActionTriggered(WebAction action, bool checked = false);
248 virtual NavigationRequestResponse navigationRequested(QWebFrame *frame, const QWebNetworkRequest &request, NavigationType type);
249 // ### what does this do?
250 virtual QString chooseFile(QWebFrame *frame, const QString& oldFile);
251 // ### can we unify the next 3 methods?
252 virtual void javaScriptAlert(QWebFrame *frame, const QString& msg);
253 virtual bool javaScriptConfirm(QWebFrame *frame, const QString& msg);
254 virtual bool javaScriptPrompt(QWebFrame *frame, const QString& msg, const QString& defaultValue, QString* result);
255 virtual void javaScriptConsoleMessage(const QString& message, unsigned int lineNumber, const QString& sourceID);
257 // ### should the be here?
258 virtual QString userAgentStringForUrl(const QUrl& forUrl) const;
260 virtual void resizeEvent(QResizeEvent*);
261 virtual void paintEvent(QPaintEvent*);
262 virtual void mouseMoveEvent(QMouseEvent*);
263 virtual void mousePressEvent(QMouseEvent*);
264 virtual void mouseDoubleClickEvent(QMouseEvent*);
265 virtual void mouseReleaseEvent(QMouseEvent*);
266 virtual void contextMenuEvent(QContextMenuEvent*);
267 virtual void wheelEvent(QWheelEvent*);
268 virtual void keyPressEvent(QKeyEvent*);
269 virtual void keyReleaseEvent(QKeyEvent*);
270 virtual void focusInEvent(QFocusEvent*);
271 virtual void focusOutEvent(QFocusEvent*);
272 virtual bool focusNextPrevChild(bool next);
274 virtual void dragEnterEvent(QDragEnterEvent *);
275 virtual void dragLeaveEvent(QDragLeaveEvent *);
276 virtual void dragMoveEvent(QDragMoveEvent *);
277 virtual void dropEvent(QDropEvent *);
280 Q_PRIVATE_SLOT(d, void _q_onLoadProgressChanged(int))
281 Q_PRIVATE_SLOT(d, void _q_webActionTriggered(bool checked));
282 friend class QWebFrame;
283 friend class QWebPagePrivate;
284 friend class WebCore::ChromeClientQt;
285 friend class WebCore::EditorClientQt;
286 friend class WebCore::FrameLoaderClientQt;
287 friend class WebCore::ResourceHandle;