qgesturemanager.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/kernel/qgesturemanager.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "private/qgesturemanager_p.h"-
41#include "private/qstandardgestures_p.h"-
42#include "private/qwidget_p.h"-
43#include "private/qgesture_p.h"-
44#include "private/qgraphicsitem_p.h"-
45#include "private/qevent_p.h"-
46#include "private/qapplication_p.h"-
47#include "private/qwidgetwindow_p.h"-
48#include "qgesture.h"-
49#include "qevent.h"-
50#include "qgraphicsitem.h"-
51-
52#ifdef Q_OS_OSX-
53#include "qmacgesturerecognizer_p.h"-
54#endif-
55#if defined(Q_DEAD_CODE_FROM_QT4_WIN) && !defined(QT_NO_NATIVE_GESTURES)-
56#include "qwinnativepangesturerecognizer_win_p.h"-
57#endif-
58-
59#include "qdebug.h"-
60#include <QtCore/QLoggingCategory>-
61-
62#ifndef QT_NO_GESTURES-
63-
64QT_BEGIN_NAMESPACE-
65-
66Q_LOGGING_CATEGORY(lcGestureManager, "qt.widgets.gestures")
never executed: return category;
0
67-
68#if !defined(Q_OS_OSX)-
69static inline int panTouchPoints()-
70{-
71 // Override by environment variable for testing.-
72 static const char panTouchPointVariable[] = "QT_PAN_TOUCHPOINTS";-
73 if (qEnvironmentVariableIsSet(panTouchPointVariable)) {
qEnvironmentVa...PointVariable)Description
TRUEnever evaluated
FALSEnever evaluated
0
74 bool ok;-
75 const int result = qEnvironmentVariableIntValue(panTouchPointVariable, &ok);-
76 if (ok && result >= 1)
okDescription
TRUEnever evaluated
FALSEnever evaluated
result >= 1Description
TRUEnever evaluated
FALSEnever evaluated
0
77 return result;
never executed: return result;
0
78 qWarning() << "Ignoring invalid value of " << panTouchPointVariable;-
79 }
never executed: end of block
0
80 // Pan should use 1 finger on a touch screen and 2 fingers on touch pads etc.-
81 // where 1 finger movements are used for mouse event synthetization. For now,-
82 // default to 2 until all classes inheriting QScrollArea are fixed to handle it-
83 // correctly.-
84 return 2;
never executed: return 2;
0
85}-
86#endif-
87-
88QGestureManager::QGestureManager(QObject *parent)-
89 : QObject(parent), state(NotGesture), m_lastCustomGestureId(Qt::CustomGesture)-
90{-
91 qRegisterMetaType<Qt::GestureState>();-
92-
93#if defined(Q_OS_OSX)-
94 registerGestureRecognizer(new QMacSwipeGestureRecognizer);-
95 registerGestureRecognizer(new QMacPinchGestureRecognizer);-
96 registerGestureRecognizer(new QMacPanGestureRecognizer);-
97#else-
98 registerGestureRecognizer(new QPanGestureRecognizer(panTouchPoints()));-
99 registerGestureRecognizer(new QPinchGestureRecognizer);-
100 registerGestureRecognizer(new QSwipeGestureRecognizer);-
101 registerGestureRecognizer(new QTapGestureRecognizer);-
102#endif-
103#if defined(Q_DEAD_CODE_FROM_QT4_WIN)-
104 #if !defined(QT_NO_NATIVE_GESTURES)-
105 if (QApplicationPrivate::HasTouchSupport)-
106 registerGestureRecognizer(new QWinNativePanGestureRecognizer);-
107 #endif-
108#else-
109 registerGestureRecognizer(new QTapAndHoldGestureRecognizer);-
110#endif-
111}
never executed: end of block
0
112-
113QGestureManager::~QGestureManager()-
114{-
115 qDeleteAll(m_recognizers);-
116 foreach (QGestureRecognizer *recognizer, m_obsoleteGestures.keys()) {-
117 qDeleteAll(m_obsoleteGestures.value(recognizer));-
118 delete recognizer;-
119 }
never executed: end of block
0
120 m_obsoleteGestures.clear();-
121}
never executed: end of block
0
122-
123Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *recognizer)-
124{-
125 QGesture *dummy = recognizer->create(0);-
126 if (Q_UNLIKELY(!dummy)) {
__builtin_expe...dummy), false)Description
TRUEnever evaluated
FALSEnever evaluated
0
127 qWarning("QGestureManager::registerGestureRecognizer: "-
128 "the recognizer fails to create a gesture object, skipping registration.");-
129 return Qt::GestureType(0);
never executed: return Qt::GestureType(0);
0
130 }-
131 Qt::GestureType type = dummy->gestureType();-
132 if (type == Qt::CustomGesture) {
type == Qt::CustomGestureDescription
TRUEnever evaluated
FALSEnever evaluated
0
133 // generate a new custom gesture id-
134 ++m_lastCustomGestureId;-
135 type = Qt::GestureType(m_lastCustomGestureId);-
136 }
never executed: end of block
0
137 m_recognizers.insertMulti(type, recognizer);-
138 delete dummy;-
139 return type;
never executed: return type;
0
140}-
141-
142void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type)-
143{-
144 QList<QGestureRecognizer *> list = m_recognizers.values(type);-
145 while (QGestureRecognizer *recognizer = m_recognizers.take(type)) {
QGestureRecogn...ers.take(type)Description
TRUEnever evaluated
FALSEnever evaluated
0
146 if (!m_obsoleteGestures.contains(recognizer)) {
!m_obsoleteGes...ns(recognizer)Description
TRUEnever evaluated
FALSEnever evaluated
0
147 // inserting even an empty QSet will cause the recognizer to be deleted on destruction of the manager-
148 m_obsoleteGestures.insert(recognizer, QSet<QGesture *>());-
149 }
never executed: end of block
0
150 }
never executed: end of block
0
151 foreach (QGesture *g, m_gestureToRecognizer.keys()) {-
152 QGestureRecognizer *recognizer = m_gestureToRecognizer.value(g);-
153 if (list.contains(recognizer)) {
list.contains(recognizer)Description
TRUEnever evaluated
FALSEnever evaluated
0
154 m_deletedRecognizers.insert(g, recognizer);-
155 }
never executed: end of block
0
156 }
never executed: end of block
0
157-
158 QMap<ObjectGesture, QList<QGesture *> >::const_iterator iter = m_objectGestures.constBegin();-
159 while (iter != m_objectGestures.constEnd()) {
iter != m_obje...res.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
160 ObjectGesture objectGesture = iter.key();-
161 if (objectGesture.gesture == type) {
objectGesture.gesture == typeDescription
TRUEnever evaluated
FALSEnever evaluated
0
162 foreach (QGesture *g, iter.value()) {-
163 if (QGestureRecognizer *recognizer = m_gestureToRecognizer.value(g)) {
QGestureRecogn...nizer.value(g)Description
TRUEnever evaluated
FALSEnever evaluated
0
164 m_gestureToRecognizer.remove(g);-
165 m_obsoleteGestures[recognizer].insert(g);-
166 }
never executed: end of block
0
167 }
never executed: end of block
0
168 }
never executed: end of block
0
169 ++iter;-
170 }
never executed: end of block
0
171}
never executed: end of block
0
172-
173void QGestureManager::cleanupCachedGestures(QObject *target, Qt::GestureType type)-
174{-
175 QMap<ObjectGesture, QList<QGesture *> >::Iterator iter = m_objectGestures.begin();-
176 while (iter != m_objectGestures.end()) {
iter != m_objectGestures.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
177 ObjectGesture objectGesture = iter.key();-
178 if (objectGesture.gesture == type && target == objectGesture.object) {
objectGesture.gesture == typeDescription
TRUEnever evaluated
FALSEnever evaluated
target == objectGesture.objectDescription
TRUEnever evaluated
FALSEnever evaluated
0
179 QSet<QGesture *> gestures = iter.value().toSet();-
180 for (QHash<QGestureRecognizer *, QSet<QGesture *> >::iterator-
181 it = m_obsoleteGestures.begin(), e = m_obsoleteGestures.end(); it != e; ++it) {
it != eDescription
TRUEnever evaluated
FALSEnever evaluated
0
182 it.value() -= gestures;-
183 }
never executed: end of block
0
184 foreach (QGesture *g, gestures) {-
185 m_deletedRecognizers.remove(g);-
186 m_gestureToRecognizer.remove(g);-
187 m_maybeGestures.remove(g);-
188 m_activeGestures.remove(g);-
189 m_gestureOwners.remove(g);-
190 m_gestureTargets.remove(g);-
191 m_gesturesToDelete.insert(g);-
192 }
never executed: end of block
0
193-
194 iter = m_objectGestures.erase(iter);-
195 } else {
never executed: end of block
0
196 ++iter;-
197 }
never executed: end of block
0
198 }-
199}
never executed: end of block
0
200-
201// get or create a QGesture object that will represent the state for a given object, used by the recognizer-
202QGesture *QGestureManager::getState(QObject *object, QGestureRecognizer *recognizer, Qt::GestureType type)-
203{-
204 // if the widget is being deleted we should be careful not to-
205 // create a new state, as it will create QWeakPointer which doesn't work-
206 // from the destructor.-
207 if (object->isWidgetType()) {
object->isWidgetType()Description
TRUEnever evaluated
FALSEnever evaluated
0
208 if (static_cast<QWidget *>(object)->d_func()->data.in_destructor)
static_cast<QW....in_destructorDescription
TRUEnever evaluated
FALSEnever evaluated
0
209 return 0;
never executed: return 0;
0
210 } else if (QGesture *g = qobject_cast<QGesture *>(object)) {
never executed: end of block
QGesture *g = ...ure *>(object)Description
TRUEnever evaluated
FALSEnever evaluated
0
211 return g;
never executed: return g;
0
212#ifndef QT_NO_GRAPHICSVIEW-
213 } else {-
214 Q_ASSERT(qobject_cast<QGraphicsObject *>(object));-
215 QGraphicsObject *graphicsObject = static_cast<QGraphicsObject *>(object);-
216 if (graphicsObject->QGraphicsItem::d_func()->inDestructor)
graphicsObject...->inDestructorDescription
TRUEnever evaluated
FALSEnever evaluated
0
217 return 0;
never executed: return 0;
0
218#endif-
219 }
never executed: end of block
0
220-
221 // check if the QGesture for this recognizer has already been created-
222 const auto states = m_objectGestures.value(QGestureManager::ObjectGesture(object, type));-
223 for (QGesture *state : states) {-
224 if (m_gestureToRecognizer.value(state) == recognizer)
m_gestureToRec... == recognizerDescription
TRUEnever evaluated
FALSEnever evaluated
0
225 return state;
never executed: return state;
0
226 }
never executed: end of block
0
227-
228 Q_ASSERT(recognizer);-
229 QGesture *state = recognizer->create(object);-
230 if (!state)
!stateDescription
TRUEnever evaluated
FALSEnever evaluated
0
231 return 0;
never executed: return 0;
0
232 state->setParent(this);-
233 if (state->gestureType() == Qt::CustomGesture) {
state->gesture...:CustomGestureDescription
TRUEnever evaluated
FALSEnever evaluated
0
234 // if the recognizer didn't fill in the gesture type, then this-
235 // is a custom gesture with autogenerated id and we fill it.-
236 state->d_func()->gestureType = type;-
237 if (lcGestureManager().isDebugEnabled())
lcGestureManag...DebugEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
238 state->setObjectName(QString::number((int)type));
never executed: state->setObjectName(QString::number((int)type));
0
239 }
never executed: end of block
0
240 m_objectGestures[QGestureManager::ObjectGesture(object, type)].append(state);-
241 m_gestureToRecognizer[state] = recognizer;-
242 m_gestureOwners[state] = object;-
243-
244 return state;
never executed: return state;
0
245}-
246-
247bool QGestureManager::filterEventThroughContexts(const QMultiMap<QObject *,-
248 Qt::GestureType> &contexts,-
249 QEvent *event)-
250{-
251 QSet<QGesture *> triggeredGestures;-
252 QSet<QGesture *> finishedGestures;-
253 QSet<QGesture *> newMaybeGestures;-
254 QSet<QGesture *> notGestures;-
255-
256 // TODO: sort contexts by the gesture type and check if one of the contexts-
257 // is already active.-
258-
259 bool consumeEventHint = false;-
260-
261 // filter the event through recognizers-
262 typedef QMultiMap<QObject *, Qt::GestureType>::const_iterator ContextIterator;-
263 ContextIterator contextEnd = contexts.end();-
264 for (ContextIterator context = contexts.begin(); context != contextEnd; ++context) {
context != contextEndDescription
TRUEnever evaluated
FALSEnever evaluated
0
265 Qt::GestureType gestureType = context.value();-
266 const QMap<Qt::GestureType, QGestureRecognizer *> &const_recognizers = m_recognizers;-
267 QMap<Qt::GestureType, QGestureRecognizer *>::const_iterator-
268 typeToRecognizerIterator = const_recognizers.lowerBound(gestureType),-
269 typeToRecognizerEnd = const_recognizers.upperBound(gestureType);-
270 for (; typeToRecognizerIterator != typeToRecognizerEnd; ++typeToRecognizerIterator) {
typeToRecogniz...oRecognizerEndDescription
TRUEnever evaluated
FALSEnever evaluated
0
271 QGestureRecognizer *recognizer = typeToRecognizerIterator.value();-
272 QObject *target = context.key();-
273 QGesture *state = getState(target, recognizer, gestureType);-
274 if (!state)
!stateDescription
TRUEnever evaluated
FALSEnever evaluated
0
275 continue;
never executed: continue;
0
276 QGestureRecognizer::Result recognizerResult = recognizer->recognize(state, target, event);-
277 QGestureRecognizer::Result recognizerState = recognizerResult & QGestureRecognizer::ResultState_Mask;-
278 QGestureRecognizer::Result resultHint = recognizerResult & QGestureRecognizer::ResultHint_Mask;-
279 if (recognizerState == QGestureRecognizer::TriggerGesture) {
recognizerStat...TriggerGestureDescription
TRUEnever evaluated
FALSEnever evaluated
0
280 qCDebug(lcGestureManager) << "QGestureManager:Recognizer: gesture triggered: " << state << event;
never executed: QMessageLogger(__FILE__, 280, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager:Recognizer: gesture triggered: " << state << event;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
281 triggeredGestures << state;-
282 } else if (recognizerState == QGestureRecognizer::FinishGesture) {
never executed: end of block
recognizerStat...:FinishGestureDescription
TRUEnever evaluated
FALSEnever evaluated
0
283 qCDebug(lcGestureManager) << "QGestureManager:Recognizer: gesture finished: " << state << event;
never executed: QMessageLogger(__FILE__, 283, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager:Recognizer: gesture finished: " << state << event;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
284 finishedGestures << state;-
285 } else if (recognizerState == QGestureRecognizer::MayBeGesture) {
never executed: end of block
recognizerStat...::MayBeGestureDescription
TRUEnever evaluated
FALSEnever evaluated
0
286 qCDebug(lcGestureManager) << "QGestureManager:Recognizer: maybe gesture: " << state << event;
never executed: QMessageLogger(__FILE__, 286, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager:Recognizer: maybe gesture: " << state << event;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
287 newMaybeGestures << state;-
288 } else if (recognizerState == QGestureRecognizer::CancelGesture) {
never executed: end of block
recognizerStat...:CancelGestureDescription
TRUEnever evaluated
FALSEnever evaluated
0
289 qCDebug(lcGestureManager) << "QGestureManager:Recognizer: not gesture: " << state << event;
never executed: QMessageLogger(__FILE__, 289, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager:Recognizer: not gesture: " << state << event;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
290 notGestures << state;-
291 } else if (recognizerState == QGestureRecognizer::Ignore) {
never executed: end of block
recognizerStat...gnizer::IgnoreDescription
TRUEnever evaluated
FALSEnever evaluated
0
292 qCDebug(lcGestureManager) << "QGestureManager:Recognizer: ignored the event: " << state << event;
never executed: QMessageLogger(__FILE__, 292, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager:Recognizer: ignored the event: " << state << event;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
293 } else {
never executed: end of block
0
294 qCDebug(lcGestureManager) << "QGestureManager:Recognizer: hm, lets assume the recognizer"
never executed: QMessageLogger(__FILE__, 294, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager:Recognizer: hm, lets assume the recognizer" << "ignored the event: " << state << event;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
295 << "ignored the event: " << state << event;
never executed: QMessageLogger(__FILE__, 294, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager:Recognizer: hm, lets assume the recognizer" << "ignored the event: " << state << event;
0
296 }
never executed: end of block
0
297 if (resultHint & QGestureRecognizer::ConsumeEventHint) {
resultHint & Q...nsumeEventHintDescription
TRUEnever evaluated
FALSEnever evaluated
0
298 qCDebug(lcGestureManager) << "QGestureManager: we were asked to consume the event: "
never executed: QMessageLogger(__FILE__, 298, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager: we were asked to consume the event: " << state << event;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
299 << state << event;
never executed: QMessageLogger(__FILE__, 298, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager: we were asked to consume the event: " << state << event;
0
300 consumeEventHint = true;-
301 }
never executed: end of block
0
302 }
never executed: end of block
0
303 }
never executed: end of block
0
304 if (!triggeredGestures.isEmpty() || !finishedGestures.isEmpty()
!triggeredGestures.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
!finishedGestures.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
305 || !newMaybeGestures.isEmpty() || !notGestures.isEmpty()) {
!newMaybeGestures.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
!notGestures.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
306 QSet<QGesture *> startedGestures = triggeredGestures - m_activeGestures;-
307 triggeredGestures &= m_activeGestures;-
308-
309 // check if a running gesture switched back to maybe state-
310 QSet<QGesture *> activeToMaybeGestures = m_activeGestures & newMaybeGestures;-
311-
312 // check if a maybe gesture switched to canceled - reset it but don't send an event-
313 QSet<QGesture *> maybeToCanceledGestures = m_maybeGestures & notGestures;-
314-
315 // check if a running gesture switched back to not gesture state,-
316 // i.e. were canceled-
317 QSet<QGesture *> canceledGestures = m_activeGestures & notGestures;-
318-
319 // new gestures in maybe state-
320 m_maybeGestures += newMaybeGestures;-
321-
322 // gestures that were in maybe state-
323 QSet<QGesture *> notMaybeGestures = (startedGestures | triggeredGestures-
324 | finishedGestures | canceledGestures-
325 | notGestures);-
326 m_maybeGestures -= notMaybeGestures;-
327-
328 Q_ASSERT((startedGestures & finishedGestures).isEmpty());-
329 Q_ASSERT((startedGestures & newMaybeGestures).isEmpty());-
330 Q_ASSERT((startedGestures & canceledGestures).isEmpty());-
331 Q_ASSERT((finishedGestures & newMaybeGestures).isEmpty());-
332 Q_ASSERT((finishedGestures & canceledGestures).isEmpty());-
333 Q_ASSERT((canceledGestures & newMaybeGestures).isEmpty());-
334-
335 QSet<QGesture *> notStarted = finishedGestures - m_activeGestures;-
336 if (!notStarted.isEmpty()) {
!notStarted.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
337 // there are some gestures that claim to be finished, but never started.-
338 // probably those are "singleshot" gestures so we'll fake the started state.-
339 foreach (QGesture *gesture, notStarted)-
340 gesture->d_func()->state = Qt::GestureStarted;
never executed: gesture->d_func()->state = Qt::GestureStarted;
0
341 QSet<QGesture *> undeliveredGestures;-
342 deliverEvents(notStarted, &undeliveredGestures);-
343 finishedGestures -= undeliveredGestures;-
344 }
never executed: end of block
0
345-
346 m_activeGestures += startedGestures;-
347 // sanity check: all triggered gestures should already be in active gestures list-
348 Q_ASSERT((m_activeGestures & triggeredGestures).size() == triggeredGestures.size());-
349 m_activeGestures -= finishedGestures;-
350 m_activeGestures -= activeToMaybeGestures;-
351 m_activeGestures -= canceledGestures;-
352-
353 // set the proper gesture state on each gesture-
354 foreach (QGesture *gesture, startedGestures)-
355 gesture->d_func()->state = Qt::GestureStarted;
never executed: gesture->d_func()->state = Qt::GestureStarted;
0
356 foreach (QGesture *gesture, triggeredGestures)-
357 gesture->d_func()->state = Qt::GestureUpdated;
never executed: gesture->d_func()->state = Qt::GestureUpdated;
0
358 foreach (QGesture *gesture, finishedGestures)-
359 gesture->d_func()->state = Qt::GestureFinished;
never executed: gesture->d_func()->state = Qt::GestureFinished;
0
360 foreach (QGesture *gesture, canceledGestures)-
361 gesture->d_func()->state = Qt::GestureCanceled;
never executed: gesture->d_func()->state = Qt::GestureCanceled;
0
362 foreach (QGesture *gesture, activeToMaybeGestures)-
363 gesture->d_func()->state = Qt::GestureFinished;
never executed: gesture->d_func()->state = Qt::GestureFinished;
0
364-
365 if (!m_activeGestures.isEmpty() || !m_maybeGestures.isEmpty() ||
!m_activeGestures.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
!m_maybeGestures.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
366 !startedGestures.isEmpty() || !triggeredGestures.isEmpty() ||
!startedGestures.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
!triggeredGestures.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
367 !finishedGestures.isEmpty() || !canceledGestures.isEmpty()) {
!finishedGestures.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
!canceledGestures.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
368 qCDebug(lcGestureManager) << "QGestureManager::filterEventThroughContexts:"
never executed: QMessageLogger(__FILE__, 368, __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;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
369 << "\n\tactiveGestures:" << m_activeGestures
never executed: QMessageLogger(__FILE__, 368, __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
370 << "\n\tmaybeGestures:" << m_maybeGestures
never executed: QMessageLogger(__FILE__, 368, __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
371 << "\n\tstarted:" << startedGestures
never executed: QMessageLogger(__FILE__, 368, __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
372 << "\n\ttriggered:" << triggeredGestures
never executed: QMessageLogger(__FILE__, 368, __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
373 << "\n\tfinished:" << finishedGestures
never executed: QMessageLogger(__FILE__, 368, __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
374 << "\n\tcanceled:" << canceledGestures
never executed: QMessageLogger(__FILE__, 368, __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
375 << "\n\tmaybe-canceled:" << maybeToCanceledGestures;
never executed: QMessageLogger(__FILE__, 368, __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
376 }
never executed: end of block
0
377-
378 QSet<QGesture *> undeliveredGestures;-
379 deliverEvents(startedGestures+triggeredGestures+finishedGestures+canceledGestures,-
380 &undeliveredGestures);-
381-
382 foreach (QGesture *g, startedGestures) {-
383 if (undeliveredGestures.contains(g))
undeliveredGes...es.contains(g)Description
TRUEnever evaluated
FALSEnever evaluated
0
384 continue;
never executed: continue;
0
385 if (g->gestureCancelPolicy() == QGesture::CancelAllInContext) {
g->gestureCanc...elAllInContextDescription
TRUEnever evaluated
FALSEnever evaluated
0
386 qCDebug(lcGestureManager) << "lets try to cancel some";
never executed: QMessageLogger(__FILE__, 386, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "lets try to cancel some";
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
387 // find gestures in context in Qt::GestureStarted or Qt::GestureUpdated state and cancel them-
388 cancelGesturesForChildren(g);-
389 }
never executed: end of block
0
390 }
never executed: end of block
0
391-
392 m_activeGestures -= undeliveredGestures;-
393-
394 // reset gestures that ended-
395 QSet<QGesture *> endedGestures =-
396 finishedGestures + canceledGestures + undeliveredGestures + maybeToCanceledGestures;-
397 foreach (QGesture *gesture, endedGestures) {-
398 recycle(gesture);-
399 m_gestureTargets.remove(gesture);-
400 }
never executed: end of block
0
401 }
never executed: end of block
0
402 //Clean up the Gestures-
403 qDeleteAll(m_gesturesToDelete);-
404 m_gesturesToDelete.clear();-
405-
406 return consumeEventHint;
never executed: return consumeEventHint;
0
407}-
408-
409// Cancel all gestures of children of the widget that original is associated with-
410void QGestureManager::cancelGesturesForChildren(QGesture *original)-
411{-
412 Q_ASSERT(original);-
413 QWidget *originatingWidget = m_gestureTargets.value(original);-
414 Q_ASSERT(originatingWidget);-
415 if (!originatingWidget)
!originatingWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
416 return;
never executed: return;
0
417-
418 // iterate over all active gestures and all maybe gestures-
419 // for each find the owner-
420 // if the owner is part of our sub-hierarchy, cancel it.-
421-
422 QSet<QGesture*> cancelledGestures;-
423 QSet<QGesture*>::Iterator iter = m_activeGestures.begin();-
424 while (iter != m_activeGestures.end()) {
iter != m_activeGestures.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
425 QWidget *widget = m_gestureTargets.value(*iter);-
426 // note that we don't touch the gestures for our originatingWidget-
427 if (widget != originatingWidget && originatingWidget->isAncestorOf(widget)) {
widget != originatingWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
originatingWid...storOf(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
428 qCDebug(lcGestureManager) << " found a gesture to cancel" << (*iter);
never executed: QMessageLogger(__FILE__, 428, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << " found a gesture to cancel" << (*iter);
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
429 (*iter)->d_func()->state = Qt::GestureCanceled;-
430 cancelledGestures << *iter;-
431 iter = m_activeGestures.erase(iter);-
432 } else {
never executed: end of block
0
433 ++iter;-
434 }
never executed: end of block
0
435 }-
436-
437 // TODO handle 'maybe' gestures too-
438-
439 // sort them per target widget by cherry picking from almostCanceledGestures and delivering-
440 QSet<QGesture *> almostCanceledGestures = cancelledGestures;-
441 while (!almostCanceledGestures.isEmpty()) {
!almostCancele...ures.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
442 QWidget *target = 0;-
443 QSet<QGesture*> gestures;-
444 iter = almostCanceledGestures.begin();-
445 // sort per target widget-
446 while (iter != almostCanceledGestures.end()) {
iter != almost...Gestures.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
447 QWidget *widget = m_gestureTargets.value(*iter);-
448 if (target == 0)
target == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
449 target = widget;
never executed: target = widget;
0
450 if (target == widget) {
target == widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
451 gestures << *iter;-
452 iter = almostCanceledGestures.erase(iter);-
453 } else {
never executed: end of block
0
454 ++iter;-
455 }
never executed: end of block
0
456 }-
457 Q_ASSERT(target);-
458-
459 QSet<QGesture*> undeliveredGestures;-
460 deliverEvents(gestures, &undeliveredGestures);-
461 }
never executed: end of block
0
462-
463 for (iter = cancelledGestures.begin(); iter != cancelledGestures.end(); ++iter)
iter != cancel...Gestures.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
464 recycle(*iter);
never executed: recycle(*iter);
0
465}
never executed: end of block
0
466-
467void QGestureManager::cleanupGesturesForRemovedRecognizer(QGesture *gesture)-
468{-
469 QGestureRecognizer *recognizer = m_deletedRecognizers.value(gesture);-
470 if(!recognizer) //The Gesture is removed while in the even loop, so the recognizers for this gestures was removed
!recognizerDescription
TRUEnever evaluated
FALSEnever evaluated
0
471 return;
never executed: return;
0
472 m_deletedRecognizers.remove(gesture);-
473 if (m_deletedRecognizers.keys(recognizer).isEmpty()) {
m_deletedRecog...zer).isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
474 // no more active gestures, cleanup!-
475 qDeleteAll(m_obsoleteGestures.value(recognizer));-
476 m_obsoleteGestures.remove(recognizer);-
477 delete recognizer;-
478 }
never executed: end of block
0
479}
never executed: end of block
0
480-
481// return true if accepted (consumed)-
482bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event)-
483{-
484 QMap<Qt::GestureType, int> types;-
485 QMultiMap<QObject *, Qt::GestureType> contexts;-
486 QWidget *w = receiver;-
487 typedef QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator ContextIterator;-
488 if (!w->d_func()->gestureContext.isEmpty()) {
!w->d_func()->...text.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
489 for(ContextIterator it = w->d_func()->gestureContext.constBegin(),-
490 e = w->d_func()->gestureContext.constEnd(); it != e; ++it) {
it != eDescription
TRUEnever evaluated
FALSEnever evaluated
0
491 types.insert(it.key(), 0);-
492 contexts.insertMulti(w, it.key());-
493 }
never executed: end of block
0
494 }
never executed: end of block
0
495 // find all gesture contexts for the widget tree-
496 w = w->isWindow() ? 0 : w->parentWidget();
w->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
497 while (w)
wDescription
TRUEnever evaluated
FALSEnever evaluated
0
498 {-
499 for (ContextIterator it = w->d_func()->gestureContext.constBegin(),-
500 e = w->d_func()->gestureContext.constEnd(); it != e; ++it) {
it != eDescription
TRUEnever evaluated
FALSEnever evaluated
0
501 if (!(it.value() & Qt::DontStartGestureOnChildren)) {
!(it.value() &...ureOnChildren)Description
TRUEnever evaluated
FALSEnever evaluated
0
502 if (!types.contains(it.key())) {
!types.contains(it.key())Description
TRUEnever evaluated
FALSEnever evaluated
0
503 types.insert(it.key(), 0);-
504 contexts.insertMulti(w, it.key());-
505 }
never executed: end of block
0
506 }
never executed: end of block
0
507 }
never executed: end of block
0
508 if (w->isWindow())
w->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
509 break;
never executed: break;
0
510 w = w->parentWidget();-
511 }
never executed: end of block
0
512 return contexts.isEmpty() ? false : filterEventThroughContexts(contexts, event);
never executed: return contexts.isEmpty() ? false : filterEventThroughContexts(contexts, event);
0
513}-
514-
515#ifndef QT_NO_GRAPHICSVIEW-
516bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event)-
517{-
518 QMap<Qt::GestureType, int> types;-
519 QMultiMap<QObject *, Qt::GestureType> contexts;-
520 QGraphicsObject *item = receiver;-
521 if (!item->QGraphicsItem::d_func()->gestureContext.isEmpty()) {
!item->QGraphi...text.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
522 typedef QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator ContextIterator;-
523 for(ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.constBegin(),-
524 e = item->QGraphicsItem::d_func()->gestureContext.constEnd(); it != e; ++it) {
it != eDescription
TRUEnever evaluated
FALSEnever evaluated
0
525 types.insert(it.key(), 0);-
526 contexts.insertMulti(item, it.key());-
527 }
never executed: end of block
0
528 }
never executed: end of block
0
529 // find all gesture contexts for the graphics object tree-
530 item = item->parentObject();-
531 while (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
532 {-
533 typedef QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator ContextIterator;-
534 for (ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.constBegin(),-
535 e = item->QGraphicsItem::d_func()->gestureContext.constEnd(); it != e; ++it) {
it != eDescription
TRUEnever evaluated
FALSEnever evaluated
0
536 if (!(it.value() & Qt::DontStartGestureOnChildren)) {
!(it.value() &...ureOnChildren)Description
TRUEnever evaluated
FALSEnever evaluated
0
537 if (!types.contains(it.key())) {
!types.contains(it.key())Description
TRUEnever evaluated
FALSEnever evaluated
0
538 types.insert(it.key(), 0);-
539 contexts.insertMulti(item, it.key());-
540 }
never executed: end of block
0
541 }
never executed: end of block
0
542 }
never executed: end of block
0
543 item = item->parentObject();-
544 }
never executed: end of block
0
545 return contexts.isEmpty() ? false : filterEventThroughContexts(contexts, event);
never executed: return contexts.isEmpty() ? false : filterEventThroughContexts(contexts, event);
0
546}-
547#endif-
548-
549bool QGestureManager::filterEvent(QObject *receiver, QEvent *event)-
550{-
551 // if the receiver is actually a widget, we need to call the correct event-
552 // filter method.-
553 QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(receiver);-
554-
555 if (widgetWindow && widgetWindow->widget())
widgetWindowDescription
TRUEnever evaluated
FALSEnever evaluated
widgetWindow->widget()Description
TRUEnever evaluated
FALSEnever evaluated
0
556 return filterEvent(widgetWindow->widget(), event);
never executed: return filterEvent(widgetWindow->widget(), event);
0
557-
558 QGesture *state = qobject_cast<QGesture *>(receiver);-
559 if (!state || !m_gestureToRecognizer.contains(state))
!stateDescription
TRUEnever evaluated
FALSEnever evaluated
!m_gestureToRe...ontains(state)Description
TRUEnever evaluated
FALSEnever evaluated
0
560 return false;
never executed: return false;
0
561 QMultiMap<QObject *, Qt::GestureType> contexts;-
562 contexts.insert(state, state->gestureType());-
563 return filterEventThroughContexts(contexts, event);
never executed: return filterEventThroughContexts(contexts, event);
0
564}-
565-
566void QGestureManager::getGestureTargets(const QSet<QGesture*> &gestures,-
567 QHash<QWidget *, QList<QGesture *> > *conflicts,-
568 QHash<QWidget *, QList<QGesture *> > *normal)-
569{-
570 typedef QHash<Qt::GestureType, QHash<QWidget *, QGesture *> > GestureByTypes;-
571 GestureByTypes gestureByTypes;-
572-
573 // sort gestures by types-
574 foreach (QGesture *gesture, gestures) {-
575 QWidget *receiver = m_gestureTargets.value(gesture, 0);-
576 Q_ASSERT(receiver);-
577 if (receiver)
receiverDescription
TRUEnever evaluated
FALSEnever evaluated
0
578 gestureByTypes[gesture->gestureType()].insert(receiver, gesture);
never executed: gestureByTypes[gesture->gestureType()].insert(receiver, gesture);
0
579 }
never executed: end of block
0
580-
581 // for each gesture type-
582 for (GestureByTypes::const_iterator git = gestureByTypes.cbegin(), gend = gestureByTypes.cend(); git != gend; ++git) {
git != gendDescription
TRUEnever evaluated
FALSEnever evaluated
0
583 const QHash<QWidget *, QGesture *> &gestures = git.value();-
584 for (QHash<QWidget *, QGesture *>::const_iterator wit = gestures.cbegin(), wend = gestures.cend(); wit != wend; ++wit) {
wit != wendDescription
TRUEnever evaluated
FALSEnever evaluated
0
585 QWidget *widget = wit.key();-
586 QWidget *w = widget->parentWidget();-
587 while (w) {
wDescription
TRUEnever evaluated
FALSEnever evaluated
0
588 QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator it-
589 = w->d_func()->gestureContext.constFind(git.key());-
590 if (it != w->d_func()->gestureContext.constEnd()) {
it != w->d_fun...ext.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
591 // i.e. 'w' listens to gesture 'type'-
592 if (!(it.value() & Qt::DontStartGestureOnChildren) && w != widget) {
!(it.value() &...ureOnChildren)Description
TRUEnever evaluated
FALSEnever evaluated
w != widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
593 // conflicting gesture!-
594 (*conflicts)[widget].append(wit.value());-
595 break;
never executed: break;
0
596 }-
597 }
never executed: end of block
0
598 if (w->isWindow()) {
w->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
599 w = 0;-
600 break;
never executed: break;
0
601 }-
602 w = w->parentWidget();-
603 }
never executed: end of block
0
604 if (!w)
!wDescription
TRUEnever evaluated
FALSEnever evaluated
0
605 (*normal)[widget].append(wit.value());
never executed: (*normal)[widget].append(wit.value());
0
606 }
never executed: end of block
0
607 }
never executed: end of block
0
608}
never executed: end of block
0
609-
610void QGestureManager::deliverEvents(const QSet<QGesture *> &gestures,-
611 QSet<QGesture *> *undeliveredGestures)-
612{-
613 if (gestures.isEmpty())
gestures.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
614 return;
never executed: return;
0
615-
616 typedef QHash<QWidget *, QList<QGesture *> > GesturesPerWidget;-
617 GesturesPerWidget conflictedGestures;-
618 GesturesPerWidget normalStartedGestures;-
619-
620 QSet<QGesture *> startedGestures;-
621 // first figure out the initial receivers of gestures-
622 for (QSet<QGesture *>::const_iterator it = gestures.begin(),-
623 e = gestures.end(); it != e; ++it) {
it != eDescription
TRUEnever evaluated
FALSEnever evaluated
0
624 QGesture *gesture = *it;-
625 QWidget *target = m_gestureTargets.value(gesture, 0);-
626 if (!target) {
!targetDescription
TRUEnever evaluated
FALSEnever evaluated
0
627 // the gesture has just started and doesn't have a target yet.-
628 Q_ASSERT(gesture->state() == Qt::GestureStarted);-
629 if (gesture->hasHotSpot()) {
gesture->hasHotSpot()Description
TRUEnever evaluated
FALSEnever evaluated
0
630 // guess the target widget using the hotspot of the gesture-
631 QPoint pt = gesture->hotSpot().toPoint();-
632 if (QWidget *topLevel = QApplication::topLevelAt(pt)) {
QWidget *topLe...topLevelAt(pt)Description
TRUEnever evaluated
FALSEnever evaluated
0
633 QWidget *child = topLevel->childAt(topLevel->mapFromGlobal(pt));-
634 target = child ? child : topLevel;
childDescription
TRUEnever evaluated
FALSEnever evaluated
0
635 }
never executed: end of block
0
636 } else {
never executed: end of block
0
637 // or use the context of the gesture-
638 QObject *context = m_gestureOwners.value(gesture, 0);-
639 if (context->isWidgetType())
context->isWidgetType()Description
TRUEnever evaluated
FALSEnever evaluated
0
640 target = static_cast<QWidget *>(context);
never executed: target = static_cast<QWidget *>(context);
0
641 }
never executed: end of block
0
642 if (target)
targetDescription
TRUEnever evaluated
FALSEnever evaluated
0
643 m_gestureTargets.insert(gesture, target);
never executed: m_gestureTargets.insert(gesture, target);
0
644 }
never executed: end of block
0
645-
646 Qt::GestureType gestureType = gesture->gestureType();-
647 Q_ASSERT(gestureType != Qt::CustomGesture);-
648 Q_UNUSED(gestureType);-
649-
650 if (Q_UNLIKELY(!target)) {
__builtin_expe...arget), false)Description
TRUEnever evaluated
FALSEnever evaluated
0
651 qCDebug(lcGestureManager) << "QGestureManager::deliverEvent: could not find the target for gesture"
never executed: QMessageLogger(__FILE__, 651, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::deliverEvent: could not find the target for gesture" << gesture->gestureType();
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
652 << gesture->gestureType();
never executed: QMessageLogger(__FILE__, 651, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::deliverEvent: could not find the target for gesture" << gesture->gestureType();
0
653 qWarning("QGestureManager::deliverEvent: could not find the target for gesture");-
654 undeliveredGestures->insert(gesture);-
655 } else {
never executed: end of block
0
656 if (gesture->state() == Qt::GestureStarted) {
gesture->state...GestureStartedDescription
TRUEnever evaluated
FALSEnever evaluated
0
657 startedGestures.insert(gesture);-
658 } else {
never executed: end of block
0
659 normalStartedGestures[target].append(gesture);-
660 }
never executed: end of block
0
661 }-
662 }-
663-
664 getGestureTargets(startedGestures, &conflictedGestures, &normalStartedGestures);-
665 qCDebug(lcGestureManager) << "QGestureManager::deliverEvents:"
never executed: QMessageLogger(__FILE__, 665, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::deliverEvents:" << "\nstarted: " << startedGestures << "\nconflicted: " << conflictedGestures << "\nnormal: " << normalStartedGestures << "\n";
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
666 << "\nstarted: " << startedGestures
never executed: QMessageLogger(__FILE__, 665, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::deliverEvents:" << "\nstarted: " << startedGestures << "\nconflicted: " << conflictedGestures << "\nnormal: " << normalStartedGestures << "\n";
0
667 << "\nconflicted: " << conflictedGestures
never executed: QMessageLogger(__FILE__, 665, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::deliverEvents:" << "\nstarted: " << startedGestures << "\nconflicted: " << conflictedGestures << "\nnormal: " << normalStartedGestures << "\n";
0
668 << "\nnormal: " << normalStartedGestures
never executed: QMessageLogger(__FILE__, 665, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::deliverEvents:" << "\nstarted: " << startedGestures << "\nconflicted: " << conflictedGestures << "\nnormal: " << normalStartedGestures << "\n";
0
669 << "\n";
never executed: QMessageLogger(__FILE__, 665, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::deliverEvents:" << "\nstarted: " << startedGestures << "\nconflicted: " << conflictedGestures << "\nnormal: " << normalStartedGestures << "\n";
0
670-
671 // if there are conflicting gestures, send the GestureOverride event-
672 for (GesturesPerWidget::const_iterator it = conflictedGestures.constBegin(),-
673 e = conflictedGestures.constEnd(); it != e; ++it) {
it != eDescription
TRUEnever evaluated
FALSEnever evaluated
0
674 QWidget *receiver = it.key();-
675 QList<QGesture *> gestures = it.value();-
676 qCDebug(lcGestureManager) << "QGestureManager::deliverEvents: sending GestureOverride to"
never executed: QMessageLogger(__FILE__, 676, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::deliverEvents: sending GestureOverride to" << receiver << "gestures:" << gestures;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
677 << receiver
never executed: QMessageLogger(__FILE__, 676, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::deliverEvents: sending GestureOverride to" << receiver << "gestures:" << gestures;
0
678 << "gestures:" << gestures;
never executed: QMessageLogger(__FILE__, 676, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::deliverEvents: sending GestureOverride to" << receiver << "gestures:" << gestures;
0
679 QGestureEvent event(gestures);-
680 event.t = QEvent::GestureOverride;-
681 // mark event and individual gestures as ignored-
682 event.ignore();-
683 foreach(QGesture *g, gestures)-
684 event.setAccepted(g, false);
never executed: event.setAccepted(g, false);
0
685-
686 QApplication::sendEvent(receiver, &event);-
687 bool eventAccepted = event.isAccepted();-
688 const auto eventGestures = event.gestures();-
689 for (QGesture *gesture : eventGestures) {-
690 if (eventAccepted || event.isAccepted(gesture)) {
eventAcceptedDescription
TRUEnever evaluated
FALSEnever evaluated
event.isAccepted(gesture)Description
TRUEnever evaluated
FALSEnever evaluated
0
691 QWidget *w = event.m_targetWidgets.value(gesture->gestureType(), 0);-
692 Q_ASSERT(w);-
693 qCDebug(lcGestureManager) << "override event: gesture was accepted:" << gesture << w;
never executed: QMessageLogger(__FILE__, 693, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "override event: gesture was accepted:" << gesture << w;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
694 QList<QGesture *> &gestures = normalStartedGestures[w];-
695 gestures.append(gesture);-
696 // override the target-
697 m_gestureTargets[gesture] = w;-
698 } else {
never executed: end of block
0
699 qCDebug(lcGestureManager) << "override event: gesture wasn't accepted. putting back:" << gesture;
never executed: QMessageLogger(__FILE__, 699, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "override event: gesture wasn't accepted. putting back:" << gesture;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
700 QList<QGesture *> &gestures = normalStartedGestures[receiver];-
701 gestures.append(gesture);-
702 }
never executed: end of block
0
703 }-
704 }
never executed: end of block
0
705-
706 // delivering gestures that are not in conflicted state-
707 for (GesturesPerWidget::const_iterator it = normalStartedGestures.constBegin(),-
708 e = normalStartedGestures.constEnd(); it != e; ++it) {
it != eDescription
TRUEnever evaluated
FALSEnever evaluated
0
709 if (!it.value().isEmpty()) {
!it.value().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
710 qCDebug(lcGestureManager) << "QGestureManager::deliverEvents: sending to" << it.key()
never executed: QMessageLogger(__FILE__, 710, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::deliverEvents: sending to" << it.key() << "gestures:" << it.value();
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
711 << "gestures:" << it.value();
never executed: QMessageLogger(__FILE__, 710, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "QGestureManager::deliverEvents: sending to" << it.key() << "gestures:" << it.value();
0
712 QGestureEvent event(it.value());-
713 QApplication::sendEvent(it.key(), &event);-
714 bool eventAccepted = event.isAccepted();-
715 const auto eventGestures = event.gestures();-
716 for (QGesture *gesture : eventGestures) {-
717 if (gesture->state() == Qt::GestureStarted &&
gesture->state...GestureStartedDescription
TRUEnever evaluated
FALSEnever evaluated
0
718 (eventAccepted || event.isAccepted(gesture))) {
eventAcceptedDescription
TRUEnever evaluated
FALSEnever evaluated
event.isAccepted(gesture)Description
TRUEnever evaluated
FALSEnever evaluated
0
719 QWidget *w = event.m_targetWidgets.value(gesture->gestureType(), 0);-
720 Q_ASSERT(w);-
721 qCDebug(lcGestureManager) << "started gesture was delivered and accepted by" << w;
never executed: QMessageLogger(__FILE__, 721, __PRETTY_FUNCTION__, lcGestureManager().categoryName()).debug() << "started gesture was delivered and accepted by" << w;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
722 m_gestureTargets[gesture] = w;-
723 }
never executed: end of block
0
724 }
never executed: end of block
0
725 }
never executed: end of block
0
726 }
never executed: end of block
0
727}
never executed: end of block
0
728-
729void QGestureManager::recycle(QGesture *gesture)-
730{-
731 QGestureRecognizer *recognizer = m_gestureToRecognizer.value(gesture, 0);-
732 if (recognizer) {
recognizerDescription
TRUEnever evaluated
FALSEnever evaluated
0
733 gesture->setGestureCancelPolicy(QGesture::CancelNone);-
734 recognizer->reset(gesture);-
735 m_activeGestures.remove(gesture);-
736 } else {
never executed: end of block
0
737 cleanupGesturesForRemovedRecognizer(gesture);-
738 }
never executed: end of block
0
739}-
740-
741bool QGestureManager::gesturePending(QObject *o)-
742{-
743 const QGestureManager *gm = QGestureManager::instance();-
744 return gm && gm->m_gestureOwners.key(o);
never executed: return gm && gm->m_gestureOwners.key(o);
0
745}-
746-
747QT_END_NAMESPACE-
748-
749#endif // QT_NO_GESTURES-
750-
751#include "moc_qgesturemanager_p.cpp"-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9