Check touch device type on TouchEvents
[quassel.git] / src / uisupport / treeviewtouch.cpp
index 0ef3b36..96845ac 100644 (file)
@@ -33,7 +33,11 @@ TreeViewTouch::TreeViewTouch(QWidget *parent)
 
 
 bool TreeViewTouch::event(QEvent *event) {
-    if (event->type() == QEvent::TouchBegin) {
+#if QT_VERSION >= 0x050000
+    if (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->device()->type()==QTouchDevice::TouchScreen) {
+#else
+    if (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->deviceType()==QTouchEvent::TouchScreen) {
+#endif
         // Register that we may be scrolling, set the scroll mode to scroll-per-pixel
         // and accept the event (return true) so that we will receive TouchUpdate and TouchEnd/TouchCancel
         _touchScrollInProgress = true;