X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fuisupport%2Fbufferview.cpp;h=3d45167d5619b6cb9733b64a7112c0f8a5cec3fb;hb=4c0c5a52458009b578a23d4abb4e726a13550c12;hp=7973785e1b332b9237c9fff4570c9d9ff9183b6a;hpb=e50ae7a06fc4e5d3a911c361d30953410deab609;p=quassel.git diff --git a/src/uisupport/bufferview.cpp b/src/uisupport/bufferview.cpp index 7973785e..3d45167d 100644 --- a/src/uisupport/bufferview.cpp +++ b/src/uisupport/bufferview.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2015 by the Quassel Project * + * Copyright (C) 2005-2016 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -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); @@ -158,21 +162,6 @@ void BufferView::setFilteredModel(QAbstractItemModel *model_, BufferViewConfig * } -void BufferView::setSelectionModel(QItemSelectionModel *selectionModel) -{ - if (QTreeView::selectionModel()) - disconnect(selectionModel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), - model(), SIGNAL(checkPreviousCurrentForRemoval(QModelIndex, QModelIndex))); - - QTreeView::setSelectionModel(selectionModel); - BufferViewFilter *filter = qobject_cast(model()); - if (filter) { - connect(selectionModel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), - filter, SLOT(checkPreviousCurrentForRemoval(QModelIndex, QModelIndex))); - } -} - - void BufferView::setConfig(BufferViewConfig *config) { if (_config == config) @@ -225,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) { @@ -253,7 +276,6 @@ void BufferView::dropEvent(QDropEvent *event) if (bufferList.count() != 1) return QTreeView::dropEvent(event); - NetworkId networkId = bufferList[0].first; BufferId bufferId2 = bufferList[0].second; if (index.data(NetworkModel::ItemTypeRole) != NetworkModel::BufferItemType) @@ -262,9 +284,6 @@ void BufferView::dropEvent(QDropEvent *event) if (index.data(NetworkModel::BufferTypeRole) != BufferInfo::QueryBuffer) return QTreeView::dropEvent(event); - if (index.data(NetworkModel::NetworkIdRole).value() != networkId) - return QTreeView::dropEvent(event); - BufferId bufferId1 = index.data(NetworkModel::BufferIdRole).value(); if (bufferId1 == bufferId2) return QTreeView::dropEvent(event);