3
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
*
|
|
5 |
* This program is free software: you can redistribute it and/or modify
|
|
6 |
* it under the terms of the GNU Lesser General Public License as published by
|
|
7 |
* the Free Software Foundation, version 2.1 of the License.
|
|
8 |
*
|
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
* GNU Lesser General Public License for more details.
|
|
13 |
*
|
|
14 |
* You should have received a copy of the GNU Lesser General Public License
|
|
15 |
* along with this program. If not,
|
|
16 |
* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
|
|
17 |
*
|
|
18 |
* Description:
|
|
19 |
*
|
|
20 |
*/
|
|
21 |
#include "WebView.h"
|
|
22 |
|
|
23 |
#include "browserpagefactory.h"
|
|
24 |
#include "wrtbrowsercontainer.h"
|
|
25 |
|
|
26 |
#include <QWebFrame>
|
|
27 |
#include <QWebPage>
|
16
|
28 |
#include "qstmgestureevent.h"
|
|
29 |
#include "qstmfilelogger.h"
|
3
|
30 |
|
|
31 |
namespace GVA {
|
|
32 |
|
|
33 |
WebView::WebView()
|
16
|
34 |
: WebViewParent()
|
3
|
35 |
, m_webPage(0)
|
16
|
36 |
{
|
|
37 |
setAttribute(Qt::WA_OpaquePaintEvent, true);
|
|
38 |
setResizesToContents(true);
|
|
39 |
setObjectName("WebView");
|
|
40 |
setAcceptHoverEvents(false);
|
|
41 |
installEventFilter(this);
|
|
42 |
}
|
3
|
43 |
|
|
44 |
WebView::~WebView()
|
|
45 |
{}
|
|
46 |
|
|
47 |
QWebPage* WebView::page() const
|
|
48 |
{
|
|
49 |
return m_webPage;
|
|
50 |
}
|
|
51 |
|
|
52 |
void WebView::setPage(QWebPage* page)
|
|
53 |
{
|
|
54 |
if (m_webPage == page)
|
|
55 |
return;
|
|
56 |
|
|
57 |
if (m_webPage) {
|
|
58 |
disconnect(m_webPage->mainFrame(), 0, this, 0);
|
|
59 |
m_webPage->setView(0);
|
|
60 |
}
|
|
61 |
|
|
62 |
m_webPage = page;
|
|
63 |
|
|
64 |
if (!m_webPage)
|
|
65 |
m_webPage = createWebPage();
|
|
66 |
|
16
|
67 |
WebViewParent::setPage(m_webPage);
|
|
68 |
|
|
69 |
setGeometry(QRectF(pos(), m_webPage->mainFrame()->contentsSize()));
|
3
|
70 |
|
|
71 |
emit titleChanged(title());
|
|
72 |
emit urlChanged(url());
|
|
73 |
}
|
|
74 |
|
|
75 |
QWebPage* WebView::createWebPage()
|
|
76 |
{
|
|
77 |
return reinterpret_cast<QWebPage*>(BrowserPageFactory::openBrowserPage());
|
|
78 |
}
|
|
79 |
|
16
|
80 |
|
|
81 |
bool WebView::sceneEvent(QEvent* event)
|
|
82 |
{
|
|
83 |
if (!WebViewParent::eventFilter(this, event)) {
|
|
84 |
return WebViewParent::sceneEvent(event);
|
|
85 |
}
|
|
86 |
return false;
|
|
87 |
}
|
|
88 |
|
|
89 |
bool WebView::eventFilter(QObject* o, QEvent* e)
|
|
90 |
{
|
|
91 |
return WebViewParent::eventFilter(o, e);
|
|
92 |
}
|
|
93 |
|
|
94 |
|
|
95 |
bool WebView::event(QEvent * e)
|
|
96 |
{
|
|
97 |
if (e->type() == QEvent::Gesture) {
|
|
98 |
QStm_Gesture* gesture = getQStmGesture(e);
|
|
99 |
if (gesture) {
|
|
100 |
QGraphicsObject* go = this->parentItem()->toGraphicsObject();
|
|
101 |
return go->event(e);
|
|
102 |
}
|
|
103 |
}
|
|
104 |
return WebViewParent::event(e);
|
|
105 |
}
|
|
106 |
|
3
|
107 |
}//namespace GVA
|