diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-10-28 13:30:11 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-10-28 13:47:20 (GMT) |
commit | 4b3ef85b499d9ec508acdf83d250e022161defbb (patch) | |
tree | 1bf5385b0be93272070ff3cff636984406b17b10 /src/gui | |
parent | 6efb1b7df725c74f265d0f315993542b0bd19b97 (diff) | |
download | Qt-4b3ef85b499d9ec508acdf83d250e022161defbb.zip Qt-4b3ef85b499d9ec508acdf83d250e022161defbb.tar.gz Qt-4b3ef85b499d9ec508acdf83d250e022161defbb.tar.bz2 |
Replaced QMap with QHash where possible in the gesture manager implementation.
There is no reason to use QMap when the key is a pointer.
Reviewed-by: Thomas Zander
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qgesturemanager.cpp | 18 | ||||
-rw-r--r-- | src/gui/kernel/qgesturemanager_p.h | 8 |
2 files changed, 13 insertions, 13 deletions
diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 3eb15cf..f1abc89 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -113,7 +113,7 @@ void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) { QList<QGestureRecognizer *> list = m_recognizers.values(type); m_recognizers.remove(type); - foreach (QGesture* g, m_gestureToRecognizer.keys()) { + foreach (QGesture *g, m_gestureToRecognizer.keys()) { QGestureRecognizer *recognizer = m_gestureToRecognizer.value(g); if (list.contains(recognizer)) { m_deletedRecognizers.insert(g, recognizer); @@ -191,7 +191,7 @@ QGesture *QGestureManager::getState(QObject *object, QGestureRecognizer *recogni return state; } -bool QGestureManager::filterEventThroughContexts(const QMap<QObject *, +bool QGestureManager::filterEventThroughContexts(const QMultiHash<QObject *, Qt::GestureType> &contexts, QEvent *event) { @@ -207,7 +207,7 @@ bool QGestureManager::filterEventThroughContexts(const QMap<QObject *, bool ret = false; // filter the event through recognizers - typedef QMap<QObject *, Qt::GestureType>::const_iterator ContextIterator; + typedef QHash<QObject *, Qt::GestureType>::const_iterator ContextIterator; for (ContextIterator cit = contexts.begin(), ce = contexts.end(); cit != ce; ++cit) { Qt::GestureType gestureType = cit.value(); QMap<Qt::GestureType, QGestureRecognizer *>::const_iterator @@ -269,7 +269,7 @@ bool QGestureManager::filterEventThroughContexts(const QMap<QObject *, | finishedGestures | canceledGestures | notGestures); foreach(QGesture *gesture, notMaybeGestures) { - QMap<QGesture *, QBasicTimer>::iterator it = + QHash<QGesture *, QBasicTimer>::iterator it = m_maybeGestures.find(gesture); if (it != m_maybeGestures.end()) { it.value().stop(); @@ -437,7 +437,7 @@ void QGestureManager::cleanupGesturesForRemovedRecognizer(QGesture *gesture) bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) { QSet<Qt::GestureType> types; - QMap<QObject *, Qt::GestureType> contexts; + QMultiHash<QObject *, Qt::GestureType> contexts; QWidget *w = receiver; typedef QMap<Qt::GestureType, Qt::GestureContext>::const_iterator ContextIterator; if (!w->d_func()->gestureContext.isEmpty()) { @@ -470,7 +470,7 @@ bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event) { QSet<Qt::GestureType> types; - QMap<QObject *, Qt::GestureType> contexts; + QMultiHash<QObject *, Qt::GestureType> contexts; QGraphicsObject *item = receiver; if (!item->QGraphicsItem::d_func()->gestureContext.isEmpty()) { typedef QMap<Qt::GestureType, Qt::GestureContext>::const_iterator ContextIterator; @@ -501,7 +501,7 @@ bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event) bool QGestureManager::filterEvent(QGesture *state, QEvent *event) { - QMap<QObject *, Qt::GestureType> contexts; + QMultiHash<QObject *, Qt::GestureType> contexts; contexts.insert(state, state->gestureType()); return filterEventThroughContexts(contexts, event); } @@ -656,8 +656,8 @@ void QGestureManager::deliverEvents(const QSet<QGesture *> &gestures, void QGestureManager::timerEvent(QTimerEvent *event) { - QMap<QGesture*, QBasicTimer>::iterator it = m_maybeGestures.begin(), - e = m_maybeGestures.end(); + QHash<QGesture *, QBasicTimer>::iterator it = m_maybeGestures.begin(), + e = m_maybeGestures.end(); for (; it != e; ) { QBasicTimer &timer = it.value(); Q_ASSERT(timer.isActive()); diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index f128273..4958cdb 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -83,14 +83,14 @@ public: protected: void timerEvent(QTimerEvent *event); - bool filterEventThroughContexts(const QMap<QObject *, Qt::GestureType> &contexts, + bool filterEventThroughContexts(const QMultiHash<QObject *, Qt::GestureType> &contexts, QEvent *event); private: QMultiMap<Qt::GestureType, QGestureRecognizer *> m_recognizers; QSet<QGesture *> m_activeGestures; - QMap<QGesture *, QBasicTimer> m_maybeGestures; + QHash<QGesture *, QBasicTimer> m_maybeGestures; enum State { Gesture, @@ -117,7 +117,7 @@ private: }; QMap<ObjectGesture, QList<QGesture *> > m_objectGestures; - QMap<QGesture *, QGestureRecognizer *> m_gestureToRecognizer; + QHash<QGesture *, QGestureRecognizer *> m_gestureToRecognizer; QHash<QGesture *, QObject *> m_gestureOwners; QHash<QGesture *, QWidget *> m_gestureTargets; @@ -125,7 +125,7 @@ private: int m_lastCustomGestureId; QHash<QGestureRecognizer *, QList<QGesture *> > m_obsoleteGestures; - QMap<QGesture *, QGestureRecognizer *> m_deletedRecognizers; + QHash<QGesture *, QGestureRecognizer *> m_deletedRecognizers; void cleanupGesturesForRemovedRecognizer(QGesture *gesture); QGesture *getState(QObject *widget, QGestureRecognizer *recognizer, |