Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qgesturemanager_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QGESTUREMANAGER_P_H
6#define QGESTUREMANAGER_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists for the convenience
13// of other Qt classes. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtWidgets/private/qtwidgetsglobal_p.h>
20#include "qobject.h"
21#include "qbasictimer.h"
22#include "private/qwidget_p.h"
24
25#include <QtCore/qpointer.h>
26
27#ifndef QT_NO_GESTURES
28
29#include <functional>
30
31QT_BEGIN_NAMESPACE
32
33class QBasicTimer;
34class QGraphicsObject;
36{
38public:
41
42 Qt::GestureType registerGestureRecognizer(QGestureRecognizer *recognizer);
43 void unregisterGestureRecognizer(Qt::GestureType type);
44
45 bool filterEvent(QWidget *receiver, QEvent *event);
46 bool filterEvent(QObject *receiver, QEvent *event);
47#if QT_CONFIG(graphicsview)
49#endif // QT_CONFIG(graphicsview)
50
52
53 static QGestureManager *instance(InstanceCreation ic = ForceCreation); // implemented in qapplication.cpp
54 static bool gesturePending(QObject *o);
55
56 void cleanupCachedGestures(QObject *target, Qt::GestureType type);
57
58 void recycle(QGesture *gesture);
59
60protected:
61 bool filterEventThroughContexts(const QMultiMap<QObject *, Qt::GestureType> &contexts,
62 QEvent *event);
63
64private:
65 QMultiMap<Qt::GestureType, QGestureRecognizer *> m_recognizers;
66
67 QSet<QGesture *> m_activeGestures;
68 QSet<QGesture *> m_maybeGestures;
69
70 struct ObjectGesture
71 {
72 QObject* object;
73 Qt::GestureType gesture;
74
75 ObjectGesture(QObject *o, const Qt::GestureType &g) : object(o), gesture(g) { }
76 inline bool operator<(const ObjectGesture &rhs) const
77 {
78 if (std::less<QObject *>{}(object, rhs.object))
79 return true;
80 if (object == rhs.object)
81 return gesture < rhs.gesture;
82 return false;
83 }
84 };
85
86 QMap<ObjectGesture, QList<QGesture *> > m_objectGestures;
87 QHash<QGesture *, QGestureRecognizer *> m_gestureToRecognizer;
88 QHash<QGesture *, QObject *> m_gestureOwners;
89
90 QHash<QGesture *, QPointer<QWidget> > m_gestureTargets;
91
92 int m_lastCustomGestureId;
93
95 QHash<QGesture *, QGestureRecognizer *> m_deletedRecognizers;
96 QSet<QGesture *> m_gesturesToDelete;
97 void cleanupGesturesForRemovedRecognizer(QGesture *gesture);
98
99 QGesture *getState(QObject *widget, QGestureRecognizer *recognizer,
100 Qt::GestureType gesture);
101 void deliverEvents(const QSet<QGesture *> &gestures,
102 QSet<QGesture *> *undeliveredGestures);
103 void getGestureTargets(const QSet<QGesture*> &gestures,
104 QHash<QWidget *, QList<QGesture *> > *conflicts,
105 QHash<QWidget *, QList<QGesture *> > *normal);
106
107 void cancelGesturesForChildren(QGesture *originatingGesture);
108};
109
110QT_END_NAMESPACE
111
112#endif // QT_NO_GESTURES
113
114#endif // QGESTUREMANAGER_P_H
void recycle(QGesture *gesture)
Qt::GestureType registerGestureRecognizer(QGestureRecognizer *recognizer)
bool filterEvent(QObject *receiver, QEvent *event)
bool filterEventThroughContexts(const QMultiMap< QObject *, Qt::GestureType > &contexts, QEvent *event)
static bool gesturePending(QObject *o)
bool filterEvent(QWidget *receiver, QEvent *event)
void unregisterGestureRecognizer(Qt::GestureType type)
static QGestureManager * instance(InstanceCreation ic=ForceCreation)
void cleanupCachedGestures(QObject *target, Qt::GestureType type)
friend class QWidget
Definition qpainter.h:431