Remove friends of QEvent.

Introduce function to set the spontaneous flag to
QCoreApplicationPrivate to solve a few cases.

Change-Id: I7c1f1f3644defe00deea9cecb244ca258afd5b94
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Friedemann Kleint 2014-05-15 15:01:21 +02:00 committed by The Qt Project
parent bf3e80023a
commit 6c5645578a
4 changed files with 3 additions and 8 deletions

View File

@ -96,6 +96,7 @@ public:
bool sendThroughApplicationEventFilters(QObject *, QEvent *);
bool sendThroughObjectEventFilters(QObject *, QEvent *);
bool notify_helper(QObject *, QEvent *);
static inline void setEventSpontaneous(QEvent *e, bool spontaneous) { e->spont = spontaneous; }
virtual void createEventDispatcher();
virtual void eventDispatcherReady();

View File

@ -318,16 +318,10 @@ private:
friend class QCoreApplicationPrivate;
friend class QThreadData;
friend class QApplication;
friend class QApplicationPrivate;
friend class QShortcutMap;
friend class QGraphicsView;
friend class QGraphicsViewPrivate;
friend class QGraphicsScene;
friend class QGraphicsScenePrivate;
friend class QWidgetWindow;
#ifndef QT_NO_GESTURES
friend class QGestureManager;
#endif
};
class Q_CORE_EXPORT QTimerEvent : public QEvent

View File

@ -3505,7 +3505,7 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
// deliver the event
bool consumed = receiver->event(e);
e->spont = false;
QCoreApplicationPrivate::setEventSpontaneous(e, false);
return consumed;
}

View File

@ -443,7 +443,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
// Use postEvent() to ensure the local QEventLoop terminates when called from QMenu::exec()
const QPoint localPos = win->mapFromGlobal(event->globalPos());
QMouseEvent *e = new QMouseEvent(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(), event->button(), event->buttons(), event->modifiers());
e->spont = 1;
QCoreApplicationPrivate::setEventSpontaneous(e, true);
QGuiApplicationPrivate::setMouseEventSource(e, QGuiApplicationPrivate::mouseEventSource(event));
e->setTimestamp(event->timestamp());
QCoreApplication::postEvent(win, e);