diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-04-22 11:03:53 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-05-11 14:51:53 (GMT) |
commit | ec94be7f23bfd9c13e42b9b20f01af69bae83660 (patch) | |
tree | 41e380722df80d2de30417ffee804ab79f6ab78d /src/gui/kernel/qwidget.cpp | |
parent | 7bda9fff3b48d2534fb70cc6a9c4b0b945eaaf12 (diff) | |
download | Qt-ec94be7f23bfd9c13e42b9b20f01af69bae83660.zip Qt-ec94be7f23bfd9c13e42b9b20f01af69bae83660.tar.gz Qt-ec94be7f23bfd9c13e42b9b20f01af69bae83660.tar.bz2 |
Removed all weird qHash usage for gesture identification.
Diffstat (limited to 'src/gui/kernel/qwidget.cpp')
-rw-r--r-- | src/gui/kernel/qwidget.cpp | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 0029809..22c2ea7 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -109,6 +109,7 @@ #include "private/qabstractscrollarea_p.h" #include "private/qgraphicssystem_p.h" +#include "private/qgesturemanager_p.h" // widget/widget data creation count //#define QWIDGET_EXTRA_DEBUG @@ -11032,17 +11033,27 @@ QWindowSurface *QWidget::windowSurface() const int QWidget::grabGesture(const QString &gesture) { Q_D(QWidget); - return d->grabGesture(qHash(gesture)); + return d->grabGesture(QGestureManager::instance()->makeGestureId(gesture)); } -int QWidgetPrivate::grabGesture(int id) +int QWidgetPrivate::grabGesture(int gestureId) { - QSet<int>::iterator it = gestures.find(id); - if (it != gestures.end()) - return *it; - gestures << id; - ++qApp->d_func()->grabbedGestures[id]; - return id; + gestures << gestureId; + ++qApp->d_func()->grabbedGestures[QGestureManager::instance()->gestureNameFromId(gestureId)]; + return gestureId; +} + +bool QWidgetPrivate::releaseGesture(int gestureId) +{ + QApplicationPrivate *qAppPriv = qApp->d_func(); + if (gestures.contains(gestureId)) { + QString name = QGestureManager::instance()->gestureNameFromId(gestureId); + Q_ASSERT(qAppPriv->grabbedGestures[name] > 0); + --qAppPriv->grabbedGestures[name]; + gestures.remove(gestureId); + return true; + } + return false; } /*! @@ -11066,12 +11077,8 @@ int QWidget::grabGesture(Qt::GestureType gesture) void QWidget::releaseGesture(int gestureId) { Q_D(QWidget); - QSet<int>::iterator it = d->gestures.find(gestureId); - if (it != d->gestures.end()) { - Q_ASSERT(qApp->d_func()->grabbedGestures[gestureId] > 0); - --qApp->d_func()->grabbedGestures[gestureId]; - d->gestures.erase(it); - } + if (d->releaseGesture(gestureId)) + QGestureManager::instance()->releaseGestureId(gestureId); } /*! |