From 93c5475a29befc1fccbd97b2d67064f470ca7110 Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Thu, 16 Nov 2023 18:06:21 +0000 Subject: [PATCH] WIP V3: preview button works --- app/playlistmodel.py | 7 +++++++ app/playlists.py | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/app/playlistmodel.py b/app/playlistmodel.py index 90c0985..b6f02e3 100644 --- a/app/playlistmodel.py +++ b/app/playlistmodel.py @@ -448,6 +448,13 @@ class PlaylistModel(QAbstractTableModel): return QVariant(boldfont) + def get_row_track_path(self, row_number: int) -> str: + """ + Return path of track associated with row or empty string if no track associated + """ + + return self.playlist_rows[row_number].path + def get_rows_duration(self, row_numbers: List[int]) -> int: """ Return the total duration of the passed rows diff --git a/app/playlists.py b/app/playlists.py index 117a425..cd6e1ac 100644 --- a/app/playlists.py +++ b/app/playlists.py @@ -284,6 +284,20 @@ class PlaylistTab(QTableView): return index.row() return None + def get_selected_row_track_path(self) -> str: + """ + Return the path of the selected row. If no row selected or selected + row does not have a track, return empty string. + """ + + sm = self.selectionModel() + if sm and sm.hasSelection(): + index = sm.currentIndex() + if index.isValid(): + model = cast(PlaylistModel, self.model()) + return model.get_row_track_path(index.row()) + return "" + # def lookup_row_in_songfacts(self) -> None: # """ # If there is a selected row and it is a track row,