Fix scroll to current/next with hidden rows
This commit is contained in:
parent
2b4e003caf
commit
9af20c29d3
@ -1027,7 +1027,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
"""Scroll to show current track"""
|
"""Scroll to show current track"""
|
||||||
|
|
||||||
log.debug(f"KAE: musicmuster.show_current()")
|
log.debug(f"KAE: musicmuster.show_current()")
|
||||||
if self.current_track_playlist_tab != self.visible_playlist_tab:
|
if self.current_track_playlist_tab != self.visible_playlist_tab():
|
||||||
self.tabPlaylist.setCurrentWidget(self.current_track_playlist_tab)
|
self.tabPlaylist.setCurrentWidget(self.current_track_playlist_tab)
|
||||||
self.tabPlaylist.currentWidget().scroll_current_to_top()
|
self.tabPlaylist.currentWidget().scroll_current_to_top()
|
||||||
|
|
||||||
@ -1035,7 +1035,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
"""Scroll to show next track"""
|
"""Scroll to show next track"""
|
||||||
|
|
||||||
log.debug(f"KAE: musicmuster.show_next()")
|
log.debug(f"KAE: musicmuster.show_next()")
|
||||||
if self.next_track_playlist_tab != self.visible_playlist_tab:
|
if self.next_track_playlist_tab != self.visible_playlist_tab():
|
||||||
self.tabPlaylist.setCurrentWidget(self.next_track_playlist_tab)
|
self.tabPlaylist.setCurrentWidget(self.next_track_playlist_tab)
|
||||||
self.tabPlaylist.currentWidget().scroll_next_to_top()
|
self.tabPlaylist.currentWidget().scroll_next_to_top()
|
||||||
|
|
||||||
|
|||||||
@ -1727,8 +1727,23 @@ class PlaylistTab(QTableWidget):
|
|||||||
top.
|
top.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if row is not None:
|
padding_required = Config.SCROLL_TOP_MARGIN
|
||||||
top_row = max(0, row - Config.SCROLL_TOP_MARGIN + 1)
|
top_row = row
|
||||||
|
|
||||||
|
if row > Config.SCROLL_TOP_MARGIN:
|
||||||
|
# We can't scroll to a hidden row. Calculate target_row as the
|
||||||
|
# one that is ideal to be at the top. Then count upwards from
|
||||||
|
# passed row until we either reach the target, pass it or reach
|
||||||
|
# row 0.
|
||||||
|
# target_row = max(0, row - Config.SCROLL_TOP_MARGIN + 1)
|
||||||
|
for i in range(row - 1, -1, -1):
|
||||||
|
if padding_required == 0:
|
||||||
|
break
|
||||||
|
if self.isRowHidden(i):
|
||||||
|
continue
|
||||||
|
top_row = i
|
||||||
|
padding_required -= 1
|
||||||
|
|
||||||
scroll_item = self.item(top_row, 0)
|
scroll_item = self.item(top_row, 0)
|
||||||
self.scrollToItem(scroll_item, QAbstractItemView.PositionAtTop)
|
self.scrollToItem(scroll_item, QAbstractItemView.PositionAtTop)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user