- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qwebpage.h

Go to the documentation of this file.

    00001 /*
    00002     Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
    00003     Copyright (C) 2007 Staikos Computing Services Inc.
    00004
    00005     This library is free software; you can redistribute it and/or
    00006     modify it under the terms of the GNU Library General Public
    00007     License as published by the Free Software Foundation; either
    00008     version 2 of the License, or (at your option) any later version.
    00009
    00010     This library is distributed in the hope that it will be useful,
    00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013     Library General Public License for more details.
    00014
    00015     You should have received a copy of the GNU Library General Public License
    00016     along with this library; see the file COPYING.LIB.  If not, write to
    00017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    00018     Boston, MA 02110-1301, USA.
    00019 */
    00020
    00021 #ifndef QWEBPAGE_H
    00022 #define QWEBPAGE_H
    00023
    00024 #include "qwebsettings.h"
    00025 #include "qwebkitglobal.h"
    00026
    00027 #include <QtCore/qobject.h>
    00028 #include <QtCore/qurl.h>
    00029 #include <QtGui/qwidget.h>
    00030
    00031 QT_BEGIN_NAMESPACE
    00032 class QNetworkProxy;
    00033 class QUndoStack;
    00034 class QMenu;
    00035 class QNetworkRequest;
    00036 class QNetworkReply;
    00037 class QNetworkAccessManager;
    00038 QT_END_NAMESPACE
    00039
    00040 class QWebElement;
    00041 class QWebFrame;
    00042 class QWebNetworkRequest;
    00043 class QWebHistory;
    00044
    00045 class QWebPagePrivate;
    00046 class QWebFrameData;
    00047 class QWebNetworkInterface;
    00048 class QWebPluginFactory;
    00049 class QWebHitTestResult;
    00050 class QWebHistoryItem;
    00051
    00052 namespace WebCore {
    00053     class ChromeClientQt;
    00054     class EditorClientQt;
    00055     class FrameLoaderClientQt;
    00056     class InspectorClientQt;
    00057     class InspectorFrontendClientQt;
    00058     class ResourceHandle;
    00059     class HitTestResult;
    00060     class QNetworkReplyHandler;
    00061
    00062     struct FrameLoadRequest;
    00063 }
    00064
    00065 class QWEBKIT_EXPORT QWebPage : public QObject {
    00066     Q_OBJECT
    00067
    00068     Q_PROPERTY(bool modified READ isModified)
    00069     Q_PROPERTY(QString selectedText READ selectedText)
    00070     Q_PROPERTY(QSize viewportSize READ viewportSize WRITE setViewportSize)
    00071     Q_PROPERTY(QSize preferredContentsSize READ preferredContentsSize WRITE setPreferredContentsSize)
    00072     Q_PROPERTY(bool forwardUnsupportedContent READ forwardUnsupportedContent WRITE setForwardUnsupportedContent)
    00073     Q_PROPERTY(LinkDelegationPolicy linkDelegationPolicy READ linkDelegationPolicy WRITE setLinkDelegationPolicy)
    00074     Q_PROPERTY(QPalette palette READ palette WRITE setPalette)
    00075     Q_PROPERTY(bool contentEditable READ isContentEditable WRITE setContentEditable)
    00076     Q_ENUMS(LinkDelegationPolicy NavigationType WebAction)
    00077 public:
    00078     enum NavigationType {
    00079         NavigationTypeLinkClicked,
    00080         NavigationTypeFormSubmitted,
    00081         NavigationTypeBackOrForward,
    00082         NavigationTypeReload,
    00083         NavigationTypeFormResubmitted,
    00084         NavigationTypeOther
    00085     };
    00086
    00087     enum WebAction {
    00088         NoWebAction = - 1,
    00089
    00090         OpenLink,
    00091
    00092         OpenLinkInNewWindow,
    00093         OpenFrameInNewWindow,
    00094
    00095         DownloadLinkToDisk,
    00096         CopyLinkToClipboard,
    00097
    00098         OpenImageInNewWindow,
    00099         DownloadImageToDisk,
    00100         CopyImageToClipboard,
    00101
    00102         Back,
    00103         Forward,
    00104         Stop,
    00105         Reload,
    00106
    00107         Cut,
    00108         Copy,
    00109         Paste,
    00110
    00111         Undo,
    00112         Redo,
    00113         MoveToNextChar,
    00114         MoveToPreviousChar,
    00115         MoveToNextWord,
    00116         MoveToPreviousWord,
    00117         MoveToNextLine,
    00118         MoveToPreviousLine,
    00119         MoveToStartOfLine,
    00120         MoveToEndOfLine,
    00121         MoveToStartOfBlock,
    00122         MoveToEndOfBlock,
    00123         MoveToStartOfDocument,
    00124         MoveToEndOfDocument,
    00125         SelectNextChar,
    00126         SelectPreviousChar,
    00127         SelectNextWord,
    00128         SelectPreviousWord,
    00129         SelectNextLine,
    00130         SelectPreviousLine,
    00131         SelectStartOfLine,
    00132         SelectEndOfLine,
    00133         SelectStartOfBlock,
    00134         SelectEndOfBlock,
    00135         SelectStartOfDocument,
    00136         SelectEndOfDocument,
    00137         DeleteStartOfWord,
    00138         DeleteEndOfWord,
    00139
    00140         SetTextDirectionDefault,
    00141         SetTextDirectionLeftToRight,
    00142         SetTextDirectionRightToLeft,
    00143
    00144         ToggleBold,
    00145         ToggleItalic,
    00146         ToggleUnderline,
    00147
    00148         InspectElement,
    00149
    00150         InsertParagraphSeparator,
    00151         InsertLineSeparator,
    00152
    00153         SelectAll,
    00154         ReloadAndBypassCache,
    00155
    00156         PasteAndMatchStyle,
    00157         RemoveFormat,
    00158
    00159         ToggleStrikethrough,
    00160         ToggleSubscript,
    00161         ToggleSuperscript,
    00162         InsertUnorderedList,
    00163         InsertOrderedList,
    00164         Indent,
    00165         Outdent,
    00166
    00167         AlignCenter,
    00168         AlignJustified,
    00169         AlignLeft,
    00170         AlignRight,
    00171
    00172         StopScheduledPageRefresh,
    00173
    00174         WebActionCount
    00175     };
    00176
    00177     enum FindFlag {
    00178         FindBackward = 1,
    00179         FindCaseSensitively = 2,
    00180         FindWrapsAroundDocument = 4,
    00181         HighlightAllOccurrences = 8
    00182     };
    00183     Q_DECLARE_FLAGS(FindFlags, FindFlag)
    00184
    00185     enum LinkDelegationPolicy {
    00186         DontDelegateLinks,
    00187         DelegateExternalLinks,
    00188         DelegateAllLinks
    00189     };
    00190
    00191     enum WebWindowType {
    00192         WebBrowserWindow,
    00193         WebModalDialog
    00194     };
    00195
    00196     explicit QWebPage(QObject *parent = 0);
    00197     ~QWebPage();
    00198
    00199     QWebFrame *mainFrame() const;
    00200     QWebFrame *currentFrame() const;
    00201     QWebFrame* frameAt(const QPoint& pos) const;
    00202
    00203     QWebHistory *history() const;
    00204     QWebSettings *settings() const;
    00205
    00206     void setView(QWidget *view);
    00207     QWidget *view() const;
    00208
    00209     bool isModified() const;
    00210 #ifndef QT_NO_UNDOSTACK
    00211     QUndoStack *undoStack() const;
    00212 #endif
    00213
    00214     void setNetworkAccessManager(QNetworkAccessManager *manager);
    00215     QNetworkAccessManager *networkAccessManager() const;
    00216
    00217     void setPluginFactory(QWebPluginFactory *factory);
    00218     QWebPluginFactory *pluginFactory() const;
    00219
    00220     quint64 totalBytes() const;
    00221     quint64 bytesReceived() const;
    00222
    00223     QString selectedText() const;
    00224
    00225 #ifndef QT_NO_ACTION
    00226     QAction *action(WebAction action) const;
    00227 #endif
    00228     virtual void triggerAction(WebAction action, bool checked = false);
    00229
    00230     QSize viewportSize() const;
    00231     void setViewportSize(const QSize &size) const;
    00232
    00233     QSize preferredContentsSize() const;
    00234     void setPreferredContentsSize(const QSize &size) const;
    00235
    00236     virtual bool event(QEvent*);
    00237     bool focusNextPrevChild(bool next);
    00238
    00239     QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
    00240
    00241     bool findText(const QString &subString, FindFlags options = 0);
    00242
    00243     void setForwardUnsupportedContent(bool forward);
    00244     bool forwardUnsupportedContent() const;
    00245
    00246     void setLinkDelegationPolicy(LinkDelegationPolicy policy);
    00247     LinkDelegationPolicy linkDelegationPolicy() const;
    00248
    00249     void setPalette(const QPalette &palette);
    00250     QPalette palette() const;
    00251
    00252     void setContentEditable(bool editable);
    00253     bool isContentEditable() const;
    00254
    00255 #ifndef QT_NO_CONTEXTMENU
    00256     bool swallowContextMenuEvent(QContextMenuEvent *event);
    00257 #endif
    00258     void updatePositionDependentActions(const QPoint &pos);
    00259
    00260     QMenu *createStandardContextMenu();
    00261
    00262     enum Extension {
    00263         ChooseMultipleFilesExtension,
    00264         ErrorPageExtension
    00265     };
    00266     class ExtensionOption
    00267     {};
    00268     class ExtensionReturn
    00269     {};
    00270
    00271     class ChooseMultipleFilesExtensionOption : public ExtensionOption {
    00272     public:
    00273         QWebFrame *parentFrame;
    00274         QStringList suggestedFileNames;
    00275     };
    00276
    00277     class ChooseMultipleFilesExtensionReturn : public ExtensionReturn {
    00278     public:
    00279         QStringList fileNames;
    00280     };
    00281
    00282     enum ErrorDomain { QtNetwork, Http, WebKit };
    00283     class ErrorPageExtensionOption : public ExtensionOption {
    00284     public:
    00285         QUrl url;
    00286         QWebFrame* frame;
    00287         ErrorDomain domain;
    00288         int error;
    00289         QString errorString;
    00290     };
    00291
    00292     class ErrorPageExtensionReturn : public ExtensionReturn {
    00293     public:
    00294         ErrorPageExtensionReturn() : contentType(QLatin1String("text/html")), encoding(QLatin1String("utf-8")) {};
    00295         QString contentType;
    00296         QString encoding;
    00297         QUrl baseUrl;
    00298         QByteArray content;
    00299     };
    00300
    00301
    00302     virtual bool extension(Extension extension, const ExtensionOption *option = 0, ExtensionReturn *output = 0);
    00303     virtual bool supportsExtension(Extension extension) const;
    00304
    00305     inline QWebPagePrivate* handle() const { return d; }
    00306
    00307 public Q_SLOTS:
    00308     bool shouldInterruptJavaScript();
    00309
    00310 Q_SIGNALS:
    00311     void loadStarted();
    00312     void loadProgress(int progress);
    00313     void loadFinished(bool ok);
    00314
    00315     void linkHovered(const QString &link, const QString &title, const QString &textContent);
    00316     void statusBarMessage(const QString& text);
    00317     void selectionChanged();
    00318     void frameCreated(QWebFrame *frame);
    00319     void geometryChangeRequested(const QRect& geom);
    00320     void repaintRequested(const QRect& dirtyRect);
    00321     void scrollRequested(int dx, int dy, const QRect& scrollViewRect);
    00322     void windowCloseRequested();
    00323     void printRequested(QWebFrame *frame);
    00324     void linkClicked(const QUrl &url);
    00325
    00326     void toolBarVisibilityChangeRequested(bool visible);
    00327     void statusBarVisibilityChangeRequested(bool visible);
    00328     void menuBarVisibilityChangeRequested(bool visible);
    00329
    00330     void unsupportedContent(QNetworkReply *reply);
    00331     void downloadRequested(const QNetworkRequest &request);
    00332
    00333     void microFocusChanged();
    00334     void contentsChanged();
    00335     void databaseQuotaExceeded(QWebFrame* frame, QString databaseName);
    00336
    00337     void saveFrameStateRequested(QWebFrame* frame, QWebHistoryItem* item);
    00338     void restoreFrameStateRequested(QWebFrame* frame);
    00339
    00340 protected:
    00341     virtual QWebPage *createWindow(WebWindowType type);
    00342     virtual QObject *createPlugin(const QString &classid, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues);
    00343
    00344     virtual bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type);
    00345     virtual QString chooseFile(QWebFrame *originatingFrame, const QString& oldFile);
    00346     virtual void javaScriptAlert(QWebFrame *originatingFrame, const QString& msg);
    00347     virtual bool javaScriptConfirm(QWebFrame *originatingFrame, const QString& msg);
    00348     virtual bool javaScriptPrompt(QWebFrame *originatingFrame, const QString& msg, const QString& defaultValue, QString* result);
    00349     virtual void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID);
    00350
    00351     virtual QString userAgentForUrl(const QUrl& url) const;
    00352
    00353 private:
    00354     Q_PRIVATE_SLOT(d, void _q_onLoadProgressChanged(int))
    00355 #ifndef QT_NO_ACTION
    00356     Q_PRIVATE_SLOT(d, void _q_webActionTriggered(bool checked))
    00357 #endif
    00358     Q_PRIVATE_SLOT(d, void _q_cleanupLeakMessages())
    00359
    00360     QWebPagePrivate *d;
    00361
    00362     friend class QWebFrame;
    00363     friend class QWebPagePrivate;
    00364     friend class QWebView;
    00365     friend class QWebViewPrivate;
    00366     friend class QGraphicsWebView;
    00367     friend class QGraphicsWebViewPrivate;
    00368     friend class QWebInspector;
    00369     friend class WebCore::ChromeClientQt;
    00370     friend class WebCore::EditorClientQt;
    00371     friend class WebCore::FrameLoaderClientQt;
    00372     friend class WebCore::InspectorClientQt;
    00373     friend class WebCore::InspectorFrontendClientQt;
    00374     friend class WebCore::ResourceHandle;
    00375     friend class WebCore::QNetworkReplyHandler;
    00376 };
    00377
    00378 Q_DECLARE_OPERATORS_FOR_FLAGS(QWebPage::FindFlags)
    00379
    00380 #endif