X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fuisupport%2Fbufferview.cpp;h=dd5005323244276ba0d466f2247dccd34e576136;hb=26e6d2ac973b67ae227dfe36062c409a8e3fa5b3;hp=4c09a46b6379b5b44ab466d5c815e15bebb6f632;hpb=9d54503555534a2c554f09a33df6afa33d6308ec;p=quassel.git diff --git a/src/uisupport/bufferview.cpp b/src/uisupport/bufferview.cpp index 4c09a46b..dd500532 100644 --- a/src/uisupport/bufferview.cpp +++ b/src/uisupport/bufferview.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2014 by the Quassel Project * + * Copyright (C) 2005-2015 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); @@ -392,10 +411,15 @@ void BufferView::setExpandedState(const QModelIndex &networkIdx) storeExpandedState(networkIdx); // this call is needed to keep track of the isActive state } - +#if QT_VERSION < 0x050000 void BufferView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) { QTreeView::dataChanged(topLeft, bottomRight); +#else +void BufferView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles) +{ + QTreeView::dataChanged(topLeft, bottomRight, roles); +#endif // determine how many items have been changed and if any of them is a networkitem // which just swichted from active to inactive or vice versa