/***************************************************************************
- * 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 *
#include <QMenu>
#include <QMessageBox>
#include <QSet>
+#include <QTouchEvent>
+#include <QScrollBar>
+
#include "action.h"
#include "buffermodel.h"
setAcceptDrops(true);
setDropIndicatorShown(true);
#endif
+ setAttribute(Qt::WA_AcceptTouchEvents);
setSortingEnabled(true);
sortByColumn(0, Qt::AscendingOrder);
}
-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<BufferViewFilter *>(model());
- if (filter) {
- connect(selectionModel, SIGNAL(currentChanged(QModelIndex, QModelIndex)),
- filter, SLOT(checkPreviousCurrentForRemoval(QModelIndex, QModelIndex)));
- }
-}
-
-
void BufferView::setConfig(BufferViewConfig *config)
{
if (_config == config)
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)
{