1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef _GINEBRA_CHROME_WIDGET_H_ |
|
20 #define _GINEBRA_CHROME_WIDGET_H_ |
|
21 |
|
22 #include <QtGui> |
|
23 #include <QMap> |
|
24 #include <QPainterPath> |
|
25 //#include "chromerenderer.h" |
|
26 |
|
27 //#define G_QUICKSTART |
|
28 |
|
29 class QWebPage; |
|
30 class ChromeSnippet; |
|
31 class QNetworkAccessManager; |
|
32 class QWebView; |
|
33 class QWebFrame; |
|
34 class QNetworkReply; |
|
35 class ChromeView; |
|
36 class QGraphicsScene; |
|
37 class QTimeLine; |
|
38 |
|
39 /** |
|
40 * \brief Manages chrome snippets. |
|
41 * |
|
42 * The ChromeWidget class manages the snippets that comprise the "chrome" of |
|
43 * the browser and the underlying web page that renders the snippets. |
|
44 * |
|
45 * \sa ChromeSnippet |
|
46 */ |
|
47 class ChromeWidget : public QObject |
|
48 { |
|
49 Q_OBJECT |
|
50 |
|
51 typedef enum { |
|
52 minimized, |
|
53 maximized |
|
54 } Visibility; |
|
55 |
|
56 public: |
|
57 friend class ChromeRenderer; |
|
58 ChromeWidget(ChromeView *parentChromeView, QGraphicsItem *parent, const QString &jsName); |
|
59 ~ChromeWidget(); |
|
60 void setChromeUrl(QString url); |
|
61 QString chromeUrl() const { return m_chromeUrl; } |
|
62 QWebPage * chromePage() { return m_chromePage; } |
|
63 void setContentPage(QWebPage * p); |
|
64 #ifdef Q_OS_SYMBIAN |
|
65 QPixmap * buffer(); |
|
66 #else |
|
67 QImage* buffer(); |
|
68 #endif |
|
69 QPainter* painter(); |
|
70 void setGeometry(const QRect &rect); |
|
71 void setGeometry(int x, int y, int w, int h) { setGeometry(QRect(x, y, w, h)); } |
|
72 ChromeSnippet *getSnippet(const QString &docElementId, QGraphicsItem *parent = 0); |
|
73 void getInitialChrome(); |
|
74 |
|
75 void show(const QString& id, int x, int y); |
|
76 void show(const QString& id); |
|
77 void hide(const QString& id); |
|
78 void setLocation(const QString& id, int x, int y); |
|
79 void setAnchor(const QString& id, const QString& anchor); |
|
80 void toggleVisibility(const QString& id); |
|
81 void toggleAttention(const QString& id); |
|
82 void setVisibilityAnimator(const QString& elementId, const QString & animatorName); |
|
83 void setAttentionAnimator(const QString& elementId, const QString & animatorName); |
|
84 QString getDisplayMode(); |
|
85 |
|
86 // Returns the javascript object that represents this object. |
|
87 QObject *jsObject(); |
|
88 |
|
89 //returns the parent chrome view |
|
90 ChromeView* getChromeView() { return m_parentChromeView; } |
|
91 |
|
92 signals: |
|
93 void delegateLink(const QUrl& url); |
|
94 void loadStarted(); |
|
95 void loadComplete(); |
|
96 void dragStarted(); |
|
97 void dragFinished(); |
|
98 void viewPortResize(QRect); |
|
99 |
|
100 |
|
101 public slots: |
|
102 void updateViewPort(); |
|
103 void setViewPort(QRect viewPort); |
|
104 void repaintRequested(QRect dirtyRect); |
|
105 |
|
106 protected slots: |
|
107 void frameCreated(QWebFrame* frame); |
|
108 void loadFinished(bool ok = true); |
|
109 void onLoadStarted(); |
|
110 void networkRequestFinished(QNetworkReply *); |
|
111 void debugAlert(const QString &msg); |
|
112 public: |
|
113 QSize getDocElementSize(const QString &id); |
|
114 QRect getDocElementRect(const QString &id); |
|
115 void updateChildGeometries(); |
|
116 void dump(); |
|
117 protected: |
|
118 QVariant getDocElement(const QString &id); |
|
119 QString getDocElementAttribute(const QString &id, const QString &attribute); |
|
120 QVariant getDocIdsByName(const QString &name); |
|
121 QVariant getDocIdsByClassName(const QString &name); |
|
122 QVariant getChildIdsByClassName(const QString &parentId, const QString &name); |
|
123 void resizeBuffer(); |
|
124 void updateOwnerAreas(); |
|
125 bool eventFilter(QObject *object, QEvent *event); |
|
126 void paintDirtyRegion(); |
|
127 |
|
128 // Get the snippet that contains the point pos. |
|
129 ChromeSnippet *getSnippet(QPoint pos) const; |
|
130 |
|
131 //Reconstruct snippets from the cache |
|
132 bool isCached(QString url); |
|
133 void cacheBuffer(); |
|
134 void restoreBuffer(); |
|
135 |
|
136 protected: |
|
137 //This is the web page that renders the chrome |
|
138 QWebPage *m_chromePage; |
|
139 |
|
140 private: |
|
141 QGraphicsItem *m_parentItem; |
|
142 ChromeView *m_parentChromeView; |
|
143 QMap<QString, ChromeSnippet *> m_snippetMap; |
|
144 QString m_chromeUrl; |
|
145 Visibility m_state; |
|
146 #ifdef Q_OS_SYMBIAN |
|
147 QPixmap *m_buffer; |
|
148 #else |
|
149 QImage *m_buffer; |
|
150 #endif |
|
151 QPainter *m_painter; |
|
152 QRegion m_dirtyRegion; |
|
153 QTimer *m_dirtyTimer; |
|
154 class ChromeWidgetJSObject *m_jsObject; // owned |
|
155 #ifdef G_QUICKSTART |
|
156 bool m_bufferCached; |
|
157 QString m_bufferFile; |
|
158 ChromeSnippet* m_fakeTopSnippet; |
|
159 ChromeSnippet* m_fakeBottomSnippet; |
|
160 #endif |
|
161 }; |
|
162 #endif |
|