|
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 |
|
53 // ChromeSnippet overrides: |
|
54 virtual void setVisible(bool visiblity, bool animate = true); |
|
55 virtual void setWidget(QGraphicsWidget * widget); |
|
56 |
|
57 /// The URL of the web page. |
|
58 QString url() const; |
|
59 void setUrl(const QString &url); |
|
60 Q_PROPERTY(QString url READ url WRITE setUrl) |
|
61 |
|
62 /// The contents of the web page in HTML. |
|
63 void setHtml(const QString &value); |
|
64 QString html() const; |
|
65 Q_PROPERTY(QString html WRITE setHtml READ html) |
|
66 |
|
67 public slots: |
|
68 void setGeometry(int x, int y, int width, int height); |
|
69 void setSize(int width, int height); |
|
70 |
|
71 /// Evaluates a JavaScript expression in the context of the web page (not the chrome's context!). |
|
72 QVariant evaluateJavaScript(const QString &expression); |
|
73 |
|
74 /// Instantiates the web view, web page, etc. This is called automatically when the |
|
75 /// window is shown. |
|
76 void instantiate(); |
|
77 |
|
78 /// Destroys the web view, web page, etc. to free up memory. |
|
79 void cleanUp(); |
|
80 |
|
81 private slots: |
|
82 /// Called when the page has finished loading. |
|
83 void onLoadFinished(bool ok); |
|
84 |
|
85 private: |
|
86 PageItem *pageItem(); |
|
87 PageItem const *constPageItem() const; |
|
88 }; |
|
89 |
|
90 } |
|
91 |
|
92 #endif /* PAGESNIPPET_H_ */ |