Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Significantly reduced the number of redraws in GUI tables #6384

Merged
merged 1 commit into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/tribler-gui/tribler_gui/widgets/lazytableview.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ def deselect_all_rows(self):
"""
Deselect all rows in the table view.
"""
old_selected = self.delegate.hover_index
self.delegate.hover_index = self.delegate.no_index
self.redraw()
self.redraw(old_selected)

def leaveEvent(self, event):
"""
Expand All @@ -117,8 +118,8 @@ def mouseMoveEvent(self, event):
index = QModelIndex(self.indexAt(event.pos()))
self.mouse_moved.emit(event.pos(), index)

def redraw(self):
self.viewport().update()
def redraw(self, index):
self.model().dataChanged.emit(index, index, [])
# This is required to drop the sensitivity zones of the controls,
# so there are no invisible controls left over from a previous state of the view
for control in self.delegate.controls:
Expand Down
5 changes: 2 additions & 3 deletions src/tribler-gui/tribler_gui/widgets/tablecontentdelegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def on_mouse_moved(self, pos, index):


class TriblerButtonsDelegate(QStyledItemDelegate):
redraw_required = pyqtSignal()
redraw_required = pyqtSignal(QModelIndex)

def __init__(self, parent=None):
QStyledItemDelegate.__init__(self, parent)
Expand Down Expand Up @@ -155,8 +155,7 @@ def on_mouse_moved(self, pos, index):
redraw = controls.on_mouse_moved(pos, index) or redraw

if redraw:
# TODO: optimize me to only redraw the rows that actually changed!
self.redraw_required.emit()
self.redraw_required.emit(index)

@staticmethod
def split_rect_into_squares(r, buttons):
Expand Down