1 /* |
1 /* |
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
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 * |
4 * |
9 * Initial Contributors: |
5 * This program is free software: you can redistribute it and/or modify |
10 * Nokia Corporation - initial contribution. |
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. |
11 * |
8 * |
12 * Contributors: |
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 * |
13 * |
14 * Description: |
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/". |
15 * |
17 * |
|
18 * Description: |
16 */ |
19 */ |
17 |
|
18 |
20 |
19 |
21 |
20 #ifndef GWebContentViewWidget_H_ |
22 #ifndef GWebContentViewWidget_H_ |
21 #define GWebContentViewWidget_H_ |
23 #define GWebContentViewWidget_H_ |
22 |
24 |
84 QWebPage* page() const; |
86 QWebPage* page() const; |
85 void setPage(QWebPage* pg); |
87 void setPage(QWebPage* pg); |
86 QWebPage* wrtPage() { return m_wrtPage; } |
88 QWebPage* wrtPage() { return m_wrtPage; } |
87 void showNormalPage(); |
89 void showNormalPage(); |
88 |
90 |
89 void createPagePixmap(); |
|
90 void setBitmapZoom(qreal zoom); |
91 void setBitmapZoom(qreal zoom); |
91 void deletePagePixmap(); |
|
92 void setPageCenterZoomFactor(qreal zoom); |
92 void setPageCenterZoomFactor(qreal zoom); |
93 |
93 |
94 void initializeViewportParams(); |
94 void initializeViewportParams(); |
95 void parseViewPortParam(const QString &propertyName, const QString &propertyValue); |
95 void parseViewPortParam(const QString &propertyName, const QString &propertyValue); |
96 bool isUserScalable(); |
96 bool isUserScalable(); |
97 qreal minimumScale(); |
97 qreal minimumScale(); |
98 qreal maximumScale(); |
98 qreal maximumScale(); |
99 qreal initialScale(); |
99 qreal initialScale(); |
100 void updateViewport(); |
100 void updateViewport(); |
101 void setBlockElement(QWebElement pt); |
101 void setBlockElement(const QWebElement &pt); |
102 QPointF mapToGlobal(const QPointF& p); |
102 QPointF mapToGlobal(const QPointF& p); |
103 QPointF mapFromGlobal(const QPointF& p); |
103 QPointF mapFromGlobal(const QPointF& p); |
104 |
104 |
105 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0) ; |
105 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0) ; |
106 void setPageZoomFactor(qreal zoom); |
106 void setPageZoomFactor(qreal zoom); |
107 |
107 |
108 ZoomMetaData pageZoomMetaData(); |
108 ZoomMetaData pageZoomMetaData(); |
109 void setPageZoomMetaData(ZoomMetaData params); |
109 void setPageZoomMetaData(ZoomMetaData params); |
110 ZoomMetaData defaultZoomData(); |
110 ZoomMetaData defaultZoomData(); |
111 void setCheckeredPixmap(); |
111 void setCheckeredPixmap(); |
|
112 |
|
113 void onLoadStarted(); |
|
114 void onLoadFinished(); |
|
115 |
|
116 /*! |
|
117 * \brief Freeze the on-screen state of the window. |
|
118 * Takes a snapshot of the window in its current state. The paint() method will then use |
|
119 * this snapshot for all further paints, until unfreeze() is called. Freeze() increments |
|
120 * a counter and unfreeze() decrements the counter so that nested calls to them are handled |
|
121 * correctly. |
|
122 * \sa unfreeze |
|
123 */ |
|
124 void freeze(); |
|
125 |
|
126 /*! |
|
127 * \brief Unfreeze the on-screen state of the window. |
|
128 * \sa freeze |
|
129 */ |
|
130 void unfreeze(); |
|
131 |
|
132 /*! |
|
133 * \brief Returns true if the window is currently frozen. |
|
134 * \sa freeze |
|
135 * \sa unfreeze |
|
136 */ |
|
137 bool frozen() const { return m_frozenCount > 0; } |
|
138 |
112 public slots: |
139 public slots: |
113 void setViewportSize(); |
140 void setViewportSize(); |
114 |
141 |
115 void onInitLayout(); |
142 void onInitLayout(); |
|
143 void onLongPressEvent(QPoint pos); |
116 |
144 |
117 signals: |
145 signals: |
118 void contextEvent(::WebViewEventContext *context); |
146 void contextEvent(::WebViewEventContext *context); |
119 void BlockFocusChanged(QPoint element); |
147 void BlockFocusChanged(QPoint element); |
120 |
148 |
121 void pageZoomMetaDataChange(QWebFrame* frame, ZoomMetaData data);protected: |
149 void pageZoomMetaDataChange(QWebFrame* frame, ZoomMetaData data);protected: |
122 void paintEvent(QPaintEvent *event); |
150 void paintEvent(QPaintEvent *event); |
|
151 void longPressEvent(::WebViewEventContext *context); |
123 |
152 |
124 virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); |
153 private slots: |
125 |
154 /*! |
126 public: |
155 * \brief Update the "frozen" image of this window. |
127 void onLoadStarted(); |
156 */ |
128 void onLoadFinished(); |
157 void updateFrozenImage(); |
129 |
158 |
130 private: |
159 private: |
131 void updateViewportSize(QGraphicsSceneResizeEvent *e); |
160 void updateViewportSize(QGraphicsSceneResizeEvent *e); |
|
161 virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); |
132 |
162 |
133 GVA::GWebContentView* m_webContentView; |
163 GVA::GWebContentView* m_webContentView; |
134 qreal m_dirtyZoomFactor; |
164 qreal m_dirtyZoomFactor; |
135 QPixmap *m_frozenPixmap; |
165 QPixmap *m_frozenPixmap; |
136 int m_freezeCount; |
166 int m_frozenCount; |
137 QWebPage *m_wrtPage; |
167 QWebPage *m_wrtPage; |
138 bool m_bitmapZoom; |
168 bool m_bitmapZoom; |
139 QPixmap *m_pagePixmap; |
|
140 qreal m_aspectRation; |
169 qreal m_aspectRation; |
141 qreal m_viewportWidth; |
170 qreal m_viewportWidth; |
142 qreal m_viewportHeight; |
171 qreal m_viewportHeight; |
143 bool m_userScalable; |
172 bool m_userScalable; |
144 qreal m_minimumScale; |
173 qreal m_minimumScale; |