Gestures & events: compile with QT_STRICT_ITERATORS.
authorThiago Macieira <thiago.macieira@intel.com>
Thu, 24 May 2012 14:43:38 +0000 (16:43 +0200)
committerQt by Nokia <qt-info@nokia.com>
Fri, 25 May 2012 19:46:55 +0000 (21:46 +0200)
There are a few mixed up iterators that needed cleaning up. We're
missing a constUpperBound and constLowerBound function, though...

This commit sneaks in one change to qtextformat related to
QT_STRICT_ITERATORS but not to gestures and events.

Change-Id: I8c7c840fb5f46c790adbf52952c6009c5b5f2f43
Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
src/gui/text/qtextformat.cpp
src/widgets/graphicsview/qgraphicsscene.cpp
src/widgets/kernel/qgesturemanager.cpp

index 6d9eeab..9995110 100644 (file)
@@ -3296,8 +3296,8 @@ QTextFormatCollection::~QTextFormatCollection()
 int QTextFormatCollection::indexForFormat(const QTextFormat &format)
 {
     uint hash = getHash(format.d, format.format_type);
-    QMultiHash<uint, int>::const_iterator i = hashes.find(hash);
-    while (i != hashes.end() && i.key() == hash) {
+    QMultiHash<uint, int>::const_iterator i = hashes.constFind(hash);
+    while (i != hashes.constEnd() && i.key() == hash) {
         if (formats.value(i.value()) == format) {
             return i.value();
         }
index 282c6a2..21db5bd 100644 (file)
@@ -4193,8 +4193,8 @@ void QGraphicsScene::wheelEvent(QGraphicsSceneWheelEvent *wheelEvent)
     // Find the first popup under the mouse (including the popup's descendants) starting from the last.
     // Remove all popups after the one found, or all or them if no popup is under the mouse.
     // Then continue with the event.
-    QList<QGraphicsWidget *>::const_iterator iter = d->popupWidgets.end();
-    while (--iter >= d->popupWidgets.begin() && !wheelCandidates.isEmpty()) {
+    QList<QGraphicsWidget *>::const_iterator iter = d->popupWidgets.constEnd();
+    while (--iter >= d->popupWidgets.constBegin() && !wheelCandidates.isEmpty()) {
         if (wheelCandidates.first() == *iter || (*iter)->isAncestorOf(wheelCandidates.first()))
             break;
         d->removePopup(*iter);
@@ -6126,8 +6126,8 @@ void QGraphicsScenePrivate::gestureTargetsAtHotSpots(const QSet<QGesture *> &ges
             if (QGraphicsObject *itemobj = item->toGraphicsObject()) {
                 QGraphicsItemPrivate *d = item->QGraphicsItem::d_func();
                 QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator it =
-                        d->gestureContext.find(gestureType);
-                if (it != d->gestureContext.end() && (!flag || (it.value() & flag))) {
+                        d->gestureContext.constFind(gestureType);
+                if (it != d->gestureContext.constEnd() && (!flag || (it.value() & flag))) {
                     if (normalGestures.contains(gesture)) {
                         normalGestures.remove(gesture);
                         if (conflicts)
index 8ba8904..4d05e0d 100644 (file)
@@ -140,8 +140,8 @@ void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type)
         }
     }
 
-    QMap<ObjectGesture, QList<QGesture *> >::const_iterator iter = m_objectGestures.begin();
-    while (iter != m_objectGestures.end()) {
+    QMap<ObjectGesture, QList<QGesture *> >::const_iterator iter = m_objectGestures.constBegin();
+    while (iter != m_objectGestures.constEnd()) {
         ObjectGesture objectGesture = iter.key();
         if (objectGesture.gesture == type) {
             foreach (QGesture *g, iter.value()) {
@@ -248,9 +248,10 @@ bool QGestureManager::filterEventThroughContexts(const QMultiMap<QObject *,
     ContextIterator contextEnd = contexts.end();
     for (ContextIterator context = contexts.begin(); context != contextEnd; ++context) {
         Qt::GestureType gestureType = context.value();
+        const QMap<Qt::GestureType, QGestureRecognizer *> &const_recognizers = m_recognizers;
         QMap<Qt::GestureType, QGestureRecognizer *>::const_iterator
-                typeToRecognizerIterator = m_recognizers.lowerBound(gestureType),
-                typeToRecognizerEnd = m_recognizers.upperBound(gestureType);
+                typeToRecognizerIterator = const_recognizers.lowerBound(gestureType),
+                typeToRecognizerEnd = const_recognizers.upperBound(gestureType);
         for (; typeToRecognizerIterator != typeToRecognizerEnd; ++typeToRecognizerIterator) {
             QGestureRecognizer *recognizer = typeToRecognizerIterator.value();
             QObject *target = context.key();
@@ -468,8 +469,8 @@ bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event)
     QWidget *w = receiver;
     typedef QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator ContextIterator;
     if (!w->d_func()->gestureContext.isEmpty()) {
-        for(ContextIterator it = w->d_func()->gestureContext.begin(),
-            e = w->d_func()->gestureContext.end(); it != e; ++it) {
+        for(ContextIterator it = w->d_func()->gestureContext.constBegin(),
+            e = w->d_func()->gestureContext.constEnd(); it != e; ++it) {
             types.insert(it.key(), 0);
             contexts.insertMulti(w, it.key());
         }
@@ -478,8 +479,8 @@ bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event)
     w = w->isWindow() ? 0 : w->parentWidget();
     while (w)
     {
-        for (ContextIterator it = w->d_func()->gestureContext.begin(),
-             e = w->d_func()->gestureContext.end(); it != e; ++it) {
+        for (ContextIterator it = w->d_func()->gestureContext.constBegin(),
+             e = w->d_func()->gestureContext.constEnd(); it != e; ++it) {
             if (!(it.value() & Qt::DontStartGestureOnChildren)) {
                 if (!types.contains(it.key())) {
                     types.insert(it.key(), 0);
@@ -502,8 +503,8 @@ bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event)
     QGraphicsObject *item = receiver;
     if (!item->QGraphicsItem::d_func()->gestureContext.isEmpty()) {
         typedef QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator ContextIterator;
-        for(ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.begin(),
-            e = item->QGraphicsItem::d_func()->gestureContext.end(); it != e; ++it) {
+        for(ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.constBegin(),
+            e = item->QGraphicsItem::d_func()->gestureContext.constEnd(); it != e; ++it) {
             types.insert(it.key(), 0);
             contexts.insertMulti(item, it.key());
         }
@@ -513,8 +514,8 @@ bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event)
     while (item)
     {
         typedef QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator ContextIterator;
-        for (ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.begin(),
-             e = item->QGraphicsItem::d_func()->gestureContext.end(); it != e; ++it) {
+        for (ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.constBegin(),
+             e = item->QGraphicsItem::d_func()->gestureContext.constEnd(); it != e; ++it) {
             if (!(it.value() & Qt::DontStartGestureOnChildren)) {
                 if (!types.contains(it.key())) {
                     types.insert(it.key(), 0);
@@ -559,8 +560,8 @@ void QGestureManager::getGestureTargets(const QSet<QGesture*> &gestures,
             QWidget *w = widget->parentWidget();
             while (w) {
                 QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator it
-                        = w->d_func()->gestureContext.find(type);
-                if (it != w->d_func()->gestureContext.end()) {
+                        = w->d_func()->gestureContext.constFind(type);
+                if (it != w->d_func()->gestureContext.constEnd()) {
                     // i.e. 'w' listens to gesture 'type'
                     if (!(it.value() & Qt::DontStartGestureOnChildren) && w != widget) {
                         // conflicting gesture!
@@ -642,8 +643,8 @@ void QGestureManager::deliverEvents(const QSet<QGesture *> &gestures,
             << "\n";
 
     // if there are conflicting gestures, send the GestureOverride event
-    for (GesturesPerWidget::const_iterator it = conflictedGestures.begin(),
-        e = conflictedGestures.end(); it != e; ++it) {
+    for (GesturesPerWidget::const_iterator it = conflictedGestures.constBegin(),
+        e = conflictedGestures.constEnd(); it != e; ++it) {
         QWidget *receiver = it.key();
         QList<QGesture *> gestures = it.value();
         DEBUG() << "QGestureManager::deliverEvents: sending GestureOverride to"
@@ -676,8 +677,8 @@ void QGestureManager::deliverEvents(const QSet<QGesture *> &gestures,
     }
 
     // delivering gestures that are not in conflicted state
-    for (GesturesPerWidget::const_iterator it = normalStartedGestures.begin(),
-        e = normalStartedGestures.end(); it != e; ++it) {
+    for (GesturesPerWidget::const_iterator it = normalStartedGestures.constBegin(),
+        e = normalStartedGestures.constEnd(); it != e; ++it) {
         if (!it.value().isEmpty()) {
             DEBUG() << "QGestureManager::deliverEvents: sending to" << it.key()
                     << "gestures:" << it.value();