| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/kernel/qgesturemanager.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | - | |||||||||||||
| 6 | const QLoggingCategory &lcGestureManager() { static const QLoggingCategory category("qt.widgets.gestures"); return never executed: category;return category;never executed: }return category; | 0 | ||||||||||||
| 7 | - | |||||||||||||
| 8 | - | |||||||||||||
| 9 | static inline int panTouchPoints() | - | ||||||||||||
| 10 | { | - | ||||||||||||
| 11 | - | |||||||||||||
| 12 | static const char panTouchPointVariable[] = "QT_PAN_TOUCHPOINTS"; | - | ||||||||||||
| 13 | if (qEnvironmentVariableIsSet(panTouchPointVariable)
| 0 | ||||||||||||
| 14 | bool ok; | - | ||||||||||||
| 15 | const int result = qEnvironmentVariableIntValue(panTouchPointVariable, &ok); | - | ||||||||||||
| 16 | if (ok
| 0 | ||||||||||||
| 17 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||
| 18 | QMessageLogger(__FILE__, 72, __PRETTY_FUNCTION__).warning() << "Ignoring invalid value of " << panTouchPointVariable; | - | ||||||||||||
| 19 | } never executed: end of block | 0 | ||||||||||||
| 20 | - | |||||||||||||
| 21 | - | |||||||||||||
| 22 | - | |||||||||||||
| 23 | - | |||||||||||||
| 24 | return never executed: 2;return 2;never executed: return 2; | 0 | ||||||||||||
| 25 | } | - | ||||||||||||
| 26 | - | |||||||||||||
| 27 | - | |||||||||||||
| 28 | QGestureManager::QGestureManager(QObject *parent) | - | ||||||||||||
| 29 | : QObject(parent), state(NotGesture), m_lastCustomGestureId(Qt::CustomGesture) | - | ||||||||||||
| 30 | { | - | ||||||||||||
| 31 | qRegisterMetaType<Qt::GestureState>(); | - | ||||||||||||
| 32 | - | |||||||||||||
| 33 | - | |||||||||||||
| 34 | - | |||||||||||||
| 35 | - | |||||||||||||
| 36 | - | |||||||||||||
| 37 | - | |||||||||||||
| 38 | registerGestureRecognizer(new QPanGestureRecognizer(panTouchPoints())); | - | ||||||||||||
| 39 | registerGestureRecognizer(new QPinchGestureRecognizer); | - | ||||||||||||
| 40 | registerGestureRecognizer(new QSwipeGestureRecognizer); | - | ||||||||||||
| 41 | registerGestureRecognizer(new QTapGestureRecognizer); | - | ||||||||||||
| 42 | - | |||||||||||||
| 43 | - | |||||||||||||
| 44 | - | |||||||||||||
| 45 | - | |||||||||||||
| 46 | - | |||||||||||||
| 47 | - | |||||||||||||
| 48 | - | |||||||||||||
| 49 | registerGestureRecognizer(new QTapAndHoldGestureRecognizer); | - | ||||||||||||
| 50 | - | |||||||||||||
| 51 | } never executed: end of block | 0 | ||||||||||||
| 52 | - | |||||||||||||
| 53 | QGestureManager::~QGestureManager() | - | ||||||||||||
| 54 | { | - | ||||||||||||
| 55 | qDeleteAll(m_recognizers.values()); | - | ||||||||||||
| 56 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(m_obsoleteGestures.keys())>::type> _container_((m_obsoleteGestures.keys())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGestureRecognizer *recognizer = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 57 | qDeleteAll(m_obsoleteGestures.value(recognizer)); | - | ||||||||||||
| 58 | delete recognizer; | - | ||||||||||||
| 59 | } never executed: end of block | 0 | ||||||||||||
| 60 | m_obsoleteGestures.clear(); | - | ||||||||||||
| 61 | } never executed: end of block | 0 | ||||||||||||
| 62 | - | |||||||||||||
| 63 | Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *recognizer) | - | ||||||||||||
| 64 | { | - | ||||||||||||
| 65 | QGesture *dummy = recognizer->create(0); | - | ||||||||||||
| 66 | if (!dummy
| 0 | ||||||||||||
| 67 | QMessageLogger(__FILE__, 121, __PRETTY_FUNCTION__).warning("QGestureManager::registerGestureRecognizer: " | - | ||||||||||||
| 68 | "the recognizer fails to create a gesture object, skipping registration."); | - | ||||||||||||
| 69 | return never executed: Qt::GestureType(0);return Qt::GestureType(0);never executed: return Qt::GestureType(0); | 0 | ||||||||||||
| 70 | } | - | ||||||||||||
| 71 | Qt::GestureType type = dummy->gestureType(); | - | ||||||||||||
| 72 | if (type == Qt::CustomGesture
| 0 | ||||||||||||
| 73 | - | |||||||||||||
| 74 | ++m_lastCustomGestureId; | - | ||||||||||||
| 75 | type = Qt::GestureType(m_lastCustomGestureId); | - | ||||||||||||
| 76 | } never executed: end of block | 0 | ||||||||||||
| 77 | m_recognizers.insertMulti(type, recognizer); | - | ||||||||||||
| 78 | delete dummy; | - | ||||||||||||
| 79 | return never executed: type;return type;never executed: return type; | 0 | ||||||||||||
| 80 | } | - | ||||||||||||
| 81 | - | |||||||||||||
| 82 | void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) | - | ||||||||||||
| 83 | { | - | ||||||||||||
| 84 | QList<QGestureRecognizer *> list = m_recognizers.values(type); | - | ||||||||||||
| 85 | while (QGestureRecognizer *recognizer = m_recognizers.take(type)
| 0 | ||||||||||||
| 86 | if (!m_obsoleteGestures.contains(recognizer)
| 0 | ||||||||||||
| 87 | - | |||||||||||||
| 88 | m_obsoleteGestures.insert(recognizer, QSet<QGesture *>()); | - | ||||||||||||
| 89 | } never executed: end of block | 0 | ||||||||||||
| 90 | } never executed: end of block | 0 | ||||||||||||
| 91 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(m_gestureToRecognizer.keys())>::type> _container_((m_gestureToRecognizer.keys())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGesture *g = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 92 | QGestureRecognizer *recognizer = m_gestureToRecognizer.value(g); | - | ||||||||||||
| 93 | if (list.contains(recognizer)
| 0 | ||||||||||||
| 94 | m_deletedRecognizers.insert(g, recognizer); | - | ||||||||||||
| 95 | } never executed: end of block | 0 | ||||||||||||
| 96 | } never executed: end of block | 0 | ||||||||||||
| 97 | - | |||||||||||||
| 98 | QMap<ObjectGesture, QList<QGesture *> >::const_iterator iter = m_objectGestures.constBegin(); | - | ||||||||||||
| 99 | while (iter != m_objectGestures.constEnd()
| 0 | ||||||||||||
| 100 | ObjectGesture objectGesture = iter.key(); | - | ||||||||||||
| 101 | if (objectGesture.gesture == type
| 0 | ||||||||||||
| 102 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(iter.value())>::type> _container_((iter.value())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGesture *g = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 103 | if (QGestureRecognizer *recognizer = m_gestureToRecognizer.value(g)
| 0 | ||||||||||||
| 104 | m_gestureToRecognizer.remove(g); | - | ||||||||||||
| 105 | m_obsoleteGestures[recognizer].insert(g); | - | ||||||||||||
| 106 | } never executed: end of block | 0 | ||||||||||||
| 107 | } never executed: end of block | 0 | ||||||||||||
| 108 | } never executed: end of block | 0 | ||||||||||||
| 109 | ++iter; | - | ||||||||||||
| 110 | } never executed: end of block | 0 | ||||||||||||
| 111 | } never executed: end of block | 0 | ||||||||||||
| 112 | - | |||||||||||||
| 113 | void QGestureManager::cleanupCachedGestures(QObject *target, Qt::GestureType type) | - | ||||||||||||
| 114 | { | - | ||||||||||||
| 115 | QMap<ObjectGesture, QList<QGesture *> >::Iterator iter = m_objectGestures.begin(); | - | ||||||||||||
| 116 | while (iter != m_objectGestures.end()
| 0 | ||||||||||||
| 117 | ObjectGesture objectGesture = iter.key(); | - | ||||||||||||
| 118 | if (objectGesture.gesture == type
| 0 | ||||||||||||
| 119 | QSet<QGesture *> gestures = iter.value().toSet(); | - | ||||||||||||
| 120 | for (QHash<QGestureRecognizer *, QSet<QGesture *> >::iterator | - | ||||||||||||
| 121 | it = m_obsoleteGestures.begin(), e = m_obsoleteGestures.end(); it != e
| 0 | ||||||||||||
| 122 | it.value() -= gestures; | - | ||||||||||||
| 123 | } never executed: end of block | 0 | ||||||||||||
| 124 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(gestures)>::type> _container_((gestures)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGesture *g = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 125 | m_deletedRecognizers.remove(g); | - | ||||||||||||
| 126 | m_gestureToRecognizer.remove(g); | - | ||||||||||||
| 127 | m_maybeGestures.remove(g); | - | ||||||||||||
| 128 | m_activeGestures.remove(g); | - | ||||||||||||
| 129 | m_gestureOwners.remove(g); | - | ||||||||||||
| 130 | m_gestureTargets.remove(g); | - | ||||||||||||
| 131 | m_gesturesToDelete.insert(g); | - | ||||||||||||
| 132 | } never executed: end of block | 0 | ||||||||||||
| 133 | - | |||||||||||||
| 134 | iter = m_objectGestures.erase(iter); | - | ||||||||||||
| 135 | } never executed: else {end of block | 0 | ||||||||||||
| 136 | ++iter; | - | ||||||||||||
| 137 | } never executed: end of block | 0 | ||||||||||||
| 138 | } | - | ||||||||||||
| 139 | } never executed: end of block | 0 | ||||||||||||
| 140 | - | |||||||||||||
| 141 | - | |||||||||||||
| 142 | QGesture *QGestureManager::getState(QObject *object, QGestureRecognizer *recognizer, Qt::GestureType type) | - | ||||||||||||
| 143 | { | - | ||||||||||||
| 144 | - | |||||||||||||
| 145 | - | |||||||||||||
| 146 | - | |||||||||||||
| 147 | if (object->isWidgetType()
| 0 | ||||||||||||
| 148 | if (static_cast<
| 0 | ||||||||||||
| 149 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 150 | } never executed: else if (QGesture *g = qobject_cast<QGesture *>(object)end of block
| 0 | ||||||||||||
| 151 | return never executed: g;return g;never executed: return g; | 0 | ||||||||||||
| 152 | - | |||||||||||||
| 153 | } else { | - | ||||||||||||
| 154 | ((!(qobject_cast<QGraphicsObject *>(object))) ? qt_assert("qobject_cast<QGraphicsObject *>(object)",__FILE__,208) : qt_noop()); | - | ||||||||||||
| 155 | QGraphicsObject *graphicsObject = static_cast<QGraphicsObject *>(object); | - | ||||||||||||
| 156 | if (graphicsObject->QGraphicsItem::d_func()->inDestructor
| 0 | ||||||||||||
| 157 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 158 | - | |||||||||||||
| 159 | } never executed: end of block | 0 | ||||||||||||
| 160 | - | |||||||||||||
| 161 | - | |||||||||||||
| 162 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(m_objectGestures.value(QGestureManager::ObjectGesture(object, type)))>::type> _container_((m_objectGestures.value(QGestureManager::ObjectGesture(object, type)))); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGesture *state = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 163 | if (m_gestureToRecognizer.value(state) == recognizer
| 0 | ||||||||||||
| 164 | return never executed: state;return state;never executed: return state; | 0 | ||||||||||||
| 165 | } never executed: end of block | 0 | ||||||||||||
| 166 | - | |||||||||||||
| 167 | ((!(recognizer)) ? qt_assert("recognizer",__FILE__,221) : qt_noop()); | - | ||||||||||||
| 168 | QGesture *state = recognizer->create(object); | - | ||||||||||||
| 169 | if (!state
| 0 | ||||||||||||
| 170 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 171 | state->setParent(this); | - | ||||||||||||
| 172 | if (state->gestureType() == Qt::CustomGesture
| 0 | ||||||||||||
| 173 | - | |||||||||||||
| 174 | - | |||||||||||||
| 175 | state->d_func()->gestureType = type; | - | ||||||||||||
| 176 | if (lcGestureManager().isDebugEnabled()
| 0 | ||||||||||||
| 177 | state->setObjectName(QString::number((int)type)); never executed: state->setObjectName(QString::number((int)type)); | 0 | ||||||||||||
| 178 | } never executed: end of block | 0 | ||||||||||||
| 179 | m_objectGestures[QGestureManager::ObjectGesture(object, type)].append(state); | - | ||||||||||||
| 180 | m_gestureToRecognizer[state] = recognizer; | - | ||||||||||||
| 181 | m_gestureOwners[state] = object; | - | ||||||||||||
| 182 | - | |||||||||||||
| 183 | return never executed: state;return state;never executed: return state; | 0 | ||||||||||||
| 184 | } | - | ||||||||||||
| 185 | - | |||||||||||||
| 186 | bool QGestureManager::filterEventThroughContexts(const QMultiMap<QObject *, | - | ||||||||||||
| 187 | Qt::GestureType> &contexts, | - | ||||||||||||
| 188 | QEvent *event) | - | ||||||||||||
| 189 | { | - | ||||||||||||
| 190 | QSet<QGesture *> triggeredGestures; | - | ||||||||||||
| 191 | QSet<QGesture *> finishedGestures; | - | ||||||||||||
| 192 | QSet<QGesture *> newMaybeGestures; | - | ||||||||||||
| 193 | QSet<QGesture *> notGestures; | - | ||||||||||||
| 194 | - | |||||||||||||
| 195 | - | |||||||||||||
| 196 | - | |||||||||||||
| 197 | - | |||||||||||||
| 198 | bool consumeEventHint = false; | - | ||||||||||||
| 199 | - | |||||||||||||
| 200 | - | |||||||||||||
| 201 | typedef QMultiMap<QObject *, Qt::GestureType>::const_iterator ContextIterator; | - | ||||||||||||
| 202 | ContextIterator contextEnd = contexts.end(); | - | ||||||||||||
| 203 | for (ContextIterator context = contexts.begin(); context != contextEnd
| 0 | ||||||||||||
| 204 | Qt::GestureType gestureType = context.value(); | - | ||||||||||||
| 205 | const QMap<Qt::GestureType, QGestureRecognizer *> &const_recognizers = m_recognizers; | - | ||||||||||||
| 206 | QMap<Qt::GestureType, QGestureRecognizer *>::const_iterator | - | ||||||||||||
| 207 | typeToRecognizerIterator = const_recognizers.lowerBound(gestureType), | - | ||||||||||||
| 208 | typeToRecognizerEnd = const_recognizers.upperBound(gestureType); | - | ||||||||||||
| 209 | for (; typeToRecognizerIterator != typeToRecognizerEnd
| 0 | ||||||||||||
| 210 | QGestureRecognizer *recognizer = typeToRecognizerIterator.value(); | - | ||||||||||||
| 211 | QObject *target = context.key(); | - | ||||||||||||
| 212 | QGesture *state = getState(target, recognizer, gestureType); | - | ||||||||||||
| 213 | if (!state
| 0 | ||||||||||||
| 214 | continue; never executed: continue; | 0 | ||||||||||||
| 215 | QGestureRecognizer::Result recognizerResult = recognizer->recognize(state, target, event); | - | ||||||||||||
| 216 | QGestureRecognizer::Result recognizerState = recognizerResult & QGestureRecognizer::ResultState_Mask; | - | ||||||||||||
| 217 | QGestureRecognizer::Result resultHint = recognizerResult & QGestureRecognizer::ResultHint_Mask; | - | ||||||||||||
| 218 | if (recognizerState == QGestureRecognizer::TriggerGesture
| 0 | ||||||||||||
| 219 | for (bool qt_category_enabled = lcGestureManager().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 273, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager:Recognizer: gesture triggered: " << state << event; | 0 | ||||||||||||
| 220 | triggeredGestures << state; | - | ||||||||||||
| 221 | } never executed: else if (recognizerState == QGestureRecognizer::FinishGestureend of block
| 0 | ||||||||||||
| 222 | for (bool qt_category_enabled = lcGestureManager().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 276, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager:Recognizer: gesture finished: " << state << event; | 0 | ||||||||||||
| 223 | finishedGestures << state; | - | ||||||||||||
| 224 | } never executed: else if (recognizerState == QGestureRecognizer::MayBeGestureend of block
| 0 | ||||||||||||
| 225 | for (bool qt_category_enabled = lcGestureManager().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 279, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager:Recognizer: maybe gesture: " << state << event; | 0 | ||||||||||||
| 226 | newMaybeGestures << state; | - | ||||||||||||
| 227 | } never executed: else if (recognizerState == QGestureRecognizer::CancelGestureend of block
| 0 | ||||||||||||
| 228 | for (bool qt_category_enabled = lcGestureManager().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 282, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager:Recognizer: not gesture: " << state << event; | 0 | ||||||||||||
| 229 | notGestures << state; | - | ||||||||||||
| 230 | } never executed: else if (recognizerState == QGestureRecognizer::Ignoreend of block
| 0 | ||||||||||||
| 231 | for (bool qt_category_enabled = lcGestureManager().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 285, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager:Recognizer: ignored the event: " << state << event; | 0 | ||||||||||||
| 232 | } never executed: else {end of block | 0 | ||||||||||||
| 233 | for (bool qt_category_enabled = lcGestureManager().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 287, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager:Recognizer: hm, lets assume the recognizer" << "ignored the event: " << state << event; | 0 | ||||||||||||
| 234 | << "ignored the event: " << state << event; never executed: QMessageLogger(__FILE__, 287, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager:Recognizer: hm, lets assume the recognizer" << "ignored the event: " << state << event; | 0 | ||||||||||||
| 235 | } never executed: end of block | 0 | ||||||||||||
| 236 | if (resultHint & QGestureRecognizer::ConsumeEventHint
| 0 | ||||||||||||
| 237 | for (bool qt_category_enabled = lcGestureManager().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 291, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager: we were asked to consume the event: " << state << event; | 0 | ||||||||||||
| 238 | << state << event; never executed: QMessageLogger(__FILE__, 291, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager: we were asked to consume the event: " << state << event; | 0 | ||||||||||||
| 239 | consumeEventHint = true; | - | ||||||||||||
| 240 | } never executed: end of block | 0 | ||||||||||||
| 241 | } never executed: end of block | 0 | ||||||||||||
| 242 | } never executed: end of block | 0 | ||||||||||||
| 243 | if (!triggeredGestures.isEmpty()
| 0 | ||||||||||||
| 244 | || !newMaybeGestures.isEmpty()
| 0 | ||||||||||||
| 245 | QSet<QGesture *> startedGestures = triggeredGestures - m_activeGestures; | - | ||||||||||||
| 246 | triggeredGestures &= m_activeGestures; | - | ||||||||||||
| 247 | - | |||||||||||||
| 248 | - | |||||||||||||
| 249 | QSet<QGesture *> activeToMaybeGestures = m_activeGestures & newMaybeGestures; | - | ||||||||||||
| 250 | - | |||||||||||||
| 251 | - | |||||||||||||
| 252 | QSet<QGesture *> maybeToCanceledGestures = m_maybeGestures & notGestures; | - | ||||||||||||
| 253 | - | |||||||||||||
| 254 | - | |||||||||||||
| 255 | - | |||||||||||||
| 256 | QSet<QGesture *> canceledGestures = m_activeGestures & notGestures; | - | ||||||||||||
| 257 | - | |||||||||||||
| 258 | - | |||||||||||||
| 259 | m_maybeGestures += newMaybeGestures; | - | ||||||||||||
| 260 | - | |||||||||||||
| 261 | - | |||||||||||||
| 262 | QSet<QGesture *> notMaybeGestures = (startedGestures | triggeredGestures | - | ||||||||||||
| 263 | | finishedGestures | canceledGestures | - | ||||||||||||
| 264 | | notGestures); | - | ||||||||||||
| 265 | m_maybeGestures -= notMaybeGestures; | - | ||||||||||||
| 266 | - | |||||||||||||
| 267 | ((!((startedGestures & finishedGestures).isEmpty())) ? qt_assert("(startedGestures & finishedGestures).isEmpty()",__FILE__,321) : qt_noop()); | - | ||||||||||||
| 268 | ((!((startedGestures & newMaybeGestures).isEmpty())) ? qt_assert("(startedGestures & newMaybeGestures).isEmpty()",__FILE__,322) : qt_noop()); | - | ||||||||||||
| 269 | ((!((startedGestures & canceledGestures).isEmpty())) ? qt_assert("(startedGestures & canceledGestures).isEmpty()",__FILE__,323) : qt_noop()); | - | ||||||||||||
| 270 | ((!((finishedGestures & newMaybeGestures).isEmpty())) ? qt_assert("(finishedGestures & newMaybeGestures).isEmpty()",__FILE__,324) : qt_noop()); | - | ||||||||||||
| 271 | ((!((finishedGestures & canceledGestures).isEmpty())) ? qt_assert("(finishedGestures & canceledGestures).isEmpty()",__FILE__,325) : qt_noop()); | - | ||||||||||||
| 272 | ((!((canceledGestures & newMaybeGestures).isEmpty())) ? qt_assert("(canceledGestures & newMaybeGestures).isEmpty()",__FILE__,326) : qt_noop()); | - | ||||||||||||
| 273 | - | |||||||||||||
| 274 | QSet<QGesture *> notStarted = finishedGestures - m_activeGestures; | - | ||||||||||||
| 275 | if (!notStarted.isEmpty()
| 0 | ||||||||||||
| 276 | - | |||||||||||||
| 277 | - | |||||||||||||
| 278 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(notStarted)>::type> _container_((notStarted)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGesture *gesture = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||
| 279 | gesture->d_func()->state = Qt::GestureStarted; never executed: gesture->d_func()->state = Qt::GestureStarted; | 0 | ||||||||||||
| 280 | QSet<QGesture *> undeliveredGestures; | - | ||||||||||||
| 281 | deliverEvents(notStarted, &undeliveredGestures); | - | ||||||||||||
| 282 | finishedGestures -= undeliveredGestures; | - | ||||||||||||
| 283 | } never executed: end of block | 0 | ||||||||||||
| 284 | - | |||||||||||||
| 285 | m_activeGestures += startedGestures; | - | ||||||||||||
| 286 | - | |||||||||||||
| 287 | ((!((m_activeGestures & triggeredGestures).size() == triggeredGestures.size())) ? qt_assert("(m_activeGestures & triggeredGestures).size() == triggeredGestures.size()",__FILE__,341) : qt_noop()); | - | ||||||||||||
| 288 | m_activeGestures -= finishedGestures; | - | ||||||||||||
| 289 | m_activeGestures -= activeToMaybeGestures; | - | ||||||||||||
| 290 | m_activeGestures -= canceledGestures; | - | ||||||||||||
| 291 | - | |||||||||||||
| 292 | - | |||||||||||||
| 293 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(startedGestures)>::type> _container_((startedGestures)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGesture *gesture = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||
| 294 | gesture->d_func()->state = Qt::GestureStarted; never executed: gesture->d_func()->state = Qt::GestureStarted; | 0 | ||||||||||||
| 295 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(triggeredGestures)>::type> _container_((triggeredGestures)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGesture *gesture = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||
| 296 | gesture->d_func()->state = Qt::GestureUpdated; never executed: gesture->d_func()->state = Qt::GestureUpdated; | 0 | ||||||||||||
| 297 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(finishedGestures)>::type> _container_((finishedGestures)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGesture *gesture = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||
| 298 | gesture->d_func()->state = Qt::GestureFinished; never executed: gesture->d_func()->state = Qt::GestureFinished; | 0 | ||||||||||||
| 299 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(canceledGestures)>::type> _container_((canceledGestures)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGesture *gesture = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||
| 300 | gesture->d_func()->state = Qt::GestureCanceled; never executed: gesture->d_func()->state = Qt::GestureCanceled; | 0 | ||||||||||||
| 301 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(activeToMaybeGestures)>::type> _container_((activeToMaybeGestures)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGesture *gesture = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||
| 302 | gesture->d_func()->state = Qt::GestureFinished; never executed: gesture->d_func()->state = Qt::GestureFinished; | 0 | ||||||||||||
| 303 | - | |||||||||||||
| 304 | if (!m_activeGestures.isEmpty()
| 0 | ||||||||||||
| 305 | !startedGestures.isEmpty()
| 0 | ||||||||||||
| 306 | !finishedGestures.isEmpty()
| 0 | ||||||||||||
| 307 | for (bool qt_category_enabled = lcGestureManager().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 361, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::filterEventThroughContexts:" << "\n\tactiveGestures:" << m_activeGestures << "\n\tmaybeGestures:" << m_maybeGestures << "\n\tstarted:" << startedGestures << "\n\ttriggered:" << triggeredGestures << "\n\tfinished:" << finishedGestures << "\n\tcanceled:" << canceledGestures << "\n\tmaybe-canceled:" << maybeToCanceledGestures; | 0 | ||||||||||||
| 308 | << "\n\tactiveGestures:" << m_activeGestures never executed: QMessageLogger(__FILE__, 361, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::filterEventThroughContexts:" << "\n\tactiveGestures:" << m_activeGestures << "\n\tmaybeGestures:" << m_maybeGestures << "\n\tstarted:" << startedGestures << "\n\ttriggered:" << triggeredGestures << "\n\tfinished:" << finishedGestures << "\n\tcanceled:" << canceledGestures << "\n\tmaybe-canceled:" << maybeToCanceledGestures; | 0 | ||||||||||||
| 309 | << "\n\tmaybeGestures:" << m_maybeGestures never executed: QMessageLogger(__FILE__, 361, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::filterEventThroughContexts:" << "\n\tactiveGestures:" << m_activeGestures << "\n\tmaybeGestures:" << m_maybeGestures << "\n\tstarted:" << startedGestures << "\n\ttriggered:" << triggeredGestures << "\n\tfinished:" << finishedGestures << "\n\tcanceled:" << canceledGestures << "\n\tmaybe-canceled:" << maybeToCanceledGestures; | 0 | ||||||||||||
| 310 | << "\n\tstarted:" << startedGestures never executed: QMessageLogger(__FILE__, 361, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::filterEventThroughContexts:" << "\n\tactiveGestures:" << m_activeGestures << "\n\tmaybeGestures:" << m_maybeGestures << "\n\tstarted:" << startedGestures << "\n\ttriggered:" << triggeredGestures << "\n\tfinished:" << finishedGestures << "\n\tcanceled:" << canceledGestures << "\n\tmaybe-canceled:" << maybeToCanceledGestures; | 0 | ||||||||||||
| 311 | << "\n\ttriggered:" << triggeredGestures never executed: QMessageLogger(__FILE__, 361, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::filterEventThroughContexts:" << "\n\tactiveGestures:" << m_activeGestures << "\n\tmaybeGestures:" << m_maybeGestures << "\n\tstarted:" << startedGestures << "\n\ttriggered:" << triggeredGestures << "\n\tfinished:" << finishedGestures << "\n\tcanceled:" << canceledGestures << "\n\tmaybe-canceled:" << maybeToCanceledGestures; | 0 | ||||||||||||
| 312 | << "\n\tfinished:" << finishedGestures never executed: QMessageLogger(__FILE__, 361, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::filterEventThroughContexts:" << "\n\tactiveGestures:" << m_activeGestures << "\n\tmaybeGestures:" << m_maybeGestures << "\n\tstarted:" << startedGestures << "\n\ttriggered:" << triggeredGestures << "\n\tfinished:" << finishedGestures << "\n\tcanceled:" << canceledGestures << "\n\tmaybe-canceled:" << maybeToCanceledGestures; | 0 | ||||||||||||
| 313 | << "\n\tcanceled:" << canceledGestures never executed: QMessageLogger(__FILE__, 361, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::filterEventThroughContexts:" << "\n\tactiveGestures:" << m_activeGestures << "\n\tmaybeGestures:" << m_maybeGestures << "\n\tstarted:" << startedGestures << "\n\ttriggered:" << triggeredGestures << "\n\tfinished:" << finishedGestures << "\n\tcanceled:" << canceledGestures << "\n\tmaybe-canceled:" << maybeToCanceledGestures; | 0 | ||||||||||||
| 314 | << "\n\tmaybe-canceled:" << maybeToCanceledGestures; never executed: QMessageLogger(__FILE__, 361, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::filterEventThroughContexts:" << "\n\tactiveGestures:" << m_activeGestures << "\n\tmaybeGestures:" << m_maybeGestures << "\n\tstarted:" << startedGestures << "\n\ttriggered:" << triggeredGestures << "\n\tfinished:" << finishedGestures << "\n\tcanceled:" << canceledGestures << "\n\tmaybe-canceled:" << maybeToCanceledGestures; | 0 | ||||||||||||
| 315 | } never executed: end of block | 0 | ||||||||||||
| 316 | - | |||||||||||||
| 317 | QSet<QGesture *> undeliveredGestures; | - | ||||||||||||
| 318 | deliverEvents(startedGestures+triggeredGestures+finishedGestures+canceledGestures, | - | ||||||||||||
| 319 | &undeliveredGestures); | - | ||||||||||||
| 320 | - | |||||||||||||
| 321 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(startedGestures)>::type> _container_((startedGestures)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGesture *g = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 322 | if (undeliveredGestures.contains(g)
| 0 | ||||||||||||
| 323 | continue; never executed: continue; | 0 | ||||||||||||
| 324 | if (g->gestureCancelPolicy() == QGesture::CancelAllInContext
| 0 | ||||||||||||
| 325 | for (bool qt_category_enabled = lcGestureManager().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 379, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "lets try to cancel some"; | 0 | ||||||||||||
| 326 | - | |||||||||||||
| 327 | cancelGesturesForChildren(g); | - | ||||||||||||
| 328 | } never executed: end of block | 0 | ||||||||||||
| 329 | } never executed: end of block | 0 | ||||||||||||
| 330 | - | |||||||||||||
| 331 | m_activeGestures -= undeliveredGestures; | - | ||||||||||||
| 332 | - | |||||||||||||
| 333 | - | |||||||||||||
| 334 | QSet<QGesture *> endedGestures = | - | ||||||||||||
| 335 | finishedGestures + canceledGestures + undeliveredGestures + maybeToCanceledGestures; | - | ||||||||||||
| 336 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(endedGestures)>::type> _container_((endedGestures)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGesture *gesture = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 337 | recycle(gesture); | - | ||||||||||||
| 338 | m_gestureTargets.remove(gesture); | - | ||||||||||||
| 339 | } never executed: end of block | 0 | ||||||||||||
| 340 | } never executed: end of block | 0 | ||||||||||||
| 341 | - | |||||||||||||
| 342 | qDeleteAll(m_gesturesToDelete); | - | ||||||||||||
| 343 | m_gesturesToDelete.clear(); | - | ||||||||||||
| 344 | - | |||||||||||||
| 345 | return never executed: consumeEventHint;return consumeEventHint;never executed: return consumeEventHint; | 0 | ||||||||||||
| 346 | } | - | ||||||||||||
| 347 | - | |||||||||||||
| 348 | - | |||||||||||||
| 349 | void QGestureManager::cancelGesturesForChildren(QGesture *original) | - | ||||||||||||
| 350 | { | - | ||||||||||||
| 351 | ((!(original)) ? qt_assert("original",__FILE__,405) : qt_noop()); | - | ||||||||||||
| 352 | QWidget *originatingWidget = m_gestureTargets.value(original); | - | ||||||||||||
| 353 | ((!(originatingWidget)) ? qt_assert("originatingWidget",__FILE__,407) : qt_noop()); | - | ||||||||||||
| 354 | if (!originatingWidget
| 0 | ||||||||||||
| 355 | return; never executed: return; | 0 | ||||||||||||
| 356 | - | |||||||||||||
| 357 | - | |||||||||||||
| 358 | - | |||||||||||||
| 359 | - | |||||||||||||
| 360 | - | |||||||||||||
| 361 | QSet<QGesture*> cancelledGestures; | - | ||||||||||||
| 362 | QSet<QGesture*>::Iterator iter = m_activeGestures.begin(); | - | ||||||||||||
| 363 | while (iter != m_activeGestures.end()
| 0 | ||||||||||||
| 364 | QWidget *widget = m_gestureTargets.value(*iter); | - | ||||||||||||
| 365 | - | |||||||||||||
| 366 | if (widget != originatingWidget
| 0 | ||||||||||||
| 367 | for (bool qt_category_enabled = lcGestureManager().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 421, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << " found a gesture to cancel" << (*iter); | 0 | ||||||||||||
| 368 | (*iter)->d_func()->state = Qt::GestureCanceled; | - | ||||||||||||
| 369 | cancelledGestures << *iter; | - | ||||||||||||
| 370 | iter = m_activeGestures.erase(iter); | - | ||||||||||||
| 371 | } never executed: else {end of block | 0 | ||||||||||||
| 372 | ++iter; | - | ||||||||||||
| 373 | } never executed: end of block | 0 | ||||||||||||
| 374 | } | - | ||||||||||||
| 375 | - | |||||||||||||
| 376 | - | |||||||||||||
| 377 | - | |||||||||||||
| 378 | - | |||||||||||||
| 379 | QSet<QGesture *> almostCanceledGestures = cancelledGestures; | - | ||||||||||||
| 380 | while (!almostCanceledGestures.isEmpty()
| 0 | ||||||||||||
| 381 | QWidget *target = 0; | - | ||||||||||||
| 382 | QSet<QGesture*> gestures; | - | ||||||||||||
| 383 | iter = almostCanceledGestures.begin(); | - | ||||||||||||
| 384 | - | |||||||||||||
| 385 | while (iter != almostCanceledGestures.end()
| 0 | ||||||||||||
| 386 | QWidget *widget = m_gestureTargets.value(*iter); | - | ||||||||||||
| 387 | if (target == 0
| 0 | ||||||||||||
| 388 | target = widget; never executed: target = widget; | 0 | ||||||||||||
| 389 | if (target == widget
| 0 | ||||||||||||
| 390 | gestures << *iter; | - | ||||||||||||
| 391 | iter = almostCanceledGestures.erase(iter); | - | ||||||||||||
| 392 | } never executed: else {end of block | 0 | ||||||||||||
| 393 | ++iter; | - | ||||||||||||
| 394 | } never executed: end of block | 0 | ||||||||||||
| 395 | } | - | ||||||||||||
| 396 | ((!(target)) ? qt_assert("target",__FILE__,450) : qt_noop()); | - | ||||||||||||
| 397 | - | |||||||||||||
| 398 | QSet<QGesture*> undeliveredGestures; | - | ||||||||||||
| 399 | deliverEvents(gestures, &undeliveredGestures); | - | ||||||||||||
| 400 | } never executed: end of block | 0 | ||||||||||||
| 401 | - | |||||||||||||
| 402 | for (iter = cancelledGestures.begin(); iter != cancelledGestures.end()
| 0 | ||||||||||||
| 403 | recycle(*iter); never executed: recycle(*iter); | 0 | ||||||||||||
| 404 | } never executed: end of block | 0 | ||||||||||||
| 405 | - | |||||||||||||
| 406 | void QGestureManager::cleanupGesturesForRemovedRecognizer(QGesture *gesture) | - | ||||||||||||
| 407 | { | - | ||||||||||||
| 408 | QGestureRecognizer *recognizer = m_deletedRecognizers.value(gesture); | - | ||||||||||||
| 409 | if(!recognizer
| 0 | ||||||||||||
| 410 | return; never executed: return; | 0 | ||||||||||||
| 411 | m_deletedRecognizers.remove(gesture); | - | ||||||||||||
| 412 | if (m_deletedRecognizers.keys(recognizer).isEmpty()
| 0 | ||||||||||||
| 413 | - | |||||||||||||
| 414 | qDeleteAll(m_obsoleteGestures.value(recognizer)); | - | ||||||||||||
| 415 | m_obsoleteGestures.remove(recognizer); | - | ||||||||||||
| 416 | delete recognizer; | - | ||||||||||||
| 417 | } never executed: end of block | 0 | ||||||||||||
| 418 | } never executed: end of block | 0 | ||||||||||||
| 419 | - | |||||||||||||
| 420 | - | |||||||||||||
| 421 | bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) | - | ||||||||||||
| 422 | { | - | ||||||||||||
| 423 | QMap<Qt::GestureType, int> types; | - | ||||||||||||
| 424 | QMultiMap<QObject *, Qt::GestureType> contexts; | - | ||||||||||||
| 425 | QWidget *w = receiver; | - | ||||||||||||
| 426 | typedef QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator ContextIterator; | - | ||||||||||||
| 427 | if (!w->d_func()->gestureContext.isEmpty()
| 0 | ||||||||||||
| 428 | for(ContextIterator it = w->d_func()->gestureContext.constBegin(), | - | ||||||||||||
| 429 | e = w->d_func()->gestureContext.constEnd(); it != e
| 0 | ||||||||||||
| 430 | types.insert(it.key(), 0); | - | ||||||||||||
| 431 | contexts.insertMulti(w, it.key()); | - | ||||||||||||
| 432 | } never executed: end of block | 0 | ||||||||||||
| 433 | } never executed: end of block | 0 | ||||||||||||
| 434 | - | |||||||||||||
| 435 | w = w->isWindow()
| 0 | ||||||||||||
| 436 | while (w
| 0 | ||||||||||||
| 437 | { | - | ||||||||||||
| 438 | for (ContextIterator it = w->d_func()->gestureContext.constBegin(), | - | ||||||||||||
| 439 | e = w->d_func()->gestureContext.constEnd(); it != e
| 0 | ||||||||||||
| 440 | if (!(it.value() & Qt::DontStartGestureOnChildren)
| 0 | ||||||||||||
| 441 | if (!types.contains(it.key())
| 0 | ||||||||||||
| 442 | types.insert(it.key(), 0); | - | ||||||||||||
| 443 | contexts.insertMulti(w, it.key()); | - | ||||||||||||
| 444 | } never executed: end of block | 0 | ||||||||||||
| 445 | } never executed: end of block | 0 | ||||||||||||
| 446 | } never executed: end of block | 0 | ||||||||||||
| 447 | if (w->isWindow()
| 0 | ||||||||||||
| 448 | break; never executed: break; | 0 | ||||||||||||
| 449 | w = w->parentWidget(); | - | ||||||||||||
| 450 | } never executed: end of block | 0 | ||||||||||||
| 451 | return never executed: contexts.isEmpty()return contexts.isEmpty() ? false : filterEventThroughContexts(contexts, event);
never executed: return contexts.isEmpty() ? false : filterEventThroughContexts(contexts, event); | 0 | ||||||||||||
| 452 | } | - | ||||||||||||
| 453 | - | |||||||||||||
| 454 | - | |||||||||||||
| 455 | bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event) | - | ||||||||||||
| 456 | { | - | ||||||||||||
| 457 | QMap<Qt::GestureType, int> types; | - | ||||||||||||
| 458 | QMultiMap<QObject *, Qt::GestureType> contexts; | - | ||||||||||||
| 459 | QGraphicsObject *item = receiver; | - | ||||||||||||
| 460 | if (!item->QGraphicsItem::d_func()->gestureContext.isEmpty()
| 0 | ||||||||||||
| 461 | typedef QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator ContextIterator; | - | ||||||||||||
| 462 | for(ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.constBegin(), | - | ||||||||||||
| 463 | e = item->QGraphicsItem::d_func()->gestureContext.constEnd(); it != e
| 0 | ||||||||||||
| 464 | types.insert(it.key(), 0); | - | ||||||||||||
| 465 | contexts.insertMulti(item, it.key()); | - | ||||||||||||
| 466 | } never executed: end of block | 0 | ||||||||||||
| 467 | } never executed: end of block | 0 | ||||||||||||
| 468 | - | |||||||||||||
| 469 | item = item->parentObject(); | - | ||||||||||||
| 470 | while (item
| 0 | ||||||||||||
| 471 | { | - | ||||||||||||
| 472 | typedef QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator ContextIterator; | - | ||||||||||||
| 473 | for (ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.constBegin(), | - | ||||||||||||
| 474 | e = item->QGraphicsItem::d_func()->gestureContext.constEnd(); it != e
| 0 | ||||||||||||
| 475 | if (!(it.value() & Qt::DontStartGestureOnChildren)
| 0 | ||||||||||||
| 476 | if (!types.contains(it.key())
| 0 | ||||||||||||
| 477 | types.insert(it.key(), 0); | - | ||||||||||||
| 478 | contexts.insertMulti(item, it.key()); | - | ||||||||||||
| 479 | } never executed: end of block | 0 | ||||||||||||
| 480 | } never executed: end of block | 0 | ||||||||||||
| 481 | } never executed: end of block | 0 | ||||||||||||
| 482 | item = item->parentObject(); | - | ||||||||||||
| 483 | } never executed: end of block | 0 | ||||||||||||
| 484 | return never executed: contexts.isEmpty()return contexts.isEmpty() ? false : filterEventThroughContexts(contexts, event);
never executed: return contexts.isEmpty() ? false : filterEventThroughContexts(contexts, event); | 0 | ||||||||||||
| 485 | } | - | ||||||||||||
| 486 | - | |||||||||||||
| 487 | - | |||||||||||||
| 488 | bool QGestureManager::filterEvent(QObject *receiver, QEvent *event) | - | ||||||||||||
| 489 | { | - | ||||||||||||
| 490 | - | |||||||||||||
| 491 | - | |||||||||||||
| 492 | QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(receiver); | - | ||||||||||||
| 493 | - | |||||||||||||
| 494 | if (widgetWindow
| 0 | ||||||||||||
| 495 | return never executed: filterEvent(widgetWindow->widget(), event);return filterEvent(widgetWindow->widget(), event);never executed: return filterEvent(widgetWindow->widget(), event); | 0 | ||||||||||||
| 496 | - | |||||||||||||
| 497 | QGesture *state = qobject_cast<QGesture *>(receiver); | - | ||||||||||||
| 498 | if (!state
| 0 | ||||||||||||
| 499 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 500 | QMultiMap<QObject *, Qt::GestureType> contexts; | - | ||||||||||||
| 501 | contexts.insert(state, state->gestureType()); | - | ||||||||||||
| 502 | return never executed: filterEventThroughContexts(contexts, event);return filterEventThroughContexts(contexts, event);never executed: return filterEventThroughContexts(contexts, event); | 0 | ||||||||||||
| 503 | } | - | ||||||||||||
| 504 | - | |||||||||||||
| 505 | void QGestureManager::getGestureTargets(const QSet<QGesture*> &gestures, | - | ||||||||||||
| 506 | QHash<QWidget *, QList<QGesture *> > *conflicts, | - | ||||||||||||
| 507 | QHash<QWidget *, QList<QGesture *> > *normal) | - | ||||||||||||
| 508 | { | - | ||||||||||||
| 509 | typedef QHash<Qt::GestureType, QHash<QWidget *, QGesture *> > GestureByTypes; | - | ||||||||||||
| 510 | GestureByTypes gestureByTypes; | - | ||||||||||||
| 511 | - | |||||||||||||
| 512 | - | |||||||||||||
| 513 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(gestures)>::type> _container_((gestures)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGesture *gesture = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 514 | QWidget *receiver = m_gestureTargets.value(gesture, 0); | - | ||||||||||||
| 515 | ((!(receiver)) ? qt_assert("receiver",__FILE__,569) : qt_noop()); | - | ||||||||||||
| 516 | if (receiver
| 0 | ||||||||||||
| 517 | gestureByTypes[gesture->gestureType()].insert(receiver, gesture); never executed: gestureByTypes[gesture->gestureType()].insert(receiver, gesture); | 0 | ||||||||||||
| 518 | } never executed: end of block | 0 | ||||||||||||
| 519 | - | |||||||||||||
| 520 | - | |||||||||||||
| 521 | for (GestureByTypes::const_iterator git = gestureByTypes.cbegin(), gend = gestureByTypes.cend(); git != gend
| 0 | ||||||||||||
| 522 | const QHash<QWidget *, QGesture *> &gestures = git.value(); | - | ||||||||||||
| 523 | for (QHash<QWidget *, QGesture *>::const_iterator wit = gestures.cbegin(), wend = gestures.cend(); wit != wend
| 0 | ||||||||||||
| 524 | QWidget *widget = wit.key(); | - | ||||||||||||
| 525 | QWidget *w = widget->parentWidget(); | - | ||||||||||||
| 526 | while (w
| 0 | ||||||||||||
| 527 | QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator it | - | ||||||||||||
| 528 | = w->d_func()->gestureContext.constFind(git.key()); | - | ||||||||||||
| 529 | if (it != w->d_func()->gestureContext.constEnd()
| 0 | ||||||||||||
| 530 | - | |||||||||||||
| 531 | if (!(it.value() & Qt::DontStartGestureOnChildren)
| 0 | ||||||||||||
| 532 | - | |||||||||||||
| 533 | (*conflicts)[widget].append(wit.value()); | - | ||||||||||||
| 534 | break; never executed: break; | 0 | ||||||||||||
| 535 | } | - | ||||||||||||
| 536 | } never executed: end of block | 0 | ||||||||||||
| 537 | if (w->isWindow()
| 0 | ||||||||||||
| 538 | w = 0; | - | ||||||||||||
| 539 | break; never executed: break; | 0 | ||||||||||||
| 540 | } | - | ||||||||||||
| 541 | w = w->parentWidget(); | - | ||||||||||||
| 542 | } never executed: end of block | 0 | ||||||||||||
| 543 | if (!w
| 0 | ||||||||||||
| 544 | (* never executed: normal)[widget].append(wit.value());(*normal)[widget].append(wit.value());never executed: (*normal)[widget].append(wit.value()); | 0 | ||||||||||||
| 545 | } never executed: end of block | 0 | ||||||||||||
| 546 | } never executed: end of block | 0 | ||||||||||||
| 547 | } never executed: end of block | 0 | ||||||||||||
| 548 | - | |||||||||||||
| 549 | void QGestureManager::deliverEvents(const QSet<QGesture *> &gestures, | - | ||||||||||||
| 550 | QSet<QGesture *> *undeliveredGestures) | - | ||||||||||||
| 551 | { | - | ||||||||||||
| 552 | if (gestures.isEmpty()
| 0 | ||||||||||||
| 553 | return; never executed: return; | 0 | ||||||||||||
| 554 | - | |||||||||||||
| 555 | typedef QHash<QWidget *, QList<QGesture *> > GesturesPerWidget; | - | ||||||||||||
| 556 | GesturesPerWidget conflictedGestures; | - | ||||||||||||
| 557 | GesturesPerWidget normalStartedGestures; | - | ||||||||||||
| 558 | - | |||||||||||||
| 559 | QSet<QGesture *> startedGestures; | - | ||||||||||||
| 560 | - | |||||||||||||
| 561 | for (QSet<QGesture *>::const_iterator it = gestures.begin(), | - | ||||||||||||
| 562 | e = gestures.end(); it != e
| 0 | ||||||||||||
| 563 | QGesture *gesture = *it; | - | ||||||||||||
| 564 | QWidget *target = m_gestureTargets.value(gesture, 0); | - | ||||||||||||
| 565 | if (!target
| 0 | ||||||||||||
| 566 | - | |||||||||||||
| 567 | ((!(gesture->state() == Qt::GestureStarted)) ? qt_assert("gesture->state() == Qt::GestureStarted",__FILE__,621) : qt_noop()); | - | ||||||||||||
| 568 | if (gesture->hasHotSpot()
| 0 | ||||||||||||
| 569 | - | |||||||||||||
| 570 | QPoint pt = gesture->hotSpot().toPoint(); | - | ||||||||||||
| 571 | if (QWidget *topLevel = QApplication::topLevelAt(pt)
| 0 | ||||||||||||
| 572 | QWidget *child = topLevel->childAt(topLevel->mapFromGlobal(pt)); | - | ||||||||||||
| 573 | target = child
| 0 | ||||||||||||
| 574 | } never executed: end of block | 0 | ||||||||||||
| 575 | } never executed: else {end of block | 0 | ||||||||||||
| 576 | - | |||||||||||||
| 577 | QObject *context = m_gestureOwners.value(gesture, 0); | - | ||||||||||||
| 578 | if (context->isWidgetType()
| 0 | ||||||||||||
| 579 | target = static_cast<QWidget *>(context); never executed: target = static_cast<QWidget *>(context); | 0 | ||||||||||||
| 580 | } never executed: end of block | 0 | ||||||||||||
| 581 | if (target
| 0 | ||||||||||||
| 582 | m_gestureTargets.insert(gesture, target); never executed: m_gestureTargets.insert(gesture, target); | 0 | ||||||||||||
| 583 | } never executed: end of block | 0 | ||||||||||||
| 584 | - | |||||||||||||
| 585 | Qt::GestureType gestureType = gesture->gestureType(); | - | ||||||||||||
| 586 | ((!(gestureType != Qt::CustomGesture)) ? qt_assert("gestureType != Qt::CustomGesture",__FILE__,640) : qt_noop()); | - | ||||||||||||
| 587 | (void)gestureType;; | - | ||||||||||||
| 588 | - | |||||||||||||
| 589 | if (target
| 0 | ||||||||||||
| 590 | if (gesture->state() == Qt::GestureStarted
| 0 | ||||||||||||
| 591 | startedGestures.insert(gesture); | - | ||||||||||||
| 592 | } never executed: else {end of block | 0 | ||||||||||||
| 593 | normalStartedGestures[target].append(gesture); | - | ||||||||||||
| 594 | } never executed: end of block | 0 | ||||||||||||
| 595 | } else { | - | ||||||||||||
| 596 | for (bool qt_category_enabled = lcGestureManager().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 650, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::deliverEvent: could not find the target for gesture" << gesture->gestureType(); | 0 | ||||||||||||
| 597 | << gesture->gestureType(); never executed: QMessageLogger(__FILE__, 650, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::deliverEvent: could not find the target for gesture" << gesture->gestureType(); | 0 | ||||||||||||
| 598 | QMessageLogger(__FILE__, 652, __PRETTY_FUNCTION__).warning("QGestureManager::deliverEvent: could not find the target for gesture"); | - | ||||||||||||
| 599 | undeliveredGestures->insert(gesture); | - | ||||||||||||
| 600 | } never executed: end of block | 0 | ||||||||||||
| 601 | } | - | ||||||||||||
| 602 | - | |||||||||||||
| 603 | getGestureTargets(startedGestures, &conflictedGestures, &normalStartedGestures); | - | ||||||||||||
| 604 | for (bool qt_category_enabled = lcGestureManager().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 658, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::deliverEvents:" << "\nstarted: " << startedGestures << "\nconflicted: " << conflictedGestures << "\nnormal: " << normalStartedGestures << "\n"; | 0 | ||||||||||||
| 605 | << "\nstarted: " << startedGestures never executed: QMessageLogger(__FILE__, 658, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::deliverEvents:" << "\nstarted: " << startedGestures << "\nconflicted: " << conflictedGestures << "\nnormal: " << normalStartedGestures << "\n"; | 0 | ||||||||||||
| 606 | << "\nconflicted: " << conflictedGestures never executed: QMessageLogger(__FILE__, 658, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::deliverEvents:" << "\nstarted: " << startedGestures << "\nconflicted: " << conflictedGestures << "\nnormal: " << normalStartedGestures << "\n"; | 0 | ||||||||||||
| 607 | << "\nnormal: " << normalStartedGestures never executed: QMessageLogger(__FILE__, 658, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::deliverEvents:" << "\nstarted: " << startedGestures << "\nconflicted: " << conflictedGestures << "\nnormal: " << normalStartedGestures << "\n"; | 0 | ||||||||||||
| 608 | << "\n"; never executed: QMessageLogger(__FILE__, 658, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::deliverEvents:" << "\nstarted: " << startedGestures << "\nconflicted: " << conflictedGestures << "\nnormal: " << normalStartedGestures << "\n"; | 0 | ||||||||||||
| 609 | - | |||||||||||||
| 610 | - | |||||||||||||
| 611 | for (GesturesPerWidget::const_iterator it = conflictedGestures.constBegin(), | - | ||||||||||||
| 612 | e = conflictedGestures.constEnd(); it != e
| 0 | ||||||||||||
| 613 | QWidget *receiver = it.key(); | - | ||||||||||||
| 614 | QList<QGesture *> gestures = it.value(); | - | ||||||||||||
| 615 | for (bool qt_category_enabled = lcGestureManager().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 669, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::deliverEvents: sending GestureOverride to" << receiver << "gestures:" << gestures; | 0 | ||||||||||||
| 616 | << receiver never executed: QMessageLogger(__FILE__, 669, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::deliverEvents: sending GestureOverride to" << receiver << "gestures:" << gestures; | 0 | ||||||||||||
| 617 | << "gestures:" << gestures; never executed: QMessageLogger(__FILE__, 669, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::deliverEvents: sending GestureOverride to" << receiver << "gestures:" << gestures; | 0 | ||||||||||||
| 618 | QGestureEvent event(gestures); | - | ||||||||||||
| 619 | event.t = QEvent::GestureOverride; | - | ||||||||||||
| 620 | - | |||||||||||||
| 621 | event.ignore(); | - | ||||||||||||
| 622 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(gestures)>::type> _container_((gestures)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGesture *g = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||
| 623 | event.setAccepted(g, false); never executed: event.setAccepted(g, false); | 0 | ||||||||||||
| 624 | - | |||||||||||||
| 625 | QApplication::sendEvent(receiver, &event); | - | ||||||||||||
| 626 | bool eventAccepted = event.isAccepted(); | - | ||||||||||||
| 627 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(event.gestures())>::type> _container_((event.gestures())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGesture *gesture = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 628 | if (eventAccepted
| 0 | ||||||||||||
| 629 | QWidget *w = event.m_targetWidgets.value(gesture->gestureType(), 0); | - | ||||||||||||
| 630 | ((!(w)) ? qt_assert("w",__FILE__,684) : qt_noop()); | - | ||||||||||||
| 631 | for (bool qt_category_enabled = lcGestureManager().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 685, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "override event: gesture was accepted:" << gesture << w; | 0 | ||||||||||||
| 632 | QList<QGesture *> &gestures = normalStartedGestures[w]; | - | ||||||||||||
| 633 | gestures.append(gesture); | - | ||||||||||||
| 634 | - | |||||||||||||
| 635 | m_gestureTargets[gesture] = w; | - | ||||||||||||
| 636 | } never executed: else {end of block | 0 | ||||||||||||
| 637 | for (bool qt_category_enabled = lcGestureManager().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 691, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "override event: gesture wasn't accepted. putting back:" << gesture; | 0 | ||||||||||||
| 638 | QList<QGesture *> &gestures = normalStartedGestures[receiver]; | - | ||||||||||||
| 639 | gestures.append(gesture); | - | ||||||||||||
| 640 | } never executed: end of block | 0 | ||||||||||||
| 641 | } | - | ||||||||||||
| 642 | } never executed: end of block | 0 | ||||||||||||
| 643 | - | |||||||||||||
| 644 | - | |||||||||||||
| 645 | for (GesturesPerWidget::const_iterator it = normalStartedGestures.constBegin(), | - | ||||||||||||
| 646 | e = normalStartedGestures.constEnd(); it != e
| 0 | ||||||||||||
| 647 | if (!it.value().isEmpty()
| 0 | ||||||||||||
| 648 | for (bool qt_category_enabled = lcGestureManager().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 702, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::deliverEvents: sending to" << it.key() << "gestures:" << it.value(); | 0 | ||||||||||||
| 649 | << "gestures:" << it.value(); never executed: QMessageLogger(__FILE__, 702, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::deliverEvents: sending to" << it.key() << "gestures:" << it.value(); | 0 | ||||||||||||
| 650 | QGestureEvent event(it.value()); | - | ||||||||||||
| 651 | QApplication::sendEvent(it.key(), &event); | - | ||||||||||||
| 652 | bool eventAccepted = event.isAccepted(); | - | ||||||||||||
| 653 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(event.gestures())>::type> _container_((event.gestures())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGesture *gesture = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 654 | if (gesture->state() == Qt::GestureStarted
| 0 | ||||||||||||
| 655 | (eventAccepted
| 0 | ||||||||||||
| 656 | QWidget *w = event.m_targetWidgets.value(gesture->gestureType(), 0); | - | ||||||||||||
| 657 | ((!(w)) ? qt_assert("w",__FILE__,711) : qt_noop()); | - | ||||||||||||
| 658 | for (bool qt_category_enabled = lcGestureManager().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 712, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "started gesture was delivered and accepted by" << w; | 0 | ||||||||||||
| 659 | m_gestureTargets[gesture] = w; | - | ||||||||||||
| 660 | } never executed: end of block | 0 | ||||||||||||
| 661 | } never executed: end of block | 0 | ||||||||||||
| 662 | } never executed: end of block | 0 | ||||||||||||
| 663 | } never executed: end of block | 0 | ||||||||||||
| 664 | } never executed: end of block | 0 | ||||||||||||
| 665 | - | |||||||||||||
| 666 | void QGestureManager::recycle(QGesture *gesture) | - | ||||||||||||
| 667 | { | - | ||||||||||||
| 668 | QGestureRecognizer *recognizer = m_gestureToRecognizer.value(gesture, 0); | - | ||||||||||||
| 669 | if (recognizer
| 0 | ||||||||||||
| 670 | gesture->setGestureCancelPolicy(QGesture::CancelNone); | - | ||||||||||||
| 671 | recognizer->reset(gesture); | - | ||||||||||||
| 672 | m_activeGestures.remove(gesture); | - | ||||||||||||
| 673 | } never executed: else {end of block | 0 | ||||||||||||
| 674 | cleanupGesturesForRemovedRecognizer(gesture); | - | ||||||||||||
| 675 | } never executed: end of block | 0 | ||||||||||||
| 676 | } | - | ||||||||||||
| 677 | - | |||||||||||||
| 678 | bool QGestureManager::gesturePending(QObject *o) | - | ||||||||||||
| 679 | { | - | ||||||||||||
| 680 | const QGestureManager *gm = QGestureManager::instance(); | - | ||||||||||||
| 681 | return never executed: gmreturn gm && gm->m_gestureOwners.key(o);
never executed: return gm && gm->m_gestureOwners.key(o); | 0 | ||||||||||||
| 682 | } | - | ||||||||||||
| 683 | - | |||||||||||||
| 684 | - | |||||||||||||
| 685 | - | |||||||||||||
| 686 | - | |||||||||||||
| 687 | - | |||||||||||||
| Switch to Source code | Preprocessed file |