author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 03 May 2010 13:17:34 +0300 | |
changeset 19 | fcece45ef507 |
parent 3 | 41300fa6a67c |
child 30 | 5dc02b23752f |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) |
|
3 |
Copyright (C) 2009 Girish Ramakrishnan <girish@forwardbias.in> |
|
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 |
#include "config.h" |
|
22 |
#include "qgraphicswebview.h" |
|
23 |
||
24 |
#include "qwebframe.h" |
|
25 |
#include "qwebpage.h" |
|
26 |
#include "qwebpage_p.h" |
|
27 |
#include "QWebPageClient.h" |
|
28 |
#include <QtGui/QGraphicsScene> |
|
29 |
#include <QtGui/QGraphicsView> |
|
30 |
#include <QtGui/qapplication.h> |
|
31 |
#include <QtGui/qgraphicssceneevent.h> |
|
32 |
#include <QtGui/qstyleoption.h> |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
33 |
#include <QtGui/qinputcontext.h> |
0 | 34 |
#if defined(Q_WS_X11) |
35 |
#include <QX11Info> |
|
36 |
#endif |
|
37 |
||
38 |
class QGraphicsWebViewPrivate : public QWebPageClient { |
|
39 |
public: |
|
40 |
QGraphicsWebViewPrivate(QGraphicsWebView* parent) |
|
41 |
: q(parent) |
|
42 |
, page(0) |
|
43 |
{} |
|
44 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
45 |
virtual ~QGraphicsWebViewPrivate(); |
0 | 46 |
virtual void scroll(int dx, int dy, const QRect&); |
47 |
virtual void update(const QRect& dirtyRect); |
|
48 |
virtual void setInputMethodEnabled(bool enable); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
49 |
virtual bool inputMethodEnabled() const; |
0 | 50 |
#if QT_VERSION >= 0x040600 |
51 |
virtual void setInputMethodHint(Qt::InputMethodHint hint, bool enable); |
|
52 |
#endif |
|
53 |
||
54 |
#ifndef QT_NO_CURSOR |
|
55 |
virtual QCursor cursor() const; |
|
56 |
virtual void updateCursor(const QCursor& cursor); |
|
57 |
#endif |
|
58 |
||
59 |
virtual QPalette palette() const; |
|
60 |
virtual int screenNumber() const; |
|
61 |
virtual QWidget* ownerWidget() const; |
|
62 |
||
63 |
virtual QObject* pluginParent() const; |
|
64 |
||
65 |
void _q_doLoadFinished(bool success); |
|
66 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
67 |
void _q_updateMicroFocus(); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
68 |
void _q_pageDestroyed(); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
69 |
|
0 | 70 |
QGraphicsWebView* q; |
71 |
QWebPage* page; |
|
72 |
}; |
|
73 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
74 |
QGraphicsWebViewPrivate::~QGraphicsWebViewPrivate() |
0 | 75 |
{ |
76 |
} |
|
77 |
||
78 |
void QGraphicsWebViewPrivate::_q_doLoadFinished(bool success) |
|
79 |
{ |
|
80 |
// If the page had no title, still make sure it gets the signal |
|
81 |
if (q->title().isEmpty()) |
|
82 |
emit q->urlChanged(q->url()); |
|
83 |
||
84 |
emit q->loadFinished(success); |
|
85 |
} |
|
86 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
87 |
void QGraphicsWebViewPrivate::_q_updateMicroFocus() |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
88 |
{ |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
89 |
#if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
90 |
// Ideally, this should be handled by a common call to an updateMicroFocus function |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
91 |
// in QGraphicsItem. See http://bugreports.qt.nokia.com/browse/QTBUG-7578. |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
92 |
QList<QGraphicsView*> views = q->scene()->views(); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
93 |
for (int c = 0; c < views.size(); ++c) { |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
94 |
QInputContext* ic = views.at(c)->inputContext(); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
95 |
if (ic) |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
96 |
ic->update(); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
97 |
} |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
98 |
#endif |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
99 |
} |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
100 |
|
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
101 |
void QGraphicsWebViewPrivate::_q_pageDestroyed() |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
102 |
{ |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
103 |
page = 0; |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
104 |
q->setPage(0); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
105 |
} |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
106 |
|
0 | 107 |
void QGraphicsWebViewPrivate::scroll(int dx, int dy, const QRect& rectToScroll) |
108 |
{ |
|
109 |
q->scroll(qreal(dx), qreal(dy), QRectF(rectToScroll)); |
|
110 |
} |
|
111 |
||
112 |
void QGraphicsWebViewPrivate::update(const QRect & dirtyRect) |
|
113 |
{ |
|
114 |
q->update(QRectF(dirtyRect)); |
|
115 |
} |
|
116 |
||
117 |
||
118 |
void QGraphicsWebViewPrivate::setInputMethodEnabled(bool enable) |
|
119 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
120 |
#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
121 |
q->setFlag(QGraphicsItem::ItemAcceptsInputMethod, enable); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
122 |
#endif |
0 | 123 |
} |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
124 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
125 |
bool QGraphicsWebViewPrivate::inputMethodEnabled() const |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
126 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
127 |
#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
128 |
return q->flags() & QGraphicsItem::ItemAcceptsInputMethod; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
129 |
#else |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
130 |
return false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
131 |
#endif |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
132 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
133 |
|
0 | 134 |
#if QT_VERSION >= 0x040600 |
135 |
void QGraphicsWebViewPrivate::setInputMethodHint(Qt::InputMethodHint hint, bool enable) |
|
136 |
{ |
|
137 |
if (enable) |
|
138 |
q->setInputMethodHints(q->inputMethodHints() | hint); |
|
139 |
else |
|
140 |
q->setInputMethodHints(q->inputMethodHints() & ~hint); |
|
141 |
} |
|
142 |
#endif |
|
143 |
#ifndef QT_NO_CURSOR |
|
144 |
QCursor QGraphicsWebViewPrivate::cursor() const |
|
145 |
{ |
|
146 |
return q->cursor(); |
|
147 |
} |
|
148 |
||
149 |
void QGraphicsWebViewPrivate::updateCursor(const QCursor& cursor) |
|
150 |
{ |
|
151 |
q->setCursor(cursor); |
|
152 |
} |
|
153 |
#endif |
|
154 |
||
155 |
QPalette QGraphicsWebViewPrivate::palette() const |
|
156 |
{ |
|
157 |
return q->palette(); |
|
158 |
} |
|
159 |
||
160 |
int QGraphicsWebViewPrivate::screenNumber() const |
|
161 |
{ |
|
162 |
#if defined(Q_WS_X11) |
|
163 |
const QList<QGraphicsView*> views = q->scene()->views(); |
|
164 |
||
165 |
if (!views.isEmpty()) |
|
166 |
return views.at(0)->x11Info().screen(); |
|
167 |
#endif |
|
168 |
||
169 |
return 0; |
|
170 |
} |
|
171 |
||
172 |
QWidget* QGraphicsWebViewPrivate::ownerWidget() const |
|
173 |
{ |
|
174 |
const QList<QGraphicsView*> views = q->scene()->views(); |
|
175 |
return views.value(0); |
|
176 |
} |
|
177 |
||
178 |
QObject* QGraphicsWebViewPrivate::pluginParent() const |
|
179 |
{ |
|
180 |
return q; |
|
181 |
} |
|
182 |
||
183 |
/*! |
|
184 |
\class QGraphicsWebView |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
185 |
\brief The QGraphicsWebView class allows Web content to be added to a GraphicsView. |
0 | 186 |
\since 4.6 |
187 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
188 |
An instance of this class renders Web content from a URL or supplied as data, using |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
189 |
features of the QtWebKit module. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
190 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
191 |
If the width and height of the item are not set, they will default to 800 and 600, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
192 |
respectively. If the Web page contents is larger than that, scrollbars will be shown |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
193 |
if not disabled explicitly. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
194 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
195 |
\section1 Browser Features |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
196 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
197 |
Many of the functions, signals and properties provided by QWebView are also available |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
198 |
for this item, making it simple to adapt existing code to use QGraphicsWebView instead |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
199 |
of QWebView. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
200 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
201 |
The item uses a QWebPage object to perform the rendering of Web content, and this can |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
202 |
be obtained with the page() function, enabling the document itself to be accessed and |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
203 |
modified. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
204 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
205 |
As with QWebView, the item records the browsing history using a QWebHistory object, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
206 |
accessible using the history() function. The QWebSettings object that defines the |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
207 |
configuration of the browser can be obtained with the settings() function, enabling |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
208 |
features like plugin support to be customized for each item. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
209 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
210 |
\sa QWebView, QGraphicsTextItem |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
211 |
*/ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
212 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
213 |
/*! |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
214 |
\fn void QGraphicsWebView::titleChanged(const QString &title) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
215 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
216 |
This signal is emitted whenever the \a title of the main frame changes. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
217 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
218 |
\sa title() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
219 |
*/ |
0 | 220 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
221 |
/*! |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
222 |
\fn void QGraphicsWebView::urlChanged(const QUrl &url) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
223 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
224 |
This signal is emitted when the \a url of the view changes. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
225 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
226 |
\sa url(), load() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
227 |
*/ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
228 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
229 |
/*! |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
230 |
\fn void QGraphicsWebView::iconChanged() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
231 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
232 |
This signal is emitted whenever the icon of the page is loaded or changes. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
233 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
234 |
In order for icons to be loaded, you will need to set an icon database path |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
235 |
using QWebSettings::setIconDatabasePath(). |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
236 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
237 |
\sa icon(), QWebSettings::setIconDatabasePath() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
238 |
*/ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
239 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
240 |
/*! |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
241 |
\fn void QGraphicsWebView::loadStarted() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
242 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
243 |
This signal is emitted when a new load of the page is started. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
244 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
245 |
\sa loadProgress(), loadFinished() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
246 |
*/ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
247 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
248 |
/*! |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
249 |
\fn void QGraphicsWebView::loadFinished(bool ok) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
250 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
251 |
This signal is emitted when a load of the page is finished. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
252 |
\a ok will indicate whether the load was successful or any error occurred. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
253 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
254 |
\sa loadStarted() |
0 | 255 |
*/ |
256 |
||
257 |
/*! |
|
258 |
Constructs an empty QGraphicsWebView with parent \a parent. |
|
259 |
||
260 |
\sa load() |
|
261 |
*/ |
|
262 |
QGraphicsWebView::QGraphicsWebView(QGraphicsItem* parent) |
|
263 |
: QGraphicsWidget(parent) |
|
264 |
, d(new QGraphicsWebViewPrivate(this)) |
|
265 |
{ |
|
266 |
#if QT_VERSION >= 0x040600 |
|
267 |
setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true); |
|
268 |
#endif |
|
269 |
setAcceptHoverEvents(true); |
|
270 |
setFocusPolicy(Qt::StrongFocus); |
|
271 |
} |
|
272 |
||
273 |
/*! |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
274 |
Destroys the item. |
0 | 275 |
*/ |
276 |
QGraphicsWebView::~QGraphicsWebView() |
|
277 |
{ |
|
278 |
if (d->page) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
279 |
#if QT_VERSION >= 0x040600 |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
280 |
d->page->d->view.clear(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
281 |
#else |
0 | 282 |
d->page->d->view = 0; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
283 |
#endif |
0 | 284 |
d->page->d->client = 0; // unset the page client |
285 |
} |
|
286 |
||
287 |
if (d->page && d->page->parent() == this) |
|
288 |
delete d->page; |
|
289 |
||
290 |
delete d; |
|
291 |
} |
|
292 |
||
293 |
/*! |
|
294 |
Returns a pointer to the underlying web page. |
|
295 |
||
296 |
\sa setPage() |
|
297 |
*/ |
|
298 |
QWebPage* QGraphicsWebView::page() const |
|
299 |
{ |
|
300 |
if (!d->page) { |
|
301 |
QGraphicsWebView* that = const_cast<QGraphicsWebView*>(this); |
|
302 |
QWebPage* page = new QWebPage(that); |
|
303 |
||
304 |
// Default to not having a background, in the case |
|
305 |
// the page doesn't provide one. |
|
306 |
QPalette palette = QApplication::palette(); |
|
307 |
palette.setBrush(QPalette::Base, QColor::fromRgbF(0, 0, 0, 0)); |
|
308 |
page->setPalette(palette); |
|
309 |
||
310 |
that->setPage(page); |
|
311 |
} |
|
312 |
||
313 |
return d->page; |
|
314 |
} |
|
315 |
||
316 |
/*! \reimp |
|
317 |
*/ |
|
318 |
void QGraphicsWebView::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget*) |
|
319 |
{ |
|
320 |
page()->mainFrame()->render(painter, option->exposedRect.toRect()); |
|
321 |
} |
|
322 |
||
323 |
/*! \reimp |
|
324 |
*/ |
|
325 |
bool QGraphicsWebView::sceneEvent(QEvent* event) |
|
326 |
{ |
|
327 |
// Re-implemented in order to allows fixing event-related bugs in patch releases. |
|
328 |
return QGraphicsWidget::sceneEvent(event); |
|
329 |
} |
|
330 |
||
331 |
/*! \reimp |
|
332 |
*/ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
333 |
QVariant QGraphicsWebView::itemChange(GraphicsItemChange change, const QVariant& value) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
334 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
335 |
switch (change) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
336 |
// Differently from QWebView, it is interesting to QGraphicsWebView to handle |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
337 |
// post mouse cursor change notifications. Reason: 'ItemCursorChange' is sent |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
338 |
// as the first action in QGraphicsItem::setCursor implementation, and at that |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
339 |
// item widget's cursor has not been effectively changed yet. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
340 |
// After cursor is properly set (at 'ItemCursorHasChanged' emission time), we |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
341 |
// fire 'CursorChange'. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
342 |
case ItemCursorChange: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
343 |
return value; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
344 |
case ItemCursorHasChanged: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
345 |
QEvent event(QEvent::CursorChange); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
346 |
QApplication::sendEvent(this, &event); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
347 |
return value; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
348 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
349 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
350 |
return QGraphicsWidget::itemChange(change, value); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
351 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
352 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
353 |
/*! \reimp |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
354 |
*/ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
355 |
QSizeF QGraphicsWebView::sizeHint(Qt::SizeHint which, const QSizeF& constraint) const |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
356 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
357 |
if (which == Qt::PreferredSize) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
358 |
return QSizeF(800, 600); // ### |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
359 |
return QGraphicsWidget::sizeHint(which, constraint); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
360 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
361 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
362 |
/*! \reimp |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
363 |
*/ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
364 |
QVariant QGraphicsWebView::inputMethodQuery(Qt::InputMethodQuery query) const |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
365 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
366 |
if (d->page) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
367 |
return d->page->inputMethodQuery(query); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
368 |
return QVariant(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
369 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
370 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
371 |
/*! \reimp |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
372 |
*/ |
0 | 373 |
bool QGraphicsWebView::event(QEvent* event) |
374 |
{ |
|
375 |
// Re-implemented in order to allows fixing event-related bugs in patch releases. |
|
376 |
||
377 |
if (d->page) { |
|
378 |
#ifndef QT_NO_CONTEXTMENU |
|
379 |
if (event->type() == QEvent::GraphicsSceneContextMenu) { |
|
380 |
if (!isEnabled()) |
|
381 |
return false; |
|
382 |
||
383 |
QGraphicsSceneContextMenuEvent* ev = static_cast<QGraphicsSceneContextMenuEvent*>(event); |
|
384 |
QContextMenuEvent fakeEvent(QContextMenuEvent::Reason(ev->reason()), ev->pos().toPoint()); |
|
385 |
if (d->page->swallowContextMenuEvent(&fakeEvent)) { |
|
386 |
event->accept(); |
|
387 |
return true; |
|
388 |
} |
|
389 |
d->page->updatePositionDependentActions(fakeEvent.pos()); |
|
390 |
} else |
|
391 |
#endif // QT_NO_CONTEXTMENU |
|
392 |
{ |
|
393 |
#ifndef QT_NO_CURSOR |
|
394 |
#if QT_VERSION >= 0x040400 |
|
395 |
if (event->type() == QEvent::CursorChange) { |
|
396 |
// An unsetCursor will set the cursor to Qt::ArrowCursor. |
|
397 |
// Thus this cursor change might be a QWidget::unsetCursor() |
|
398 |
// If this is not the case and it came from WebCore, the |
|
399 |
// QWebPageClient already has set its cursor internally |
|
400 |
// to Qt::ArrowCursor, so updating the cursor is always |
|
401 |
// right, as it falls back to the last cursor set by |
|
402 |
// WebCore. |
|
403 |
// FIXME: Add a QEvent::CursorUnset or similar to Qt. |
|
404 |
if (cursor().shape() == Qt::ArrowCursor) |
|
405 |
d->resetCursor(); |
|
406 |
} |
|
407 |
#endif |
|
408 |
#endif |
|
409 |
} |
|
410 |
} |
|
411 |
return QGraphicsWidget::event(event); |
|
412 |
} |
|
413 |
||
414 |
/*! |
|
415 |
Makes \a page the new web page of the web graphicsitem. |
|
416 |
||
417 |
The parent QObject of the provided page remains the owner |
|
418 |
of the object. If the current document is a child of the web |
|
419 |
view, it will be deleted. |
|
420 |
||
421 |
\sa page() |
|
422 |
*/ |
|
423 |
void QGraphicsWebView::setPage(QWebPage* page) |
|
424 |
{ |
|
425 |
if (d->page == page) |
|
426 |
return; |
|
427 |
||
428 |
if (d->page) { |
|
429 |
d->page->d->client = 0; // unset the page client |
|
430 |
if (d->page->parent() == this) |
|
431 |
delete d->page; |
|
432 |
else |
|
433 |
d->page->disconnect(this); |
|
434 |
} |
|
435 |
||
436 |
d->page = page; |
|
437 |
if (!d->page) |
|
438 |
return; |
|
439 |
d->page->d->client = d; // set the page client |
|
440 |
||
441 |
QSize size = geometry().size().toSize(); |
|
442 |
page->setViewportSize(size); |
|
443 |
||
444 |
QWebFrame* mainFrame = d->page->mainFrame(); |
|
445 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
446 |
connect(mainFrame, SIGNAL(titleChanged(QString)), |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
447 |
this, SIGNAL(titleChanged(QString))); |
0 | 448 |
connect(mainFrame, SIGNAL(iconChanged()), |
449 |
this, SIGNAL(iconChanged())); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
450 |
connect(mainFrame, SIGNAL(urlChanged(QUrl)), |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
451 |
this, SIGNAL(urlChanged(QUrl))); |
0 | 452 |
connect(d->page, SIGNAL(loadStarted()), |
453 |
this, SIGNAL(loadStarted())); |
|
454 |
connect(d->page, SIGNAL(loadProgress(int)), |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
455 |
this, SIGNAL(loadProgress(int))); |
0 | 456 |
connect(d->page, SIGNAL(loadFinished(bool)), |
457 |
this, SLOT(_q_doLoadFinished(bool))); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
458 |
connect(d->page, SIGNAL(statusBarMessage(QString)), |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
459 |
this, SIGNAL(statusBarMessage(QString))); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
460 |
connect(d->page, SIGNAL(linkClicked(QUrl)), |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
461 |
this, SIGNAL(linkClicked(QUrl))); |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
462 |
connect(d->page, SIGNAL(microFocusChanged()), |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
463 |
this, SLOT(_q_updateMicroFocus())); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
464 |
connect(d->page, SIGNAL(destroyed()), |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
465 |
this, SLOT(_q_pageDestroyed())); |
0 | 466 |
} |
467 |
||
468 |
/*! |
|
469 |
\property QGraphicsWebView::url |
|
470 |
\brief the url of the web page currently viewed |
|
471 |
||
472 |
Setting this property clears the view and loads the URL. |
|
473 |
||
474 |
By default, this property contains an empty, invalid URL. |
|
475 |
||
476 |
\sa load(), urlChanged() |
|
477 |
*/ |
|
478 |
||
479 |
void QGraphicsWebView::setUrl(const QUrl &url) |
|
480 |
{ |
|
481 |
page()->mainFrame()->setUrl(url); |
|
482 |
} |
|
483 |
||
484 |
QUrl QGraphicsWebView::url() const |
|
485 |
{ |
|
486 |
if (d->page) |
|
487 |
return d->page->mainFrame()->url(); |
|
488 |
||
489 |
return QUrl(); |
|
490 |
} |
|
491 |
||
492 |
/*! |
|
493 |
\property QGraphicsWebView::title |
|
494 |
\brief the title of the web page currently viewed |
|
495 |
||
496 |
By default, this property contains an empty string. |
|
497 |
||
498 |
\sa titleChanged() |
|
499 |
*/ |
|
500 |
QString QGraphicsWebView::title() const |
|
501 |
{ |
|
502 |
if (d->page) |
|
503 |
return d->page->mainFrame()->title(); |
|
504 |
||
505 |
return QString(); |
|
506 |
} |
|
507 |
||
508 |
/*! |
|
509 |
\property QGraphicsWebView::icon |
|
510 |
\brief the icon associated with the web page currently viewed |
|
511 |
||
512 |
By default, this property contains a null icon. |
|
513 |
||
514 |
\sa iconChanged(), QWebSettings::iconForUrl() |
|
515 |
*/ |
|
516 |
QIcon QGraphicsWebView::icon() const |
|
517 |
{ |
|
518 |
if (d->page) |
|
519 |
return d->page->mainFrame()->icon(); |
|
520 |
||
521 |
return QIcon(); |
|
522 |
} |
|
523 |
||
524 |
/*! |
|
525 |
\property QGraphicsWebView::zoomFactor |
|
526 |
\since 4.5 |
|
527 |
\brief the zoom factor for the view |
|
528 |
*/ |
|
529 |
||
530 |
void QGraphicsWebView::setZoomFactor(qreal factor) |
|
531 |
{ |
|
532 |
if (factor == page()->mainFrame()->zoomFactor()) |
|
533 |
return; |
|
534 |
||
535 |
page()->mainFrame()->setZoomFactor(factor); |
|
536 |
} |
|
537 |
||
538 |
qreal QGraphicsWebView::zoomFactor() const |
|
539 |
{ |
|
540 |
return page()->mainFrame()->zoomFactor(); |
|
541 |
} |
|
542 |
||
543 |
/*! \reimp |
|
544 |
*/ |
|
545 |
void QGraphicsWebView::updateGeometry() |
|
546 |
{ |
|
547 |
QGraphicsWidget::updateGeometry(); |
|
548 |
||
549 |
if (!d->page) |
|
550 |
return; |
|
551 |
||
552 |
QSize size = geometry().size().toSize(); |
|
553 |
d->page->setViewportSize(size); |
|
554 |
} |
|
555 |
||
556 |
/*! \reimp |
|
557 |
*/ |
|
558 |
void QGraphicsWebView::setGeometry(const QRectF& rect) |
|
559 |
{ |
|
560 |
QGraphicsWidget::setGeometry(rect); |
|
561 |
||
562 |
if (!d->page) |
|
563 |
return; |
|
564 |
||
565 |
// NOTE: call geometry() as setGeometry ensures that |
|
566 |
// the geometry is within legal bounds (minimumSize, maximumSize) |
|
567 |
QSize size = geometry().size().toSize(); |
|
568 |
d->page->setViewportSize(size); |
|
569 |
} |
|
570 |
||
571 |
/*! |
|
572 |
Convenience slot that stops loading the document. |
|
573 |
||
574 |
\sa reload(), loadFinished() |
|
575 |
*/ |
|
576 |
void QGraphicsWebView::stop() |
|
577 |
{ |
|
578 |
if (d->page) |
|
579 |
d->page->triggerAction(QWebPage::Stop); |
|
580 |
} |
|
581 |
||
582 |
/*! |
|
583 |
Convenience slot that loads the previous document in the list of documents |
|
584 |
built by navigating links. Does nothing if there is no previous document. |
|
585 |
||
586 |
\sa forward() |
|
587 |
*/ |
|
588 |
void QGraphicsWebView::back() |
|
589 |
{ |
|
590 |
if (d->page) |
|
591 |
d->page->triggerAction(QWebPage::Back); |
|
592 |
} |
|
593 |
||
594 |
/*! |
|
595 |
Convenience slot that loads the next document in the list of documents |
|
596 |
built by navigating links. Does nothing if there is no next document. |
|
597 |
||
598 |
\sa back() |
|
599 |
*/ |
|
600 |
void QGraphicsWebView::forward() |
|
601 |
{ |
|
602 |
if (d->page) |
|
603 |
d->page->triggerAction(QWebPage::Forward); |
|
604 |
} |
|
605 |
||
606 |
/*! |
|
607 |
Reloads the current document. |
|
608 |
||
609 |
\sa stop(), loadStarted() |
|
610 |
*/ |
|
611 |
void QGraphicsWebView::reload() |
|
612 |
{ |
|
613 |
if (d->page) |
|
614 |
d->page->triggerAction(QWebPage::Reload); |
|
615 |
} |
|
616 |
||
617 |
/*! |
|
618 |
Loads the specified \a url and displays it. |
|
619 |
||
620 |
\note The view remains the same until enough data has arrived to display the new \a url. |
|
621 |
||
622 |
\sa setUrl(), url(), urlChanged() |
|
623 |
*/ |
|
624 |
void QGraphicsWebView::load(const QUrl& url) |
|
625 |
{ |
|
626 |
page()->mainFrame()->load(url); |
|
627 |
} |
|
628 |
||
629 |
/*! |
|
630 |
\fn void QGraphicsWebView::load(const QNetworkRequest &request, QNetworkAccessManager::Operation operation, const QByteArray &body) |
|
631 |
||
632 |
Loads a network request, \a request, using the method specified in \a operation. |
|
633 |
||
634 |
\a body is optional and is only used for POST operations. |
|
635 |
||
636 |
\note The view remains the same until enough data has arrived to display the new url. |
|
637 |
||
638 |
\sa url(), urlChanged() |
|
639 |
*/ |
|
640 |
||
641 |
void QGraphicsWebView::load(const QNetworkRequest& request, |
|
642 |
QNetworkAccessManager::Operation operation, |
|
643 |
const QByteArray& body) |
|
644 |
{ |
|
645 |
page()->mainFrame()->load(request, operation, body); |
|
646 |
} |
|
647 |
||
648 |
/*! |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
649 |
Sets the content of the web view to the specified \a html. |
0 | 650 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
651 |
External objects such as stylesheets or images referenced in the HTML |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
652 |
document are located relative to \a baseUrl. |
0 | 653 |
|
654 |
The \a html is loaded immediately; external objects are loaded asynchronously. |
|
655 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
656 |
When using this method, WebKit assumes that external resources such as |
0 | 657 |
JavaScript programs or style sheets are encoded in UTF-8 unless otherwise |
658 |
specified. For example, the encoding of an external script can be specified |
|
659 |
through the charset attribute of the HTML script tag. Alternatively, the |
|
660 |
encoding can also be specified by the web server. |
|
661 |
||
662 |
\sa load(), setContent(), QWebFrame::toHtml() |
|
663 |
*/ |
|
664 |
void QGraphicsWebView::setHtml(const QString& html, const QUrl& baseUrl) |
|
665 |
{ |
|
666 |
page()->mainFrame()->setHtml(html, baseUrl); |
|
667 |
} |
|
668 |
||
669 |
/*! |
|
670 |
Sets the content of the web graphicsitem to the specified content \a data. If the \a mimeType argument |
|
671 |
is empty it is currently assumed that the content is HTML but in future versions we may introduce |
|
672 |
auto-detection. |
|
673 |
||
674 |
External objects referenced in the content are located relative to \a baseUrl. |
|
675 |
||
676 |
The \a data is loaded immediately; external objects are loaded asynchronously. |
|
677 |
||
678 |
\sa load(), setHtml(), QWebFrame::toHtml() |
|
679 |
*/ |
|
680 |
void QGraphicsWebView::setContent(const QByteArray& data, const QString& mimeType, const QUrl& baseUrl) |
|
681 |
{ |
|
682 |
page()->mainFrame()->setContent(data, mimeType, baseUrl); |
|
683 |
} |
|
684 |
||
685 |
/*! |
|
686 |
Returns a pointer to the view's history of navigated web pages. |
|
687 |
||
688 |
It is equivalent to |
|
689 |
||
690 |
\snippet webkitsnippets/qtwebkit_qwebview_snippet.cpp 0 |
|
691 |
*/ |
|
692 |
QWebHistory* QGraphicsWebView::history() const |
|
693 |
{ |
|
694 |
return page()->history(); |
|
695 |
} |
|
696 |
||
697 |
/*! |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
698 |
\property QGraphicsWebView::modified |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
699 |
\brief whether the document was modified by the user |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
700 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
701 |
Parts of HTML documents can be editable for example through the |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
702 |
\c{contenteditable} attribute on HTML elements. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
703 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
704 |
By default, this property is false. |
0 | 705 |
*/ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
706 |
bool QGraphicsWebView::isModified() const |
0 | 707 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
708 |
if (d->page) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
709 |
return d->page->isModified(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
710 |
return false; |
0 | 711 |
} |
712 |
||
713 |
/*! |
|
714 |
Returns a pointer to the view/page specific settings object. |
|
715 |
||
716 |
It is equivalent to |
|
717 |
||
718 |
\snippet webkitsnippets/qtwebkit_qwebview_snippet.cpp 1 |
|
719 |
||
720 |
\sa QWebSettings::globalSettings() |
|
721 |
*/ |
|
722 |
QWebSettings* QGraphicsWebView::settings() const |
|
723 |
{ |
|
724 |
return page()->settings(); |
|
725 |
} |
|
726 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
727 |
/*! |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
728 |
Returns a pointer to a QAction that encapsulates the specified web action \a action. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
729 |
*/ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
730 |
QAction *QGraphicsWebView::pageAction(QWebPage::WebAction action) const |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
731 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
732 |
return page()->action(action); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
733 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
734 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
735 |
/*! |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
736 |
Triggers the specified \a action. If it is a checkable action the specified |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
737 |
\a checked state is assumed. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
738 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
739 |
\sa pageAction() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
740 |
*/ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
741 |
void QGraphicsWebView::triggerPageAction(QWebPage::WebAction action, bool checked) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
742 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
743 |
page()->triggerAction(action, checked); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
744 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
745 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
746 |
/*! |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
747 |
Finds the specified string, \a subString, in the page, using the given \a options. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
748 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
749 |
If the HighlightAllOccurrences flag is passed, the function will highlight all occurrences |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
750 |
that exist in the page. All subsequent calls will extend the highlight, rather than |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
751 |
replace it, with occurrences of the new string. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
752 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
753 |
If the HighlightAllOccurrences flag is not passed, the function will select an occurrence |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
754 |
and all subsequent calls will replace the current occurrence with the next one. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
755 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
756 |
To clear the selection, just pass an empty string. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
757 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
758 |
Returns true if \a subString was found; otherwise returns false. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
759 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
760 |
\sa QWebPage::selectedText(), QWebPage::selectionChanged() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
761 |
*/ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
762 |
bool QGraphicsWebView::findText(const QString &subString, QWebPage::FindFlags options) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
763 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
764 |
if (d->page) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
765 |
return d->page->findText(subString, options); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
766 |
return false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
767 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
768 |
|
0 | 769 |
/*! \reimp |
770 |
*/ |
|
771 |
void QGraphicsWebView::hoverMoveEvent(QGraphicsSceneHoverEvent* ev) |
|
772 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
773 |
if (d->page) { |
0 | 774 |
const bool accepted = ev->isAccepted(); |
775 |
QMouseEvent me = QMouseEvent(QEvent::MouseMove, |
|
776 |
ev->pos().toPoint(), Qt::NoButton, |
|
777 |
Qt::NoButton, Qt::NoModifier); |
|
778 |
d->page->event(&me); |
|
779 |
ev->setAccepted(accepted); |
|
780 |
} |
|
781 |
||
782 |
if (!ev->isAccepted()) |
|
783 |
QGraphicsItem::hoverMoveEvent(ev); |
|
784 |
} |
|
785 |
||
786 |
/*! \reimp |
|
787 |
*/ |
|
788 |
void QGraphicsWebView::hoverLeaveEvent(QGraphicsSceneHoverEvent* ev) |
|
789 |
{ |
|
790 |
Q_UNUSED(ev); |
|
791 |
} |
|
792 |
||
793 |
/*! \reimp |
|
794 |
*/ |
|
795 |
void QGraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent* ev) |
|
796 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
797 |
if (d->page) { |
0 | 798 |
const bool accepted = ev->isAccepted(); |
799 |
d->page->event(ev); |
|
800 |
ev->setAccepted(accepted); |
|
801 |
} |
|
802 |
||
803 |
if (!ev->isAccepted()) |
|
804 |
QGraphicsItem::mouseMoveEvent(ev); |
|
805 |
} |
|
806 |
||
807 |
/*! \reimp |
|
808 |
*/ |
|
809 |
void QGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent* ev) |
|
810 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
811 |
if (d->page) { |
0 | 812 |
const bool accepted = ev->isAccepted(); |
813 |
d->page->event(ev); |
|
814 |
ev->setAccepted(accepted); |
|
815 |
} |
|
816 |
||
817 |
if (!ev->isAccepted()) |
|
818 |
QGraphicsItem::mousePressEvent(ev); |
|
819 |
} |
|
820 |
||
821 |
/*! \reimp |
|
822 |
*/ |
|
823 |
void QGraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent* ev) |
|
824 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
825 |
if (d->page) { |
0 | 826 |
const bool accepted = ev->isAccepted(); |
827 |
d->page->event(ev); |
|
828 |
ev->setAccepted(accepted); |
|
829 |
} |
|
830 |
||
831 |
if (!ev->isAccepted()) |
|
832 |
QGraphicsItem::mouseReleaseEvent(ev); |
|
833 |
} |
|
834 |
||
835 |
/*! \reimp |
|
836 |
*/ |
|
837 |
void QGraphicsWebView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* ev) |
|
838 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
839 |
if (d->page) { |
0 | 840 |
const bool accepted = ev->isAccepted(); |
841 |
d->page->event(ev); |
|
842 |
ev->setAccepted(accepted); |
|
843 |
} |
|
844 |
||
845 |
if (!ev->isAccepted()) |
|
846 |
QGraphicsItem::mouseDoubleClickEvent(ev); |
|
847 |
} |
|
848 |
||
849 |
/*! \reimp |
|
850 |
*/ |
|
851 |
void QGraphicsWebView::keyPressEvent(QKeyEvent* ev) |
|
852 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
853 |
if (d->page) |
0 | 854 |
d->page->event(ev); |
855 |
||
856 |
if (!ev->isAccepted()) |
|
857 |
QGraphicsItem::keyPressEvent(ev); |
|
858 |
} |
|
859 |
||
860 |
/*! \reimp |
|
861 |
*/ |
|
862 |
void QGraphicsWebView::keyReleaseEvent(QKeyEvent* ev) |
|
863 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
864 |
if (d->page) |
0 | 865 |
d->page->event(ev); |
866 |
||
867 |
if (!ev->isAccepted()) |
|
868 |
QGraphicsItem::keyReleaseEvent(ev); |
|
869 |
} |
|
870 |
||
871 |
/*! \reimp |
|
872 |
*/ |
|
873 |
void QGraphicsWebView::focusInEvent(QFocusEvent* ev) |
|
874 |
{ |
|
875 |
if (d->page) |
|
876 |
d->page->event(ev); |
|
877 |
else |
|
878 |
QGraphicsItem::focusInEvent(ev); |
|
879 |
} |
|
880 |
||
881 |
/*! \reimp |
|
882 |
*/ |
|
883 |
void QGraphicsWebView::focusOutEvent(QFocusEvent* ev) |
|
884 |
{ |
|
885 |
if (d->page) |
|
886 |
d->page->event(ev); |
|
887 |
else |
|
888 |
QGraphicsItem::focusOutEvent(ev); |
|
889 |
} |
|
890 |
||
891 |
/*! \reimp |
|
892 |
*/ |
|
893 |
bool QGraphicsWebView::focusNextPrevChild(bool next) |
|
894 |
{ |
|
895 |
if (d->page) |
|
896 |
return d->page->focusNextPrevChild(next); |
|
897 |
||
898 |
return QGraphicsWidget::focusNextPrevChild(next); |
|
899 |
} |
|
900 |
||
901 |
/*! \reimp |
|
902 |
*/ |
|
903 |
void QGraphicsWebView::dragEnterEvent(QGraphicsSceneDragDropEvent* ev) |
|
904 |
{ |
|
905 |
#ifndef QT_NO_DRAGANDDROP |
|
906 |
//if (d->page) |
|
907 |
// d->page->event(ev); |
|
908 |
//Just remove this line below when the code above is working |
|
909 |
Q_UNUSED(ev); |
|
910 |
#else |
|
911 |
Q_UNUSED(ev); |
|
912 |
#endif |
|
913 |
} |
|
914 |
||
915 |
/*! \reimp |
|
916 |
*/ |
|
917 |
void QGraphicsWebView::dragLeaveEvent(QGraphicsSceneDragDropEvent* ev) |
|
918 |
{ |
|
919 |
#ifndef QT_NO_DRAGANDDROP |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
920 |
if (d->page) { |
0 | 921 |
const bool accepted = ev->isAccepted(); |
922 |
d->page->event(ev); |
|
923 |
ev->setAccepted(accepted); |
|
924 |
} |
|
925 |
||
926 |
if (!ev->isAccepted()) |
|
927 |
QGraphicsWidget::dragLeaveEvent(ev); |
|
928 |
#else |
|
929 |
Q_UNUSED(ev); |
|
930 |
#endif |
|
931 |
} |
|
932 |
||
933 |
/*! \reimp |
|
934 |
*/ |
|
935 |
void QGraphicsWebView::dragMoveEvent(QGraphicsSceneDragDropEvent* ev) |
|
936 |
{ |
|
937 |
#ifndef QT_NO_DRAGANDDROP |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
938 |
if (d->page) { |
0 | 939 |
const bool accepted = ev->isAccepted(); |
940 |
d->page->event(ev); |
|
941 |
ev->setAccepted(accepted); |
|
942 |
} |
|
943 |
||
944 |
if (!ev->isAccepted()) |
|
945 |
QGraphicsWidget::dragMoveEvent(ev); |
|
946 |
#else |
|
947 |
Q_UNUSED(ev); |
|
948 |
#endif |
|
949 |
} |
|
950 |
||
951 |
/*! \reimp |
|
952 |
*/ |
|
953 |
void QGraphicsWebView::dropEvent(QGraphicsSceneDragDropEvent* ev) |
|
954 |
{ |
|
955 |
#ifndef QT_NO_DRAGANDDROP |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
956 |
if (d->page) { |
0 | 957 |
const bool accepted = ev->isAccepted(); |
958 |
d->page->event(ev); |
|
959 |
ev->setAccepted(accepted); |
|
960 |
} |
|
961 |
||
962 |
if (!ev->isAccepted()) |
|
963 |
QGraphicsWidget::dropEvent(ev); |
|
964 |
#else |
|
965 |
Q_UNUSED(ev); |
|
966 |
#endif |
|
967 |
} |
|
968 |
||
969 |
#ifndef QT_NO_CONTEXTMENU |
|
970 |
/*! \reimp |
|
971 |
*/ |
|
972 |
void QGraphicsWebView::contextMenuEvent(QGraphicsSceneContextMenuEvent* ev) |
|
973 |
{ |
|
974 |
if (d->page) { |
|
975 |
const bool accepted = ev->isAccepted(); |
|
976 |
d->page->event(ev); |
|
977 |
ev->setAccepted(accepted); |
|
978 |
} |
|
979 |
} |
|
980 |
#endif // QT_NO_CONTEXTMENU |
|
981 |
||
982 |
#ifndef QT_NO_WHEELEVENT |
|
983 |
/*! \reimp |
|
984 |
*/ |
|
985 |
void QGraphicsWebView::wheelEvent(QGraphicsSceneWheelEvent* ev) |
|
986 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
987 |
if (d->page) { |
0 | 988 |
const bool accepted = ev->isAccepted(); |
989 |
d->page->event(ev); |
|
990 |
ev->setAccepted(accepted); |
|
991 |
} |
|
992 |
||
993 |
if (!ev->isAccepted()) |
|
994 |
QGraphicsItem::wheelEvent(ev); |
|
995 |
} |
|
996 |
#endif // QT_NO_WHEELEVENT |
|
997 |
||
998 |
/*! \reimp |
|
999 |
*/ |
|
1000 |
void QGraphicsWebView::inputMethodEvent(QInputMethodEvent* ev) |
|
1001 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1002 |
if (d->page) |
0 | 1003 |
d->page->event(ev); |
1004 |
||
1005 |
if (!ev->isAccepted()) |
|
1006 |
QGraphicsItem::inputMethodEvent(ev); |
|
1007 |
} |
|
1008 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1009 |
/*! |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1010 |
\fn void QGraphicsWebView::statusBarMessage(const QString& text) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1011 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1012 |
This signal is emitted when the statusbar \a text is changed by the page. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1013 |
*/ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1014 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1015 |
/*! |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1016 |
\fn void QGraphicsWebView::loadProgress(int progress) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1017 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1018 |
This signal is emitted every time an element in the web page |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1019 |
completes loading and the overall loading progress advances. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1020 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1021 |
This signal tracks the progress of all child frames. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1022 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1023 |
The current value is provided by \a progress and scales from 0 to 100, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1024 |
which is the default range of QProgressBar. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1025 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1026 |
\sa loadStarted(), loadFinished() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1027 |
*/ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1028 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1029 |
/*! |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1030 |
\fn void QGraphicsWebView::linkClicked(const QUrl &url) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1031 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1032 |
This signal is emitted whenever the user clicks on a link and the page's linkDelegationPolicy |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1033 |
property is set to delegate the link handling for the specified \a url. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1034 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1035 |
\sa QWebPage::linkDelegationPolicy() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1036 |
*/ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1037 |
|
0 | 1038 |
#include "moc_qgraphicswebview.cpp" |