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 |
|
|
22 |
#include "PageSnippet.h"
|
|
23 |
#include "PageItem.h"
|
|
24 |
#include "Utilities.h"
|
|
25 |
#include "ExternalEventCharm.h"
|
|
26 |
|
|
27 |
#include <QGraphicsWebView>
|
|
28 |
#include <QVariant>
|
|
29 |
|
|
30 |
namespace GVA {
|
|
31 |
|
|
32 |
// ----------------------------
|
|
33 |
// Inlines
|
|
34 |
// ----------------------------
|
|
35 |
|
|
36 |
inline PageItem *PageSnippet::pageItem() {
|
|
37 |
return static_cast<PageItem *>(widget());
|
|
38 |
}
|
|
39 |
|
|
40 |
inline PageItem const *PageSnippet::constPageItem() const {
|
|
41 |
return static_cast<PageItem const *>(constWidget());
|
|
42 |
}
|
|
43 |
|
|
44 |
// ----------------------------
|
|
45 |
// PageSnippet
|
|
46 |
// ----------------------------
|
|
47 |
|
|
48 |
PageSnippet::PageSnippet(const QString & elementId, ChromeWidget * chrome,
|
|
49 |
QGraphicsWidget * widget, const QWebElement & element)
|
|
50 |
: ChromeSnippet(elementId, chrome, widget, element),
|
|
51 |
m_externalEventCharm(0)
|
|
52 |
{
|
|
53 |
}
|
|
54 |
|
|
55 |
PageSnippet::~PageSnippet() {
|
|
56 |
delete m_externalEventCharm;
|
|
57 |
}
|
|
58 |
|
|
59 |
PageSnippet * PageSnippet::instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element)
|
|
60 |
{
|
|
61 |
PageSnippet* that = new PageSnippet(elementId, chrome, 0, element);
|
|
62 |
that->setChromeWidget( new PageItem( that, chrome ) );
|
|
63 |
return that;
|
|
64 |
}
|
|
65 |
|
|
66 |
void PageSnippet::setChromeWidget(QGraphicsWidget * widget) {
|
|
67 |
ChromeSnippet::setChromeWidget(widget);
|
|
68 |
m_externalEventCharm = new ExternalEventCharm(widget);
|
|
69 |
safe_connect(m_externalEventCharm, SIGNAL(externalMouseEvent(QEvent*, const QString &, const QString &)),
|
|
70 |
this, SIGNAL(externalMouseEvent(QEvent*, const QString &, const QString &)));
|
|
71 |
}
|
|
72 |
|
|
73 |
void PageSnippet::setVisible(bool visiblity, bool animate) {
|
|
74 |
ChromeSnippet::setVisible(visiblity, animate);
|
|
75 |
}
|
|
76 |
|
|
77 |
QString PageSnippet::url() const {
|
|
78 |
return constPageItem()->url();
|
|
79 |
}
|
|
80 |
|
|
81 |
void PageSnippet::setUrl(const QString &url) {
|
|
82 |
pageItem()->setUrl(url);
|
|
83 |
}
|
|
84 |
|
|
85 |
void PageSnippet::setHtml(const QString &value) {
|
|
86 |
pageItem()->setHtml(value);
|
|
87 |
}
|
|
88 |
|
|
89 |
QString PageSnippet::html() const {
|
|
90 |
return constPageItem()->html();
|
|
91 |
}
|
|
92 |
|
|
93 |
void PageSnippet::setGeometry(int x, int y, int width, int height) {
|
|
94 |
widget()->setGeometry(x, y, width, height);
|
|
95 |
}
|
|
96 |
|
|
97 |
void PageSnippet::setSize(int width, int height) {
|
|
98 |
pageItem()->setSize(QSizeF(width, height));
|
|
99 |
}
|
|
100 |
|
|
101 |
QVariant PageSnippet::evaluateJavaScript(const QString &expression) {
|
|
102 |
return pageItem()->evaluateJavaScript(expression);
|
|
103 |
}
|
|
104 |
|
|
105 |
void PageSnippet::instantiate() {
|
|
106 |
pageItem()->instantiate();
|
|
107 |
}
|
|
108 |
|
|
109 |
void PageSnippet::cleanUp() {
|
|
110 |
pageItem()->cleanUpOnTimer();
|
|
111 |
}
|
|
112 |
|
|
113 |
}
|