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 |
#ifndef PAGESNIPPET_H_
|
|
23 |
#define PAGESNIPPET_H_
|
|
24 |
|
|
25 |
#include "ChromeSnippet.h"
|
|
26 |
|
|
27 |
class QGraphicsWebView;
|
|
28 |
|
|
29 |
namespace GVA {
|
|
30 |
|
|
31 |
class PageItem;
|
|
32 |
class ExternalEventCharm;
|
|
33 |
|
|
34 |
/*! \ingroup JavascriptAPI
|
|
35 |
* \brief This class provides a snippet that contains a QWebView.
|
|
36 |
*
|
|
37 |
* This class provides a snippet that contains a QWebView, allowing entire web pages to loaded
|
|
38 |
* and displayed in the chrome. Note that this snippet has no real physical representation in the
|
|
39 |
* chrome page (chrome.html), ie. the DIV that defines it is empty. Use the \ref url and
|
|
40 |
* \ref html properties to set the contents of the page.
|
|
41 |
*
|
|
42 |
* Note: use these snippets sparingly since they use a significant amount of memory when
|
|
43 |
* instantiated! If possible, share them and/or de-instantiate them whenever possible by calling
|
|
44 |
* \ref cleanUp.
|
|
45 |
* \sa PageItem
|
|
46 |
*/
|
|
47 |
class PageSnippet : public ChromeSnippet {
|
|
48 |
Q_OBJECT
|
|
49 |
public:
|
|
50 |
PageSnippet(const QString & elementId, ChromeWidget * chrome,
|
|
51 |
QGraphicsWidget * widget, const QWebElement & element);
|
|
52 |
~PageSnippet();
|
|
53 |
|
|
54 |
static PageSnippet * instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element);
|
|
55 |
|
|
56 |
// ChromeSnippet overrides:
|
|
57 |
virtual void setVisible(bool visiblity, bool animate = true);
|
|
58 |
virtual void setChromeWidget(QGraphicsWidget * widget);
|
|
59 |
|
|
60 |
/// The URL of the web page.
|
|
61 |
QString url() const;
|
|
62 |
void setUrl(const QString &url);
|
|
63 |
Q_PROPERTY(QString url READ url WRITE setUrl)
|
|
64 |
|
|
65 |
/// The contents of the web page in HTML.
|
|
66 |
void setHtml(const QString &value);
|
|
67 |
QString html() const;
|
|
68 |
Q_PROPERTY(QString html WRITE setHtml READ html)
|
12
|
69 |
|
|
70 |
bool hasFocus();
|
|
71 |
Q_PROPERTY(bool hasFocus READ hasFocus)
|
3
|
72 |
|
|
73 |
public slots:
|
|
74 |
void setGeometry(int x, int y, int width, int height);
|
|
75 |
void setSize(int width, int height);
|
|
76 |
|
|
77 |
/// Evaluates a JavaScript expression in the context of the web page (not the chrome's context!).
|
|
78 |
QVariant evaluateJavaScript(const QString &expression);
|
|
79 |
|
|
80 |
/// Instantiates the web view, web page, etc. This is called automatically when the
|
|
81 |
/// window is shown.
|
|
82 |
void instantiate();
|
|
83 |
|
|
84 |
/// Destroys the web view, web page, etc. to free up memory.
|
|
85 |
void cleanUp();
|
|
86 |
|
|
87 |
private:
|
|
88 |
PageItem *pageItem();
|
|
89 |
PageItem const *constPageItem() const;
|
|
90 |
|
|
91 |
ExternalEventCharm *m_externalEventCharm;
|
|
92 |
};
|
|
93 |
|
|
94 |
}
|
|
95 |
|
|
96 |
#endif /* PAGESNIPPET_H_ */
|