summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qdeclarativegesturearea.cpp41
1 files changed, 23 insertions, 18 deletions
diff --git a/qdeclarativegesturearea.cpp b/qdeclarativegesturearea.cpp
index 298b0e7..29c7b1f 100644
--- a/qdeclarativegesturearea.cpp
+++ b/qdeclarativegesturearea.cpp
@@ -69,14 +69,12 @@ public:
QDeclarativeGestureArea *q_ptr;
- typedef QMap<Qt::GestureType, QObject *> Handlers;
- Handlers handlers;
+ QList<QObject *> handlers;
QObject *defaultHandler;
static void handlers_append(QDeclarativeListProperty<QObject> *prop, QObject *handler) {
QDeclarativeGestureAreaPrivate *d = static_cast<QDeclarativeGestureAreaPrivate *>(prop->data);
QDeclarativeGestureArea *q = d->q_ptr;
- handler->setParent(q);
int type = handler->property("gestureType").toInt();
// check that all needed properties exist
if (!handler->property("gestureType").isValid() || !handler->property("gesture").isValid()
@@ -88,11 +86,15 @@ public:
return;
}
Qt::GestureType gestureType = Qt::GestureType(type);
- if (d->handlers.contains(gestureType)) {
- qmlInfo(handler) << "Duplicate gesture found, ignoring.";
- return;
+ // see if there is already a handler for that gesture type
+ foreach(QObject *handler, d->handlers) {
+ Qt::GestureType type(Qt::GestureType(handler->property("gestureType").toInt()));
+ if (type == gestureType) {
+ qmlInfo(handler) << "Duplicate gesture found, ignoring.";
+ return;
+ }
}
- d->handlers.insert(gestureType, handler);
+ d->handlers.append(handler);
if (GestureAreaQmlPlugin::self)
GestureAreaQmlPlugin::self->allGestures << gestureType;
if (type == 0 && GestureAreaQmlPlugin::self) {
@@ -118,7 +120,7 @@ public:
}
static QObject *handlers_at(QDeclarativeListProperty<QObject> *prop, int index) {
QDeclarativeGestureAreaPrivate *d = static_cast<QDeclarativeGestureAreaPrivate *>(prop->data);
- return d->handlers.value(d->handlers.keys().at(index));
+ return d->handlers.at(index);
}
void evaluate(QGestureEvent *event, QGesture *gesture, QObject *handler);
@@ -259,26 +261,29 @@ void QDeclarativeGestureAreaPrivate::evaluate(QGestureEvent *event, QGesture *ge
bool QDeclarativeGestureAreaPrivate::gestureEvent(QGestureEvent *event)
{
- event->accept();
- foreach(Qt::GestureType type, handlers.keys())
- event->ignore(type);
-
if (handlers.isEmpty())
return false;
+ event->accept();
+
+ QList<Qt::GestureType> handlersTypes;
+ foreach(QObject *handler, handlers) {
+ Qt::GestureType type(Qt::GestureType(handler->property("gestureType").toInt()));
+ handlersTypes.append(type);
+ event->ignore(type);
+ }
+
QSet<Qt::GestureType> handledGestures;
- Handlers::Iterator it = handlers.end();
- do {
- --it;
- Qt::GestureType gestureType = it.key();
+ for (int i = handlers.size()-1; i >= 0; --i) {
+ Qt::GestureType gestureType = handlersTypes.at(i);
if (!gestureType)
continue;
if (QGesture *gesture = event->gesture(gestureType)) {
handledGestures << gestureType;
- QObject *handler = it.value();
+ QObject *handler = handlers.at(i);
evaluate(event, gesture, handler);
}
- } while (it != handlers.begin());
+ }
if (defaultHandler) {
// filter all gestures through the default handler