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 SetTextDirectionDefault,
126 SetTextDirectionLeftToRight,
127 SetTextDirectionRightToLeft,
137 QWebPage(QWidget *parent);
140 void open(const QUrl &url);
141 void open(const QWebNetworkRequest &request);
143 QWebFrame *mainFrame() const;
145 QWebPageHistory *history() const;
147 QWebSettings *settings();
149 QSize sizeHint() const;
151 QString title() const;
153 QPixmap icon() const;
155 bool isModified() const;
156 QUndoStack *undoStack() const;
158 void setNetworkInterface(QWebNetworkInterface *interface);
159 QWebNetworkInterface *networkInterface() const;
161 // #### why is this in the page itself?
162 #ifndef QT_NO_NETWORKPROXY
163 void setNetworkProxy(const QNetworkProxy& proxy);
164 QNetworkProxy networkProxy() const;
167 quint64 totalBytes() const;
168 quint64 bytesReceived() const;
170 QString selectedText() const;
172 QAction *action(WebAction action) const;
173 virtual void triggerAction(WebAction action, bool checked = false);
177 * Stops loading of the page, if loading.
183 * Signal is emitted when load is started on one of the child
184 * frames of the page. The frame on which the load started
187 void loadStarted(QWebFrame *frame);
189 * Signal is emitted when the global progress status changes.
190 * It accumulates changes from all the child frames.
192 void loadProgressChanged(int progress);
194 * Signal is emitted when load has been finished on one of
195 * the child frames of the page. The frame on which the
196 * load finished is passed as an argument.
198 void loadFinished(QWebFrame *frame);
200 * Signal is emitted when the title of this page has changed.
201 * Applies only to the main frame. Sub-frame titles do not trigger this.
203 void titleChanged(const QString& title);
205 * Signal is emitted when the mouse is hovering over a link.
206 * The first parameter is the link url, the second is the link title
207 * if any. Method is emitter with both empty parameters when the mouse
208 * isn't hovering over any link element.
210 void hoveringOverLink(const QString &link, const QString &title);
212 * Signal is emitted when the statusbar text is changed by the page.
214 void statusBarTextChanged(const QString& text);
216 * Signal is emitted when an icon ("favicon") is loaded from the site.
220 void selectionChanged();
223 * Signal is emitted when the mainframe()'s initial layout is completed.
225 void initialLayoutComplete();
227 // ### call addedToHistory instead, something more signal'ish
228 void addToHistory(const QUrl&);
230 void frameCreated(QWebFrame *frame);
232 void geometryChangeRequest(const QRect& geom);
235 virtual QWebPage *createWindow();
236 virtual QWebPage *createModalDialog();
237 virtual QObject *createPlugin(const QString &classid, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues);
239 virtual NavigationRequestResponse navigationRequested(QWebFrame *frame, const QWebNetworkRequest &request, NavigationType type);
240 // ### do we need the frame? maybe include "file dialog" in the name
241 virtual QString chooseFile(QWebFrame *frame, const QString& oldFile);
242 // ### can we unify the next 3 methods? do we need the frame?
243 virtual void javaScriptAlert(QWebFrame *frame, const QString& msg);
244 virtual bool javaScriptConfirm(QWebFrame *frame, const QString& msg);
245 virtual bool javaScriptPrompt(QWebFrame *frame, const QString& msg, const QString& defaultValue, QString* result);
246 virtual void javaScriptConsoleMessage(const QString& message, unsigned int lineNumber, const QString& sourceID);
248 virtual QString userAgentFor(const QUrl& url) const;
250 virtual void resizeEvent(QResizeEvent*);
251 virtual void paintEvent(QPaintEvent*);
252 virtual void mouseMoveEvent(QMouseEvent*);
253 virtual void mousePressEvent(QMouseEvent*);
254 virtual void mouseDoubleClickEvent(QMouseEvent*);
255 virtual void mouseReleaseEvent(QMouseEvent*);
256 virtual void contextMenuEvent(QContextMenuEvent*);
257 virtual void wheelEvent(QWheelEvent*);
258 virtual void keyPressEvent(QKeyEvent*);
259 virtual void keyReleaseEvent(QKeyEvent*);
260 virtual void focusInEvent(QFocusEvent*);
261 virtual void focusOutEvent(QFocusEvent*);
262 virtual bool focusNextPrevChild(bool next);
264 virtual void dragEnterEvent(QDragEnterEvent *);
265 virtual void dragLeaveEvent(QDragLeaveEvent *);
266 virtual void dragMoveEvent(QDragMoveEvent *);
267 virtual void dropEvent(QDropEvent *);
270 Q_PRIVATE_SLOT(d, void _q_onLoadProgressChanged(int))
271 Q_PRIVATE_SLOT(d, void _q_webActionTriggered(bool checked));
272 friend class QWebFrame;
273 friend class QWebPagePrivate;
274 friend class WebCore::ChromeClientQt;
275 friend class WebCore::EditorClientQt;
276 friend class WebCore::FrameLoaderClientQt;
277 friend class WebCore::ResourceHandle;