WIP V3: add track to header working

This commit is contained in:
Keith Edmunds 2023-11-23 17:12:03 +00:00
parent c626d91f26
commit 25e3be6fae
2 changed files with 14 additions and 9 deletions

View File

@ -685,9 +685,9 @@ class PlaylistModel(QAbstractTableModel):
proposed_row_number: Optional[int], proposed_row_number: Optional[int],
track_id: Optional[int] = None, track_id: Optional[int] = None,
note: Optional[str] = None, note: Optional[str] = None,
) -> PlaylistRows: ) -> None:
""" """
Insert a track row. Insert a row.
""" """
new_row_number = self._get_new_row_number(proposed_row_number) new_row_number = self._get_new_row_number(proposed_row_number)
@ -704,9 +704,7 @@ class PlaylistModel(QAbstractTableModel):
super().endInsertRows() super().endInsertRows()
self.row_order_changed(self.playlist_id) self.row_order_changed(self.playlist_id)
self.invalidate_rows(list(range(plr.plr_rownum, len(self.playlist_rows)))) self.invalidate_rows(list(range(new_row_number, len(self.playlist_rows))))
return plr
def invalidate_row(self, modified_row: int) -> None: def invalidate_row(self, modified_row: int) -> None:
""" """

View File

@ -482,9 +482,13 @@ class PlaylistTab(QTableView):
# # # ########## Internally called functions ########## # # # ########## Internally called functions ##########
def _add_track(self, row_number: int) -> None: def _add_track(self) -> None:
"""Add a track to a section header making it a normal track row""" """Add a track to a section header making it a normal track row"""
row_number = self.get_selected_row_number()
if not row_number:
return
with Session() as session: with Session() as session:
dlg = TrackSelectDialog( dlg = TrackSelectDialog(
session=session, session=session,
@ -534,7 +538,7 @@ class PlaylistTab(QTableView):
# Add track to section header (ie, make this a track row) # Add track to section header (ie, make this a track row)
# TODO # TODO
if header_row: if header_row:
self._add_context_menu("Add a track", lambda: print("Add a track")) self._add_context_menu("Add a track", lambda: self._add_track())
# # ---------------------- # # ----------------------
self.menu.addSeparator() self.menu.addSeparator()
@ -542,7 +546,8 @@ class PlaylistTab(QTableView):
# Mark unplayed # Mark unplayed
if track_row and model.is_unplayed_row(row_number): if track_row and model.is_unplayed_row(row_number):
self._add_context_menu( self._add_context_menu(
"Mark unplayed", lambda: self._mark_as_unplayed(self.get_selected_rows()) "Mark unplayed",
lambda: self._mark_as_unplayed(self.get_selected_rows()),
) )
# Unmark as next # Unmark as next
@ -583,7 +588,9 @@ class PlaylistTab(QTableView):
# Track path TODO # Track path TODO
if track_row: if track_row:
self._add_context_menu("Copy track path", lambda: self._copy_path(row_number)) self._add_context_menu(
"Copy track path", lambda: self._copy_path(row_number)
)
def _calculate_end_time( def _calculate_end_time(
self, start: Optional[datetime], duration: int self, start: Optional[datetime], duration: int