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 |
|
18 |
21 |
19 #include "PopupWebChromeItem.h" |
22 #include "PopupWebChromeItem.h" |
20 #include "ChromeWidget.h" |
23 #include "ChromeWidget.h" |
21 #include "WebChromeSnippet.h" |
24 #include "WebChromeSnippet.h" |
22 |
25 |
24 |
27 |
25 PopupWebChromeItem::PopupWebChromeItem( |
28 PopupWebChromeItem::PopupWebChromeItem( |
26 const QRectF & ownerArea, |
29 const QRectF & ownerArea, |
27 ChromeWidget * chrome, |
30 ChromeWidget * chrome, |
28 const QWebElement & element, |
31 const QWebElement & element, |
29 QGraphicsItem * parent) |
32 QGraphicsItem * parent, |
30 : WebChromeItem(ownerArea, chrome, element, parent) |
33 bool modal) |
|
34 : WebChromeItem(ownerArea, chrome, element, parent), |
|
35 m_modal(modal) |
31 { |
36 { |
32 } |
37 } |
33 |
38 |
34 PopupWebChromeItem::~PopupWebChromeItem() |
39 PopupWebChromeItem::~PopupWebChromeItem() |
35 {} |
40 {} |
50 { |
55 { |
51 // Check for external events grabbed by this item. |
56 // Check for external events grabbed by this item. |
52 |
57 |
53 checkForExternalEvent(this, e); |
58 checkForExternalEvent(this, e); |
54 |
59 |
55 switch(e->type()) { |
60 switch (e->type()) { |
56 case QEvent::Show: |
61 case QEvent::Show: |
57 scene()->installEventFilter(this); |
62 scene()->installEventFilter(this); |
|
63 if(snippet() && m_modal) { |
|
64 chrome()->emitPopupShown(snippet()->objectName()); |
|
65 } |
58 break; |
66 break; |
59 case QEvent::Hide: |
67 case QEvent::Hide: |
60 scene()->removeEventFilter(this); |
68 scene()->removeEventFilter(this); |
|
69 if(snippet() && m_modal) { |
|
70 chrome()->emitPopupHidden(snippet()->objectName()); |
|
71 } |
61 break; |
72 break; |
62 default: break; |
73 default: break; |
63 } |
74 } |
64 |
75 |
65 // Let the parent class handle the event. |
76 // Let the parent class handle the event. |
92 |
103 |
93 switch (e->type()) { |
104 switch (e->type()) { |
94 case QEvent::GraphicsSceneMousePress: |
105 case QEvent::GraphicsSceneMousePress: |
95 case QEvent::GraphicsSceneMouseRelease: |
106 case QEvent::GraphicsSceneMouseRelease: |
96 case QEvent::GraphicsSceneMouseDoubleClick: |
107 case QEvent::GraphicsSceneMouseDoubleClick: |
97 case QEvent::GraphicsSceneResize: |
108 // Commented out because new context menu resizes itself, don't want externalMouseEvents |
|
109 // in that case. |
|
110 // case QEvent::GraphicsSceneResize: |
98 break; |
111 break; |
99 default: |
112 default: |
100 return; |
113 return; |
101 } |
114 } |
102 |
115 |
103 // Check where the mouse press event occurred. |
116 // Check where the mouse press event occurred. |
104 // If it was outside this item's bounding rectangle, |
117 // If it was outside this item's bounding rectangle, |
105 // then tell the world. |
118 // then tell the world. |
106 |
119 |
107 if(e->type() == QEvent::GraphicsSceneResize) |
120 // Commented out because new context menu resizes itself, don't want externalMouseEvents |
108 { |
121 // in that case. |
109 emitExternalEvent(e); |
122 // if (e->type() == QEvent::GraphicsSceneResize) |
110 return; |
123 // { |
111 } |
124 // QGraphicsSceneResizeEvent *resizeEvent = static_cast<QGraphicsSceneResizeEvent *>(e); |
112 |
125 // qDebug() << "PopupWebChromeItem::checkForExternalEvent: " << resizeEvent->newSize() << resizeEvent->oldSize(); |
|
126 // if (resizeEvent->newSize() != resizeEvent->oldSize()) |
|
127 // emitExternalEvent(e); |
|
128 // return; |
|
129 // } |
|
130 |
113 QGraphicsSceneMouseEvent * me = static_cast<QGraphicsSceneMouseEvent*>(e); |
131 QGraphicsSceneMouseEvent * me = static_cast<QGraphicsSceneMouseEvent*>(e); |
114 |
132 |
115 QPointF eventPosition = me->scenePos(); |
133 QPointF eventPosition = me->scenePos(); |
116 |
134 |
117 QRectF itemGeometry = sceneBoundingRect(); |
135 QRectF itemGeometry = sceneBoundingRect(); |