QtWebKit/qwebview.h Source File

qwebview.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
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 
21 #ifndef QWEBVIEW_H
22 #define QWEBVIEW_H
23 
24 #include "qwebkitglobal.h"
25 #include "qwebpage.h"
26 #include <QtGui/qwidget.h>
27 #include <QtGui/qicon.h>
28 #include <QtGui/qpainter.h>
29 #include <QtCore/qurl.h>
31 
33 class QNetworkRequest;
34 class QPrinter;
36 
37 class QWebPage;
38 class QWebViewPrivate;
39 class QWebNetworkRequest;
40 
42  Q_OBJECT
43  Q_PROPERTY(QString title READ title)
44  Q_PROPERTY(QUrl url READ url WRITE setUrl)
45  Q_PROPERTY(QIcon icon READ icon)
46  Q_PROPERTY(QString selectedText READ selectedText)
47  Q_PROPERTY(QString selectedHtml READ selectedHtml)
48  Q_PROPERTY(bool hasSelection READ hasSelection)
49  Q_PROPERTY(bool modified READ isModified)
50  //Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
51  Q_PROPERTY(qreal textSizeMultiplier READ textSizeMultiplier WRITE setTextSizeMultiplier DESIGNABLE false)
52  Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor)
53 
54  Q_PROPERTY(QPainter::RenderHints renderHints READ renderHints WRITE setRenderHints)
55  Q_FLAGS(QPainter::RenderHints)
56 public:
57  explicit QWebView(QWidget* parent = 0);
58  virtual ~QWebView();
59 
60  QWebPage* page() const;
61  void setPage(QWebPage* page);
62 
63  void load(const QUrl& url);
64  void load(const QNetworkRequest& request,
65  QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation,
66  const QByteArray &body = QByteArray());
67  void setHtml(const QString& html, const QUrl& baseUrl = QUrl());
68  void setContent(const QByteArray& data, const QString& mimeType = QString(), const QUrl& baseUrl = QUrl());
69 
70  QWebHistory* history() const;
71  QWebSettings* settings() const;
72 
73  QString title() const;
74  void setUrl(const QUrl &url);
75  QUrl url() const;
76  QIcon icon() const;
77 
78  bool hasSelection() const;
79  QString selectedText() const;
80  QString selectedHtml() const;
81 
82 #ifndef QT_NO_ACTION
83  QAction* pageAction(QWebPage::WebAction action) const;
84 #endif
85  void triggerPageAction(QWebPage::WebAction action, bool checked = false);
86 
87  bool isModified() const;
88 
89  /*
90  Qt::TextInteractionFlags textInteractionFlags() const;
91  void setTextInteractionFlags(Qt::TextInteractionFlags flags);
92  void setTextInteractionFlag(Qt::TextInteractionFlag flag);
93  */
94 
96 
97  QSize sizeHint() const;
98 
99  qreal zoomFactor() const;
100  void setZoomFactor(qreal factor);
101 
102  void setTextSizeMultiplier(qreal factor);
103  qreal textSizeMultiplier() const;
104 
105  QPainter::RenderHints renderHints() const;
106  void setRenderHints(QPainter::RenderHints hints);
107  void setRenderHint(QPainter::RenderHint hint, bool enabled = true);
108 
109  bool findText(const QString& subString, QWebPage::FindFlags options = 0);
110 
111  virtual bool event(QEvent*);
112 
113 public Q_SLOTS:
114  void stop();
115  void back();
116  void forward();
117  void reload();
118 
119  void print(QPrinter*) const;
120 
121 Q_SIGNALS:
122  void loadStarted();
123  void loadProgress(int progress);
124  void loadFinished(bool);
125  void titleChanged(const QString& title);
126  void statusBarMessage(const QString& text);
127  void linkClicked(const QUrl&);
128  void selectionChanged();
129  void iconChanged();
130  void urlChanged(const QUrl&);
131 
132 protected:
133  void resizeEvent(QResizeEvent*);
134  void paintEvent(QPaintEvent*);
135 
136  virtual QWebView *createWindow(QWebPage::WebWindowType type);
137 
138  virtual void changeEvent(QEvent*);
139  virtual void mouseMoveEvent(QMouseEvent*);
140  virtual void mousePressEvent(QMouseEvent*);
141  virtual void mouseDoubleClickEvent(QMouseEvent*);
142  virtual void mouseReleaseEvent(QMouseEvent*);
143 #ifndef QT_NO_CONTEXTMENU
144  virtual void contextMenuEvent(QContextMenuEvent*);
145 #endif
146 #ifndef QT_NO_WHEELEVENT
147  virtual void wheelEvent(QWheelEvent*);
148 #endif
149  virtual void keyPressEvent(QKeyEvent*);
150  virtual void keyReleaseEvent(QKeyEvent*);
151  virtual void dragEnterEvent(QDragEnterEvent*);
152  virtual void dragLeaveEvent(QDragLeaveEvent*);
153  virtual void dragMoveEvent(QDragMoveEvent*);
154  virtual void dropEvent(QDropEvent*);
155  virtual void focusInEvent(QFocusEvent*);
156  virtual void focusOutEvent(QFocusEvent*);
157  virtual void inputMethodEvent(QInputMethodEvent*);
158 
159  virtual bool focusNextPrevChild(bool next);
160 
161 private:
162  friend class QWebPage;
163  QWebViewPrivate* d;
164  Q_PRIVATE_SLOT(d, void _q_pageDestroyed())
165 };
166 
167 #endif // QWEBVIEW_H
GLuint GLuint GLsizei GLenum type
Definition: GLee.h:872
friend class QWebViewPrivate
Definition: qwebpage.h:432
bool event(QEvent *)
virtual bool focusNextPrevChild(bool next)
#define QT_END_NAMESPACE
Definition: qglobal.h:128
#define Q_PROPERTY(text)
Definition: qobjectdefs.h:80
virtual void contextMenuEvent(QContextMenuEvent *)
virtual void dragEnterEvent(QDragEnterEvent *)
virtual void dropEvent(QDropEvent *)
virtual void focusInEvent(QFocusEvent *)
virtual void wheelEvent(QWheelEvent *)
virtual void mouseMoveEvent(QMouseEvent *)
virtual void focusOutEvent(QFocusEvent *)
virtual void keyPressEvent(QKeyEvent *)
#define Q_PRIVATE_SLOT(d, signature)
Definition: qobjectdefs.h:73
virtual void resizeEvent(QResizeEvent *)
#define Q_SLOTS
Definition: qobjectdefs.h:71
#define Q_SIGNALS
Definition: qobjectdefs.h:72
Definition: qicon.h:60
#define QT_BEGIN_NAMESPACE
Definition: qglobal.h:127
virtual void mouseReleaseEvent(QMouseEvent *)
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: GLee.h:880
virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const
virtual void mouseDoubleClickEvent(QMouseEvent *)
virtual void keyReleaseEvent(QKeyEvent *)
virtual QSize sizeHint() const
InputMethodQuery
Definition: qnamespace.h:1541
#define Q_OBJECT
Definition: qobjectdefs.h:157
WebWindowType
Definition: qwebpage.h:200
Definition: qurl.h:61
Definition: qsize.h:53
RenderHint
Definition: qpainter.h:93
virtual void paintEvent(QPaintEvent *)
virtual void dragMoveEvent(QDragMoveEvent *)
#define Q_FLAGS(x)
Definition: qobjectdefs.h:85
virtual void mousePressEvent(QMouseEvent *)
virtual void dragLeaveEvent(QDragLeaveEvent *)
virtual void inputMethodEvent(QInputMethodEvent *)
#define QWEBKIT_EXPORT
Definition: qwebkitglobal.h:45
virtual void changeEvent(QEvent *)