mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Grid View: Delay rendering on wheel events
Ignore continuous wheel events, only rendering after the "last" wheel event, where two wheel event are continuous if they occur within 200 msecs of each other.
This commit is contained in:
parent
6ce79b2d96
commit
798eb321d8
@ -15,7 +15,7 @@ from Queue import Queue
|
|||||||
from functools import wraps, partial
|
from functools import wraps, partial
|
||||||
|
|
||||||
from PyQt4.Qt import (
|
from PyQt4.Qt import (
|
||||||
QListView, QSize, QStyledItemDelegate, QModelIndex, Qt, QImage, pyqtSignal,
|
QListView, QSize, QStyledItemDelegate, QModelIndex, Qt, QImage, pyqtSignal, QTimer,
|
||||||
QPalette, QColor, QItemSelection, QPixmap, QMenu, QApplication, QMimeData, QIcon,
|
QPalette, QColor, QItemSelection, QPixmap, QMenu, QApplication, QMimeData, QIcon,
|
||||||
QUrl, QDrag, QPoint, QPainter, QRect, pyqtProperty, QPropertyAnimation, QEasingCurve)
|
QUrl, QDrag, QPoint, QPainter, QRect, pyqtProperty, QPropertyAnimation, QEasingCurve)
|
||||||
|
|
||||||
@ -470,6 +470,10 @@ class GridView(QListView):
|
|||||||
self.context_menu = None
|
self.context_menu = None
|
||||||
self.verticalScrollBar().sliderPressed.connect(self.slider_pressed)
|
self.verticalScrollBar().sliderPressed.connect(self.slider_pressed)
|
||||||
self.verticalScrollBar().sliderReleased.connect(self.slider_released)
|
self.verticalScrollBar().sliderReleased.connect(self.slider_released)
|
||||||
|
self.update_timer = QTimer(self)
|
||||||
|
self.update_timer.setInterval(200)
|
||||||
|
self.update_timer.timeout.connect(self.update_viewport)
|
||||||
|
self.update_timer.setSingleShot(True)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def first_visible_row(self):
|
def first_visible_row(self):
|
||||||
@ -491,6 +495,7 @@ class GridView(QListView):
|
|||||||
return ans + (geom.width() // item_width)
|
return ans + (geom.width() // item_width)
|
||||||
|
|
||||||
def update_viewport(self):
|
def update_viewport(self):
|
||||||
|
self.ignore_render_requests.clear()
|
||||||
m = self.model()
|
m = self.model()
|
||||||
for r in xrange(self.first_visible_row or 0, self.last_visible_row or (m.count() - 1)):
|
for r in xrange(self.first_visible_row or 0, self.last_visible_row or (m.count() - 1)):
|
||||||
self.update(m.index(r, 0))
|
self.update(m.index(r, 0))
|
||||||
@ -502,6 +507,11 @@ class GridView(QListView):
|
|||||||
self.ignore_render_requests.clear()
|
self.ignore_render_requests.clear()
|
||||||
self.update_viewport()
|
self.update_viewport()
|
||||||
|
|
||||||
|
def wheelEvent(self, e):
|
||||||
|
self.ignore_render_requests.set()
|
||||||
|
QListView.wheelEvent(self, e)
|
||||||
|
self.update_timer.start()
|
||||||
|
|
||||||
def double_clicked(self, index):
|
def double_clicked(self, index):
|
||||||
d = self.delegate
|
d = self.delegate
|
||||||
if d.animating is None and not config['disable_animations']:
|
if d.animating is None and not config['disable_animations']:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user