summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2009-10-05 08:20:38 (GMT)
committerAlexis Menard <alexis.menard@nokia.com>2009-10-05 08:42:10 (GMT)
commit10dba674d366260589f3b742e5b1b87ce9ddd47c (patch)
treeded3feb9a219dba8f204d0015d2e44ef7114db20 /src
parentd1d661a1858e28befe5980c22009702f5ea82829 (diff)
downloadQt-10dba674d366260589f3b742e5b1b87ce9ddd47c.zip
Qt-10dba674d366260589f3b742e5b1b87ce9ddd47c.tar.gz
Qt-10dba674d366260589f3b742e5b1b87ce9ddd47c.tar.bz2
Make QEventTransition works with QGraphicsObject.
QStateMachine framework installs QObject event filters to catch events in order to triggers the proper transition. But installing a QObject event filter on a QGraphicsObject gives nothing because QGraphicsView events filters works differently. In order to make this works we now post events using QApplication::postEvent in addition to the QGraphicsView events. Reviewed-by:andreas
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qcoreevent.h1
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp12
-rw-r--r--src/gui/graphicsview/qgraphicswidget.cpp6
3 files changed, 11 insertions, 8 deletions
diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h
index a039d32..d66cead 100644
--- a/src/corelib/kernel/qcoreevent.h
+++ b/src/corelib/kernel/qcoreevent.h
@@ -324,7 +324,6 @@ private:
friend class QGraphicsView;
friend class QGraphicsViewPrivate;
friend class QGraphicsScenePrivate;
- friend class QGraphicsWidget;
};
class Q_CORE_EXPORT QTimerEvent : public QEvent
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 1226722..961f44f 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -254,6 +254,8 @@
QT_BEGIN_NAMESPACE
+bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event);
+
static void _q_hoverFromMouseEvent(QGraphicsSceneHoverEvent *hover, const QGraphicsSceneMouseEvent *mouseEvent)
{
hover->setWidget(mouseEvent->widget());
@@ -1051,7 +1053,15 @@ bool QGraphicsScenePrivate::sendEvent(QGraphicsItem *item, QEvent *event)
return false;
if (filterDescendantEvent(item, event))
return false;
- return (item && item->isEnabled() ? item->sceneEvent(event) : false);
+ if (!item || !item->isEnabled())
+ return false;
+ if (QGraphicsObject *o = item->toGraphicsObject()) {
+ bool spont = event->spontaneous();
+ if (spont ? qt_sendSpontaneousEvent(o, event) : QApplication::sendEvent(o, event))
+ return true;
+ event->spont = spont;
+ }
+ return item->sceneEvent(event);
}
/*!
diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp
index 224f50b..7764157 100644
--- a/src/gui/graphicsview/qgraphicswidget.cpp
+++ b/src/gui/graphicsview/qgraphicswidget.cpp
@@ -168,8 +168,6 @@ QT_BEGIN_NAMESPACE
\sa QGraphicsProxyWidget, QGraphicsItem, {Widgets and Layouts}
*/
-bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event);
-
/*!
Constructs a QGraphicsWidget instance. The optional \a parent argument is
passed to QGraphicsItem's constructor. The optional \a wFlags argument
@@ -1103,10 +1101,6 @@ QVariant QGraphicsWidget::propertyChange(const QString &propertyName, const QVar
*/
bool QGraphicsWidget::sceneEvent(QEvent *event)
{
- bool spont = event->spontaneous();
- if (spont ? qt_sendSpontaneousEvent(this, event) : QApplication::sendEvent(this, event))
- return true;
- event->spont = spont;
return QGraphicsItem::sceneEvent(event);
}