X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fbufferview.cpp;h=3d45167d5619b6cb9733b64a7112c0f8a5cec3fb;hp=0f80d0d8959681263ec3076e077f7fa9f66959c2;hb=4c0c5a52458009b578a23d4abb4e726a13550c12;hpb=29c7d46de1bb0703e51033ddcec34cb785d6f8c6 diff --git a/src/uisupport/bufferview.cpp b/src/uisupport/bufferview.cpp index 0f80d0d8..3d45167d 100644 --- a/src/uisupport/bufferview.cpp +++ b/src/uisupport/bufferview.cpp @@ -28,6 +28,9 @@ #include #include #include +#include +#include + #include "action.h" #include "buffermodel.h" @@ -84,6 +87,7 @@ void BufferView::init() setAcceptDrops(true); setDropIndicatorShown(true); #endif + setAttribute(Qt::WA_AcceptTouchEvents); setSortingEnabled(true); sortByColumn(0, Qt::AscendingOrder); @@ -210,6 +214,40 @@ void BufferView::joinChannel(const QModelIndex &index) Client::userInput(bufferInfo, QString("/JOIN %1").arg(bufferInfo.bufferName())); } +bool BufferView::event(QEvent *event) { + if (event->type() == QEvent::TouchBegin && _lastTouchStart < QDateTime::currentMSecsSinceEpoch() - 1000) { //(slow) double tab = normal behaviour = select multiple. 1000 ok? + _touchScrollInProgress = true; + _lastTouchStart = QDateTime::currentMSecsSinceEpoch(); + setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); + return true; + } + + if (event->type() == QEvent::TouchUpdate && _touchScrollInProgress) { + QTouchEvent::TouchPoint p = ((QTouchEvent*)event)->touchPoints().at(0); + verticalScrollBar()->setValue(verticalScrollBar()->value() - (p.pos().y() - p.lastPos().y())); + return true; + } +#if QT_VERSION >= 0x050000 + if (event->type() == QEvent::TouchEnd || event->type() == QEvent::TouchCancel) { +#else + if (event->type() == QEvent::TouchEnd) { +#endif + _touchScrollInProgress = false; + return true; + } + + return QTreeView::event(event); +} + +void BufferView::mousePressEvent(QMouseEvent * event) { + if (!_touchScrollInProgress) + QTreeView::mousePressEvent(event); +} + +void BufferView::mouseMoveEvent(QMouseEvent * event) { + if (!_touchScrollInProgress) + QTreeView::mouseMoveEvent(event); +} void BufferView::keyPressEvent(QKeyEvent *event) {