71 |
71 |
72 Qt::GestureType registerGestureRecognizer(QGestureRecognizer *recognizer); |
72 Qt::GestureType registerGestureRecognizer(QGestureRecognizer *recognizer); |
73 void unregisterGestureRecognizer(Qt::GestureType type); |
73 void unregisterGestureRecognizer(Qt::GestureType type); |
74 |
74 |
75 bool filterEvent(QWidget *receiver, QEvent *event); |
75 bool filterEvent(QWidget *receiver, QEvent *event); |
76 bool filterEvent(QGesture *receiver, QEvent *event); |
76 bool filterEvent(QObject *receiver, QEvent *event); |
|
77 #ifndef QT_NO_GRAPHICSVIEW |
77 bool filterEvent(QGraphicsObject *receiver, QEvent *event); |
78 bool filterEvent(QGraphicsObject *receiver, QEvent *event); |
|
79 #endif //QT_NO_GRAPHICSVIEW |
78 |
80 |
79 // declared in qapplication.cpp |
|
80 static QGestureManager* instance(); |
81 static QGestureManager* instance(); |
|
82 |
|
83 void cleanupCachedGestures(QObject *target, Qt::GestureType type); |
|
84 |
|
85 void recycle(QGesture *gesture); |
81 |
86 |
82 protected: |
87 protected: |
83 void timerEvent(QTimerEvent *event); |
88 void timerEvent(QTimerEvent *event); |
84 bool filterEventThroughContexts(const QMap<QObject *, Qt::GestureType> &contexts, |
89 bool filterEventThroughContexts(const QMultiMap<QObject *, Qt::GestureType> &contexts, |
85 QEvent *event); |
90 QEvent *event); |
86 |
91 |
87 private: |
92 private: |
88 QMultiMap<Qt::GestureType, QGestureRecognizer *> recognizers; |
93 QMultiMap<Qt::GestureType, QGestureRecognizer *> m_recognizers; |
89 |
94 |
90 QSet<QGesture *> activeGestures; |
95 QSet<QGesture *> m_activeGestures; |
91 QMap<QGesture *, QBasicTimer> maybeGestures; |
96 QHash<QGesture *, QBasicTimer> m_maybeGestures; |
92 |
97 |
93 enum State { |
98 enum State { |
94 Gesture, |
99 Gesture, |
95 NotGesture, |
100 NotGesture, |
96 MaybeGesture // this means timers are up and waiting for some |
101 MaybeGesture // this means timers are up and waiting for some |
102 { |
107 { |
103 QWeakPointer<QObject> object; |
108 QWeakPointer<QObject> object; |
104 Qt::GestureType gesture; |
109 Qt::GestureType gesture; |
105 |
110 |
106 ObjectGesture(QObject *o, const Qt::GestureType &g) : object(o), gesture(g) { } |
111 ObjectGesture(QObject *o, const Qt::GestureType &g) : object(o), gesture(g) { } |
107 inline bool operator<(const ObjectGesture& rhs) const |
112 inline bool operator<(const ObjectGesture &rhs) const |
108 { |
113 { |
109 if (object.data() < rhs.object.data()) |
114 if (object.data() < rhs.object.data()) |
110 return true; |
115 return true; |
111 if (object == rhs.object) |
116 if (object == rhs.object) |
112 return gesture < rhs.gesture; |
117 return gesture < rhs.gesture; |
113 return false; |
118 return false; |
114 } |
119 } |
115 }; |
120 }; |
116 |
121 |
117 QMap<ObjectGesture, QGesture *> objectGestures; |
122 QMap<ObjectGesture, QList<QGesture *> > m_objectGestures; |
118 QMap<QGesture *, QGestureRecognizer *> gestureToRecognizer; |
123 QHash<QGesture *, QGestureRecognizer *> m_gestureToRecognizer; |
119 QHash<QGesture *, QObject *> gestureOwners; |
124 QHash<QGesture *, QObject *> m_gestureOwners; |
120 |
125 |
121 QHash<QGesture *, QWidget *> gestureTargets; |
126 QHash<QGesture *, QWidget *> m_gestureTargets; |
122 |
127 |
123 int lastCustomGestureId; |
128 int m_lastCustomGestureId; |
124 |
129 |
125 QGesture *getState(QObject *widget, Qt::GestureType gesture); |
130 QHash<QGestureRecognizer *, QList<QGesture *> > m_obsoleteGestures; |
|
131 QHash<QGesture *, QGestureRecognizer *> m_deletedRecognizers; |
|
132 void cleanupGesturesForRemovedRecognizer(QGesture *gesture); |
|
133 |
|
134 QGesture *getState(QObject *widget, QGestureRecognizer *recognizer, |
|
135 Qt::GestureType gesture); |
126 void deliverEvents(const QSet<QGesture *> &gestures, |
136 void deliverEvents(const QSet<QGesture *> &gestures, |
127 QSet<QGesture *> *undeliveredGestures); |
137 QSet<QGesture *> *undeliveredGestures); |
128 void getGestureTargets(const QSet<QGesture*> &gestures, |
138 void getGestureTargets(const QSet<QGesture*> &gestures, |
129 QMap<QWidget *, QList<QGesture *> > *conflicts, |
139 QMap<QWidget *, QList<QGesture *> > *conflicts, |
130 QMap<QWidget *, QList<QGesture *> > *normal); |
140 QMap<QWidget *, QList<QGesture *> > *normal); |
|
141 |
|
142 void cancelGesturesForChildren(QGesture *originatingGesture); |
131 }; |
143 }; |
|
144 |
|
145 extern QGestureManager *qt_gestureManager; |
132 |
146 |
133 QT_END_NAMESPACE |
147 QT_END_NAMESPACE |
134 |
148 |
135 #endif // QGESTUREMANAGER_P_H |
149 #endif // QGESTUREMANAGER_P_H |