Upstream | d8543bb | 1970-01-12 13:46:40 +0000 | [diff] [blame^] | 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 | #ifndef QWEBVIEW_H |
| 21 | #define QWEBVIEW_H |
| 22 | |
| 23 | #include "qwebkitglobal.h" |
| 24 | #include "qwebpage.h" |
| 25 | #include <QtGui/qwidget.h> |
| 26 | #include <QtCore/qurl.h> |
| 27 | #if QT_VERSION >= 0x040400 |
| 28 | #include <QtNetwork/qnetworkaccessmanager.h> |
| 29 | #endif |
| 30 | |
| 31 | class QWebPage; |
| 32 | class QWebViewPrivate; |
| 33 | class QNetworkRequest; |
| 34 | class QWebNetworkRequest; |
| 35 | |
| 36 | class QWEBKIT_EXPORT QWebView : public QWidget |
| 37 | { |
| 38 | Q_OBJECT |
| 39 | Q_PROPERTY(QString title READ title) |
| 40 | Q_PROPERTY(QUrl url READ url WRITE load) |
| 41 | Q_PROPERTY(QPixmap icon READ icon) |
| 42 | Q_PROPERTY(QString selectedText READ selectedText) |
| 43 | Q_PROPERTY(bool modified READ isModified) |
| 44 | Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags) |
| 45 | public: |
| 46 | explicit QWebView(QWidget *parent = 0); |
| 47 | virtual ~QWebView(); |
| 48 | |
| 49 | QWebPage *page() const; |
| 50 | void setPage(QWebPage *page); |
| 51 | |
| 52 | void load(const QUrl &url); |
| 53 | #if QT_VERSION < 0x040400 |
| 54 | void load(const QWebNetworkRequest &request); |
| 55 | #else |
| 56 | void load(const QNetworkRequest &request, |
| 57 | QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, |
| 58 | const QByteArray &body = QByteArray()); |
| 59 | #endif |
| 60 | void setHtml(const QString &html, const QUrl &baseUrl = QUrl()); |
| 61 | void setHtml(const QByteArray &html, const QUrl &baseUrl = QUrl()); |
| 62 | void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl()); |
| 63 | |
| 64 | QWebHistory *history() const; |
| 65 | QWebSettings *settings() const; |
| 66 | |
| 67 | QString title() const; |
| 68 | QUrl url() const; |
| 69 | QPixmap icon() const; |
| 70 | |
| 71 | QString selectedText() const; |
| 72 | |
| 73 | QAction *action(QWebPage::WebAction action) const; |
| 74 | void triggerAction(QWebPage::WebAction action, bool checked = false); |
| 75 | |
| 76 | bool isModified() const; |
| 77 | |
| 78 | Qt::TextInteractionFlags textInteractionFlags() const; |
| 79 | void setTextInteractionFlags(Qt::TextInteractionFlags flags); |
| 80 | |
| 81 | /* #### QTextBrowser compatibility? |
| 82 | bool openLinks() const; |
| 83 | void setOpenLinks(bool open); |
| 84 | |
| 85 | bool openExternalLinks() const; |
| 86 | void setOpenExternalLinks(bool open); |
| 87 | */ |
| 88 | |
| 89 | QSize sizeHint() const; |
| 90 | public Q_SLOTS: |
| 91 | void stop(); |
| 92 | void backward(); |
| 93 | void forward(); |
| 94 | void reload(); |
| 95 | |
| 96 | Q_SIGNALS: |
| 97 | void loadStarted(); |
| 98 | void loadProgressChanged(int progress); |
| 99 | void loadFinished(); |
| 100 | void titleChanged(const QString& title); |
| 101 | void statusBarTextChanged(const QString& text); |
| 102 | void linkClicked(const QUrl &url); |
| 103 | void selectionChanged(); |
| 104 | void iconLoaded(); |
| 105 | void urlChanged(const QUrl &url); |
| 106 | |
| 107 | protected: |
| 108 | void resizeEvent(QResizeEvent *e); |
| 109 | void paintEvent(QPaintEvent *ev); |
| 110 | |
| 111 | virtual QWebView *createWindow(); |
| 112 | |
| 113 | virtual void mouseMoveEvent(QMouseEvent*); |
| 114 | virtual void mousePressEvent(QMouseEvent*); |
| 115 | virtual void mouseDoubleClickEvent(QMouseEvent*); |
| 116 | virtual void mouseReleaseEvent(QMouseEvent*); |
| 117 | virtual void contextMenuEvent(QContextMenuEvent*); |
| 118 | virtual void wheelEvent(QWheelEvent*); |
| 119 | virtual void keyPressEvent(QKeyEvent*); |
| 120 | virtual void keyReleaseEvent(QKeyEvent*); |
| 121 | virtual void dragEnterEvent(QDragEnterEvent *); |
| 122 | virtual void dragLeaveEvent(QDragLeaveEvent *); |
| 123 | virtual void dragMoveEvent(QDragMoveEvent *); |
| 124 | virtual void dropEvent(QDropEvent *); |
| 125 | virtual void focusInEvent(QFocusEvent*); |
| 126 | virtual void focusOutEvent(QFocusEvent*); |
| 127 | |
| 128 | virtual bool focusNextPrevChild(bool next); |
| 129 | |
| 130 | private: |
| 131 | friend class QWebPage; |
| 132 | QWebViewPrivate *d; |
| 133 | }; |
| 134 | |
| 135 | #endif // QWEBVIEW_H |