--- a/ginebra2/PopupWebChromeItem.cpp Wed Jun 23 17:59:43 2010 +0300
+++ b/ginebra2/PopupWebChromeItem.cpp Tue Jul 06 14:03:49 2010 +0300
@@ -22,50 +22,48 @@
#include "PopupWebChromeItem.h"
#include "ChromeWidget.h"
#include "WebChromeSnippet.h"
+#include "ExternalEventCharm.h"
namespace GVA {
PopupWebChromeItem::PopupWebChromeItem(
- const QRectF & ownerArea,
ChromeWidget * chrome,
const QWebElement & element,
QGraphicsItem * parent,
bool modal)
-: WebChromeItem(ownerArea, chrome, element, parent),
- m_modal(modal)
+: WebChromeItem(chrome, element, parent),
+ m_modal(modal),
+ m_externalEventCharm(0)
{
}
PopupWebChromeItem::~PopupWebChromeItem()
-{}
+{
+ delete m_externalEventCharm;
+}
void PopupWebChromeItem::init(WebChromeSnippet * snippet)
{
WebChromeItem::init(snippet);
+ m_externalEventCharm = new ExternalEventCharm(this);
// Forward externalMouseEvent signals from context items.
QObject::connect(
- this,
- SIGNAL(externalMouseEvent(int, const QString &, const QString &)),
+ m_externalEventCharm,
+ SIGNAL(externalMouseEvent(QEvent *, const QString &, const QString &)),
snippet,
- SIGNAL(externalMouseEvent(int, const QString &, const QString &)));
+ SIGNAL(externalMouseEvent(QEvent *, const QString &, const QString &)));
}
bool PopupWebChromeItem::event(QEvent * e)
{
- // Check for external events grabbed by this item.
-
- checkForExternalEvent(this, e);
-
switch (e->type()) {
case QEvent::Show:
- scene()->installEventFilter(this);
if(snippet() && m_modal) {
chrome()->emitPopupShown(snippet()->objectName());
}
break;
case QEvent::Hide:
- scene()->removeEventFilter(this);
if(snippet() && m_modal) {
chrome()->emitPopupHidden(snippet()->objectName());
}
@@ -78,78 +76,4 @@
return WebChromeItem::event(e);
}
-bool PopupWebChromeItem::eventFilter(QObject * o, QEvent * e)
-{
- // Check for external events NOT grabbed by this item.
-
- checkForExternalEvent(o, e);
-
- // Don't filter any events.
-
- return false;
-}
-
-void PopupWebChromeItem::checkForExternalEvent(QObject * o, QEvent * e)
-{
- Q_UNUSED(o);
-
- // Ignore all events when this item is not showing.
-
- if (!isVisible()) {
- return;
- }
-
- // Ignore all but a few mouse press events.
-
- switch (e->type()) {
- case QEvent::GraphicsSceneMousePress:
- case QEvent::GraphicsSceneMouseRelease:
- case QEvent::GraphicsSceneMouseDoubleClick:
-// Commented out because new context menu resizes itself, don't want externalMouseEvents
-// in that case.
-// case QEvent::GraphicsSceneResize:
- break;
- default:
- return;
- }
-
- // Check where the mouse press event occurred.
- // If it was outside this item's bounding rectangle,
- // then tell the world.
-
-// Commented out because new context menu resizes itself, don't want externalMouseEvents
-// in that case.
-// if (e->type() == QEvent::GraphicsSceneResize)
-// {
-// QGraphicsSceneResizeEvent *resizeEvent = static_cast<QGraphicsSceneResizeEvent *>(e);
-// qDebug() << "PopupWebChromeItem::checkForExternalEvent: " << resizeEvent->newSize() << resizeEvent->oldSize();
-// if (resizeEvent->newSize() != resizeEvent->oldSize())
-// emitExternalEvent(e);
-// return;
-// }
-
- QGraphicsSceneMouseEvent * me = static_cast<QGraphicsSceneMouseEvent*>(e);
-
- QPointF eventPosition = me->scenePos();
-
- QRectF itemGeometry = sceneBoundingRect();
-
- if (!itemGeometry.contains(eventPosition)) {
- emitExternalEvent(e);
- }
-}
-
-void PopupWebChromeItem::emitExternalEvent(QEvent * e)
-{
- QString description;
-
- QDebug stream(&description);
- stream << e;
-
- QString name = description;
- name.truncate(name.indexOf('('));
-
- emit externalMouseEvent(e->type(), name, description.trimmed());
-}
-
} // end of namespace GVA