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 QWEBVIEW_H 00022 #define QWEBVIEW_H 00023 00024 #include "qwebkitglobal.h" 00025 #include "qwebpage.h" 00026 #include <QtGui/qwidget.h> 00027 #include <QtGui/qicon.h> 00028 #include <QtGui/qpainter.h> 00029 #include <QtCore/qurl.h> 00030 #include <QtNetwork/qnetworkaccessmanager.h> 00031 00032 QT_BEGIN_NAMESPACE 00033 class QNetworkRequest; 00034 class QPrinter; 00035 QT_END_NAMESPACE 00036 00037 class QWebPage; 00038 class QWebViewPrivate; 00039 class QWebNetworkRequest; 00040 00041 class QWEBKIT_EXPORT QWebView : public QWidget { 00042 Q_OBJECT 00043 Q_PROPERTY(QString title READ title) 00044 Q_PROPERTY(QUrl url READ url WRITE setUrl) 00045 Q_PROPERTY(QIcon icon READ icon) 00046 Q_PROPERTY(QString selectedText READ selectedText) 00047 Q_PROPERTY(bool modified READ isModified) 00048 //Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags) 00049 Q_PROPERTY(qreal textSizeMultiplier READ textSizeMultiplier WRITE setTextSizeMultiplier DESIGNABLE false) 00050 Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor) 00051 00052 Q_PROPERTY(QPainter::RenderHints renderHints READ renderHints WRITE setRenderHints) 00053 Q_FLAGS(QPainter::RenderHints) 00054 public: 00055 explicit QWebView(QWidget* parent = 0); 00056 virtual ~QWebView(); 00057 00058 QWebPage* page() const; 00059 void setPage(QWebPage* page); 00060 00061 void load(const QUrl& url); 00062 void load(const QNetworkRequest& request, 00063 QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, 00064 const QByteArray &body = QByteArray()); 00065 void setHtml(const QString& html, const QUrl& baseUrl = QUrl()); 00066 void setContent(const QByteArray& data, const QString& mimeType = QString(), const QUrl& baseUrl = QUrl()); 00067 00068 QWebHistory* history() const; 00069 QWebSettings* settings() const; 00070 00071 QString title() const; 00072 void setUrl(const QUrl &url); 00073 QUrl url() const; 00074 QIcon icon() const; 00075 00076 QString selectedText() const; 00077 00078 #ifndef QT_NO_ACTION 00079 QAction* pageAction(QWebPage::WebAction action) const; 00080 #endif 00081 void triggerPageAction(QWebPage::WebAction action, bool checked = false); 00082 00083 bool isModified() const; 00084 00085 /* 00086 Qt::TextInteractionFlags textInteractionFlags() const; 00087 void setTextInteractionFlags(Qt::TextInteractionFlags flags); 00088 void setTextInteractionFlag(Qt::TextInteractionFlag flag); 00089 */ 00090 00091 QVariant inputMethodQuery(Qt::InputMethodQuery property) const; 00092 00093 QSize sizeHint() const; 00094 00095 qreal zoomFactor() const; 00096 void setZoomFactor(qreal factor); 00097 00098 void setTextSizeMultiplier(qreal factor); 00099 qreal textSizeMultiplier() const; 00100 00101 QPainter::RenderHints renderHints() const; 00102 void setRenderHints(QPainter::RenderHints hints); 00103 void setRenderHint(QPainter::RenderHint hint, bool enabled = true); 00104 00105 bool findText(const QString& subString, QWebPage::FindFlags options = 0); 00106 00107 virtual bool event(QEvent*); 00108 00109 public Q_SLOTS: 00110 void stop(); 00111 void back(); 00112 void forward(); 00113 void reload(); 00114 00115 void print(QPrinter*) const; 00116 00117 Q_SIGNALS: 00118 void loadStarted(); 00119 void loadProgress(int progress); 00120 void loadFinished(bool); 00121 void titleChanged(const QString& title); 00122 void statusBarMessage(const QString& text); 00123 void linkClicked(const QUrl&); 00124 void selectionChanged(); 00125 void iconChanged(); 00126 void urlChanged(const QUrl&); 00127 00128 protected: 00129 void resizeEvent(QResizeEvent*); 00130 void paintEvent(QPaintEvent*); 00131 00132 virtual QWebView *createWindow(QWebPage::WebWindowType type); 00133 00134 virtual void changeEvent(QEvent*); 00135 virtual void mouseMoveEvent(QMouseEvent*); 00136 virtual void mousePressEvent(QMouseEvent*); 00137 virtual void mouseDoubleClickEvent(QMouseEvent*); 00138 virtual void mouseReleaseEvent(QMouseEvent*); 00139 #ifndef QT_NO_CONTEXTMENU 00140 virtual void contextMenuEvent(QContextMenuEvent*); 00141 #endif 00142 #ifndef QT_NO_WHEELEVENT 00143 virtual void wheelEvent(QWheelEvent*); 00144 #endif 00145 virtual void keyPressEvent(QKeyEvent*); 00146 virtual void keyReleaseEvent(QKeyEvent*); 00147 virtual void dragEnterEvent(QDragEnterEvent*); 00148 virtual void dragLeaveEvent(QDragLeaveEvent*); 00149 virtual void dragMoveEvent(QDragMoveEvent*); 00150 virtual void dropEvent(QDropEvent*); 00151 virtual void focusInEvent(QFocusEvent*); 00152 virtual void focusOutEvent(QFocusEvent*); 00153 virtual void inputMethodEvent(QInputMethodEvent*); 00154 00155 virtual bool focusNextPrevChild(bool next); 00156 00157 private: 00158 friend class QWebPage; 00159 QWebViewPrivate* d; 00160 Q_PRIVATE_SLOT(d, void _q_pageDestroyed()) 00161 }; 00162 00163 #endif // QWEBVIEW_H