From f02e1d6d8e0ee560667b445e8fa43bde85e31f41 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 19 Apr 2012 21:16:47 +0200 Subject: Move QGestureEventPrivate's content to the main class QEvent now checks that the d pointer is unused. Change-Id: Ib0aa97d1692ea55324c4c6f133ffdd5a221f1680 Reviewed-by: Lars Knoll --- src/widgets/kernel/qapplication.cpp | 4 ++-- src/widgets/kernel/qgesture.cpp | 42 ++++++++++------------------------ src/widgets/kernel/qgesture.h | 6 +++-- src/widgets/kernel/qgesture_p.h | 13 ----------- src/widgets/kernel/qgesturemanager.cpp | 4 ++-- 5 files changed, 20 insertions(+), 49 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index ee4f9bd6bb..f672aef0eb 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3523,7 +3523,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) ge.t = gestureEvent->t; ge.spont = gestureEvent->spont; ge.m_accept = wasAccepted; - ge.d_func()->accepted = gestureEvent->d_func()->accepted; + ge.m_accepted = gestureEvent->m_accepted; res = d->notify_helper(w, &ge); gestureEvent->spont = false; eventAccepted = ge.isAccepted(); @@ -3533,7 +3533,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) // packed into a single QEvent depends on not consuming the event if (eventAccepted || ge.isAccepted(g)) { // if the gesture was accepted, mark the target widget for it - gestureEvent->d_func()->targetWidgets[g->gestureType()] = w; + gestureEvent->m_targetWidgets[g->gestureType()] = w; gestureEvent->setAccepted(g, true); } else { // if the gesture was explicitly ignored by the application, diff --git a/src/widgets/kernel/qgesture.cpp b/src/widgets/kernel/qgesture.cpp index 070af65c70..4f899e5644 100644 --- a/src/widgets/kernel/qgesture.cpp +++ b/src/widgets/kernel/qgesture.cpp @@ -846,9 +846,9 @@ int QTapAndHoldGesturePrivate::Timeout = 700; // in ms Creates new QGestureEvent containing a list of \a gestures. */ QGestureEvent::QGestureEvent(const QList &gestures) - : QEvent(QEvent::Gesture) + : QEvent(QEvent::Gesture), m_gestures(gestures), m_widget(0) + { - d = reinterpret_cast(new QGestureEventPrivate(gestures)); } /*! @@ -856,7 +856,6 @@ QGestureEvent::QGestureEvent(const QList &gestures) */ QGestureEvent::~QGestureEvent() { - delete reinterpret_cast(d); } /*! @@ -864,7 +863,7 @@ QGestureEvent::~QGestureEvent() */ QList QGestureEvent::gestures() const { - return d_func()->gestures; + return m_gestures; } /*! @@ -872,10 +871,9 @@ QList QGestureEvent::gestures() const */ QGesture *QGestureEvent::gesture(Qt::GestureType type) const { - const QGestureEventPrivate *d = d_func(); - for(int i = 0; i < d->gestures.size(); ++i) - if (d->gestures.at(i)->gestureType() == type) - return d->gestures.at(i); + for (int i = 0; i < m_gestures.size(); ++i) + if (m_gestures.at(i)->gestureType() == type) + return m_gestures.at(i); return 0; } @@ -885,7 +883,7 @@ QGesture *QGestureEvent::gesture(Qt::GestureType type) const QList QGestureEvent::activeGestures() const { QList gestures; - foreach (QGesture *gesture, d_func()->gestures) { + foreach (QGesture *gesture, m_gestures) { if (gesture->state() != Qt::GestureCanceled) gestures.append(gesture); } @@ -898,7 +896,7 @@ QList QGestureEvent::activeGestures() const QList QGestureEvent::canceledGestures() const { QList gestures; - foreach (QGesture *gesture, d_func()->gestures) { + foreach (QGesture *gesture, m_gestures) { if (gesture->state() == Qt::GestureCanceled) gestures.append(gesture); } @@ -980,7 +978,7 @@ bool QGestureEvent::isAccepted(QGesture *gesture) const void QGestureEvent::setAccepted(Qt::GestureType gestureType, bool value) { setAccepted(false); - d_func()->accepted[gestureType] = value; + m_accepted[gestureType] = value; } /*! @@ -1017,7 +1015,7 @@ void QGestureEvent::ignore(Qt::GestureType gestureType) */ bool QGestureEvent::isAccepted(Qt::GestureType gestureType) const { - return d_func()->accepted.value(gestureType, true); + return m_accepted.value(gestureType, true); } /*! @@ -1027,7 +1025,7 @@ bool QGestureEvent::isAccepted(Qt::GestureType gestureType) const */ void QGestureEvent::setWidget(QWidget *widget) { - d_func()->widget = widget; + m_widget = widget; } /*! @@ -1035,7 +1033,7 @@ void QGestureEvent::setWidget(QWidget *widget) */ QWidget *QGestureEvent::widget() const { - return d_func()->widget; + return m_widget; } #ifndef QT_NO_GRAPHICSVIEW @@ -1062,22 +1060,6 @@ QPointF QGestureEvent::mapToGraphicsScene(const QPointF &gesturePoint) const } #endif //QT_NO_GRAPHICSVIEW -/*! - \internal -*/ -QGestureEventPrivate *QGestureEvent::d_func() -{ - return reinterpret_cast(d); -} - -/*! - \internal -*/ -const QGestureEventPrivate *QGestureEvent::d_func() const -{ - return reinterpret_cast(d); -} - #ifdef Q_NO_USING_KEYWORD /*! \fn void QGestureEvent::setAccepted(bool accepted) diff --git a/src/widgets/kernel/qgesture.h b/src/widgets/kernel/qgesture.h index 5e121def41..ec5048089d 100644 --- a/src/widgets/kernel/qgesture.h +++ b/src/widgets/kernel/qgesture.h @@ -310,8 +310,10 @@ public: #endif private: - QGestureEventPrivate *d_func(); - const QGestureEventPrivate *d_func() const; + QList m_gestures; + QWidget *m_widget; + QMap m_accepted; + QMap m_targetWidgets; friend class QApplication; friend class QGestureManager; diff --git a/src/widgets/kernel/qgesture_p.h b/src/widgets/kernel/qgesture_p.h index ceccf17a6c..85793f6f7f 100644 --- a/src/widgets/kernel/qgesture_p.h +++ b/src/widgets/kernel/qgesture_p.h @@ -222,19 +222,6 @@ public: #endif }; -class QGestureEventPrivate -{ -public: - inline QGestureEventPrivate(const QList &list) - : gestures(list), widget(0) - { - } - - QList gestures; - QWidget *widget; - QMap accepted; - QMap targetWidgets; -}; #endif // QT_NO_GESTURES diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp index f4bf667ef8..8ba8904684 100644 --- a/src/widgets/kernel/qgesturemanager.cpp +++ b/src/widgets/kernel/qgesturemanager.cpp @@ -660,7 +660,7 @@ void QGestureManager::deliverEvents(const QSet &gestures, bool eventAccepted = event.isAccepted(); foreach(QGesture *gesture, event.gestures()) { if (eventAccepted || event.isAccepted(gesture)) { - QWidget *w = event.d_func()->targetWidgets.value(gesture->gestureType(), 0); + QWidget *w = event.m_targetWidgets.value(gesture->gestureType(), 0); Q_ASSERT(w); DEBUG() << "override event: gesture was accepted:" << gesture << w; QList &gestures = normalStartedGestures[w]; @@ -687,7 +687,7 @@ void QGestureManager::deliverEvents(const QSet &gestures, foreach (QGesture *gesture, event.gestures()) { if (gesture->state() == Qt::GestureStarted && (eventAccepted || event.isAccepted(gesture))) { - QWidget *w = event.d_func()->targetWidgets.value(gesture->gestureType(), 0); + QWidget *w = event.m_targetWidgets.value(gesture->gestureType(), 0); Q_ASSERT(w); DEBUG() << "started gesture was delivered and accepted by" << w; m_gestureTargets[gesture] = w; -- cgit v1.2.3