Compare commits
3 Commits
589a664971
...
fc02a4aa7e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc02a4aa7e | ||
|
|
6223ef0ef0 | ||
|
|
76e6084419 |
@ -34,6 +34,7 @@ from PyQt6.QtWidgets import (
|
||||
)
|
||||
|
||||
# Third party imports
|
||||
import line_profiler
|
||||
|
||||
# App imports
|
||||
from audacity_controller import AudacityController
|
||||
@ -774,14 +775,29 @@ class PlaylistTab(QTableView):
|
||||
if row_count < 1:
|
||||
return
|
||||
|
||||
# Don't delete current or next tracks
|
||||
selected_row_numbers = self.selected_model_row_numbers()
|
||||
for ts in [
|
||||
track_sequence.next,
|
||||
track_sequence.current,
|
||||
]:
|
||||
if ts:
|
||||
if (
|
||||
ts.playlist_id == self.playlist_id
|
||||
and ts.row_number in selected_row_numbers
|
||||
):
|
||||
self.musicmuster.show_warning(
|
||||
"Delete not allowed", "Can't delete current or next track"
|
||||
)
|
||||
return
|
||||
|
||||
# Get confirmation
|
||||
plural = "s" if row_count > 1 else ""
|
||||
if not ask_yes_no("Delete rows", f"Really delete {row_count} row{plural}?"):
|
||||
return
|
||||
|
||||
base_model = self.get_base_model()
|
||||
|
||||
base_model.delete_rows(self.selected_model_row_numbers())
|
||||
base_model.delete_rows(selected_row_numbers)
|
||||
self.clear_selection()
|
||||
|
||||
def get_base_model(self) -> PlaylistModel:
|
||||
@ -830,14 +846,12 @@ class PlaylistTab(QTableView):
|
||||
|
||||
# Use a set to deduplicate result (a selected row will have all
|
||||
# items in that row selected)
|
||||
result = sorted(
|
||||
list(
|
||||
set([self.model().mapToSource(a).row() for a in self.selectedIndexes()])
|
||||
)
|
||||
)
|
||||
selected_indexes = self.selectedIndexes()
|
||||
|
||||
log.debug(f"get_selected_rows() returned: {result=}")
|
||||
return result
|
||||
if not selected_indexes:
|
||||
return []
|
||||
|
||||
return sorted(list(set([self.model().mapToSource(a).row() for a in selected_indexes])))
|
||||
|
||||
def get_top_visible_row(self) -> int:
|
||||
"""
|
||||
@ -1119,6 +1133,7 @@ class PlaylistTab(QTableView):
|
||||
|
||||
self.setSpan(row, column, rowSpan, columnSpan)
|
||||
|
||||
@line_profiler.profile
|
||||
def tab_live(self) -> None:
|
||||
"""
|
||||
Called when tab gets focus
|
||||
|
||||
Loading…
Reference in New Issue
Block a user