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/". |
|
17 * |
|
18 * Description: |
15 * |
19 * |
16 */ |
20 */ |
17 |
21 |
18 |
22 |
19 #ifndef __GINEBRA_WEBCHROMEITEM_H__ |
23 #ifndef __GINEBRA_WEBCHROMEITEM_H__ |
20 #define __GINEBRA_WEBCHROMEITEM_H__ |
24 #define __GINEBRA_WEBCHROMEITEM_H__ |
21 |
25 |
22 #include <QtGui> |
26 #include <QtGui> |
23 #include <QWebElement> |
27 #include <QWebElement> |
24 #include "CachedHandler.h" |
28 #include "CachedHandler.h" |
|
29 #include "ChromeItem.h" |
25 |
30 |
26 namespace GVA { |
31 namespace GVA { |
27 |
32 |
28 class ChromeWidget; |
33 class ChromeWidget; |
29 class ChromeRenderer; |
34 class ChromeRenderer; |
30 class WebChromeSnippet; |
35 class WebChromeSnippet; |
31 |
36 |
32 class WebChromeItem : public QGraphicsWidget |
37 class WebChromeItem : public ChromeItem |
33 { |
38 { |
34 Q_OBJECT |
39 Q_OBJECT |
35 public: |
40 public: |
36 WebChromeItem(const QRectF& ownerArea, ChromeWidget* chrome, const QWebElement & element, QGraphicsItem* parent=0); |
41 WebChromeItem(ChromeWidget* chrome, const QWebElement & element, QGraphicsItem* parent=0); |
37 virtual ~WebChromeItem(); |
42 virtual ~WebChromeItem(); |
38 virtual void init(WebChromeSnippet * snippet); |
43 virtual void init(WebChromeSnippet * snippet); |
39 void paint(QPainter* painter, const QStyleOptionGraphicsItem* opt, QWidget* widget); |
44 void paint(QPainter* painter, const QStyleOptionGraphicsItem* opt, QWidget* widget); |
40 QRectF ownerArea() {return m_ownerArea;}\ |
45 QRectF elementRect() {return QRectF(m_element.geometry());} |
41 void setOwnerArea(const QRectF& ownerArea); |
46 void updateSizes(); |
42 void setCachedHandlers(QList<CachedHandler> handlers) {m_handlers = handlers;} |
47 void setCachedHandlers(QList<CachedHandler> handlers) {m_handlers = handlers;} |
43 QGraphicsScene * scene(); |
48 QGraphicsScene * scene(); |
44 ChromeRenderer * renderer(); |
49 ChromeRenderer * renderer(); |
45 void grabFocus(); |
50 void grabFocus(); |
46 bool event(QEvent* event); |
51 bool event(QEvent* event); |
47 ChromeWidget * chrome() { return m_chrome; } |
52 ChromeWidget * chrome() { return m_chrome; } |
48 QWebElement element() { return m_element; } |
53 QWebElement element() { return m_element; } |
49 inline bool isPainting() { return m_painting; } |
54 inline bool isPainting() { return m_painting; } |
50 public slots: |
55 public slots: |
51 void repaintFromChrome(const QRectF& rect = QRectF()); |
|
52 //inline void setCacheMode(bool mode) {m_cacheMode = mode;}; |
56 //inline void setCacheMode(bool mode) {m_cacheMode = mode;}; |
53 signals: |
57 signals: |
54 void contextMenu(QGraphicsSceneContextMenuEvent * ev); |
58 void contextMenu(QGraphicsSceneContextMenuEvent * ev); |
55 void mouseEvent(QEvent::Type type); |
|
56 protected: |
59 protected: |
57 void contextMenuEvent(QGraphicsSceneContextMenuEvent * ev); |
60 void contextMenuEvent(QGraphicsSceneContextMenuEvent * ev); |
58 void mousePressEvent(QGraphicsSceneMouseEvent * ev); |
61 void mousePressEvent(QGraphicsSceneMouseEvent * ev); |
59 void mouseReleaseEvent(QGraphicsSceneMouseEvent * ev); |
62 void mouseReleaseEvent(QGraphicsSceneMouseEvent * ev); |
60 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *ev); |
63 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *ev); |
65 void forwardMouseEvent(QEvent::Type type, QGraphicsSceneMouseEvent *ev); |
68 void forwardMouseEvent(QEvent::Type type, QGraphicsSceneMouseEvent *ev); |
66 |
69 |
67 //virtual bool event(QEvent * ev); |
70 //virtual bool event(QEvent * ev); |
68 private: |
71 private: |
69 void cachedHandlerEvent(QGraphicsSceneMouseEvent * ev); |
72 void cachedHandlerEvent(QGraphicsSceneMouseEvent * ev); |
70 QRectF m_ownerArea; |
73 //Owner area obsolete, use element rectangle |
|
74 //QRectF m_ownerArea; |
71 QPixmap * m_pageBits; |
75 QPixmap * m_pageBits; |
72 ChromeWidget* m_chrome; |
76 ChromeWidget* m_chrome; |
73 QWebElement m_element; |
77 QWebElement m_element; |
74 //ChromeRenderer * m_renderer; |
78 //ChromeRenderer * m_renderer; |
75 QList<CachedHandler> m_handlers; |
79 QList<CachedHandler> m_handlers; |