Clean up merge from dev
This commit is contained in:
parent
75cc7a3f19
commit
0ea12eb9d9
@ -272,7 +272,7 @@ class PlaylistModel(QAbstractTableModel):
|
||||
- update track times
|
||||
"""
|
||||
|
||||
if not track_sequence.current:
|
||||
if not self.track_sequence.current:
|
||||
return
|
||||
|
||||
row_number = self.track_sequence.current.row_number
|
||||
@ -846,11 +846,46 @@ class PlaylistModel(QAbstractTableModel):
|
||||
)
|
||||
from_rows.remove(self.track_sequence.current.row_number)
|
||||
|
||||
# Row moves must be wrapped in beginMoveRows .. endMoveRows and
|
||||
# the row range must be contiguous. Process the highest rows
|
||||
# first so the lower row numbers are unchanged
|
||||
from_rows = sorted(set(from_rows))
|
||||
if (min(from_rows) < 0 or max(from_rows) >= self.rowCount()
|
||||
or to_row_number < 0 or to_row_number > self.rowCount()):
|
||||
log.debug("move_rows: invalid indexes")
|
||||
return False
|
||||
|
||||
row_groups = self._reversed_contiguous_row_groups([a.row_number for a in from_rows])
|
||||
if to_row_number in from_rows:
|
||||
return False # Destination within rows to be moved
|
||||
|
||||
# # Remove rows from bottom to top to avoid index shifting
|
||||
# for row in sorted(from_rows, reverse=True):
|
||||
# self.beginRemoveRows(QModelIndex(), row, row)
|
||||
# del self.playlist_rows[row]
|
||||
# # At this point self.playlist_rows has been updated but the
|
||||
# # underlying database has not (that's done below after
|
||||
# # inserting the rows)
|
||||
# self.endRemoveRows()
|
||||
|
||||
# # Adjust insertion point after removal
|
||||
# if to_row_number > max(from_rows):
|
||||
# rows_below_dest = len([r for r in from_rows if r < to_row_number])
|
||||
# insertion_point = to_row_number - rows_below_dest
|
||||
# else:
|
||||
# insertion_point = to_row_number
|
||||
|
||||
# # Insert rows at the destination
|
||||
# plrid_to_new_row_number: list[dict[int, int]] = []
|
||||
# for offset, row_data in enumerate(rows_to_move):
|
||||
# row_number = insertion_point + offset
|
||||
# self.beginInsertRows(QModelIndex(), row_number, row_number)
|
||||
# self.playlist_rows[row_number] = row_data
|
||||
# plrid_to_new_row_number.append({row_data.playlistrow_id: row_number})
|
||||
# self.endInsertRows()
|
||||
|
||||
# Notify model going to change
|
||||
self.beginResetModel()
|
||||
# Update database
|
||||
repository.move_rows(from_rows, self.playlist_id, to_row_number)
|
||||
# Notify model changed
|
||||
self.endResetModel()
|
||||
|
||||
# Handle the moves in row_group chunks
|
||||
for row_group in row_groups:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user