Android: Faked up touch scroll - not fully working, behaves a bit odd...
This commit is contained in:
committed by
craig.p.drummond
parent
1884f42608
commit
bb523394ea
@@ -38,6 +38,10 @@ ListView::ListView(QWidget *parent)
|
||||
setAlternatingRowColors(true);
|
||||
setUniformItemSizes(true);
|
||||
setAttribute(Qt::WA_MouseTracking);
|
||||
#ifdef CANTATA_ANDROID
|
||||
viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
|
||||
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
#endif
|
||||
}
|
||||
|
||||
ListView::~ListView()
|
||||
@@ -123,3 +127,30 @@ void ListView::correctSelection()
|
||||
setCurrentIndex(currentIndex());
|
||||
selectionModel()->select(s, QItemSelectionModel::SelectCurrent);
|
||||
}
|
||||
|
||||
#ifdef CANTATA_ANDROID
|
||||
#include <QtGui/QScrollBar>
|
||||
bool ListView::viewportEvent(QEvent *event) {
|
||||
if (QEvent::TouchUpdate==event->type()) {
|
||||
QTouchEvent *te=(QTouchEvent *)event;
|
||||
|
||||
if (1==te->touchPoints().count()) {
|
||||
QTouchEvent::TouchPoint point=te->touchPoints().at(0);
|
||||
|
||||
if (point.pos().y()>-1 && point.pos().y()<height()) {
|
||||
double diff=point.lastPos().y()-point.pos().y();
|
||||
|
||||
if (diff>0.00001 || diff<-0.00001) {
|
||||
QScrollBar *sb=verticalScrollBar();
|
||||
|
||||
if (sb) {
|
||||
sb->setValue(sb->value()+diff);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return QListView::viewportEvent(event);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#define LISTVIEW_H
|
||||
|
||||
#include <QtGui/QListView>
|
||||
#include "config.h"
|
||||
|
||||
class ListView : public QListView
|
||||
{
|
||||
@@ -48,6 +49,11 @@ private Q_SLOTS:
|
||||
|
||||
Q_SIGNALS:
|
||||
bool itemsSelected(bool);
|
||||
|
||||
private:
|
||||
#ifdef CANTATA_ANDROID
|
||||
bool viewportEvent(QEvent *event);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user