X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fuisupport%2Ftreeviewtouch.cpp;h=16abf9d1a6e7db29568ff1dfcfd5656c0ab5f28b;hb=47b54cd3ad35201ff2ab9ef6bfdba83fc086558d;hp=96845ac4721c7e9eb11b3c9b03575c793f76388d;hpb=127226e3619358013ef821acdf9e80f615370b12;p=quassel.git diff --git a/src/uisupport/treeviewtouch.cpp b/src/uisupport/treeviewtouch.cpp index 96845ac4..16abf9d1 100644 --- a/src/uisupport/treeviewtouch.cpp +++ b/src/uisupport/treeviewtouch.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2016 by the Quassel Project * + * Copyright (C) 2005-2020 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -24,20 +24,15 @@ #include #include - -TreeViewTouch::TreeViewTouch(QWidget *parent) +TreeViewTouch::TreeViewTouch(QWidget* parent) : QTreeView(parent) { setAttribute(Qt::WA_AcceptTouchEvents); } - -bool TreeViewTouch::event(QEvent *event) { -#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 +bool TreeViewTouch::event(QEvent* event) +{ + if (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->device()->type() == QTouchDevice::TouchScreen) { // 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; @@ -62,11 +57,7 @@ bool TreeViewTouch::event(QEvent *event) { return true; } -#if QT_VERSION >= 0x050000 if (event->type() == QEvent::TouchEnd || event->type() == QEvent::TouchCancel) { -#else - if (event->type() == QEvent::TouchEnd) { -#endif // End scroll and reset variables _touchScrollInProgress = false; _firstTouchUpdateHappened = false; @@ -76,14 +67,14 @@ bool TreeViewTouch::event(QEvent *event) { return QTreeView::event(event); } - -void TreeViewTouch::mousePressEvent(QMouseEvent *event) { +void TreeViewTouch::mousePressEvent(QMouseEvent* event) +{ if (!_touchScrollInProgress) QTreeView::mousePressEvent(event); } - -void TreeViewTouch::mouseMoveEvent(QMouseEvent *event) { +void TreeViewTouch::mouseMoveEvent(QMouseEvent* event) +{ if (!_touchScrollInProgress) QTreeView::mouseMoveEvent(event); -}; +}