Command out @log_call decorators
This commit is contained in:
parent
728d012257
commit
0c717241ff
42
app/ds.py
42
app/ds.py
@ -50,7 +50,7 @@ cache_region = make_region().configure(
|
|||||||
|
|
||||||
|
|
||||||
# Helper functions
|
# Helper functions
|
||||||
@log_call
|
# @log_call
|
||||||
def _remove_substring_case_insensitive(parent_string: str, substring: str) -> str:
|
def _remove_substring_case_insensitive(parent_string: str, substring: str) -> str:
|
||||||
"""
|
"""
|
||||||
Remove all instances of substring from parent string, case insensitively
|
Remove all instances of substring from parent string, case insensitively
|
||||||
@ -166,7 +166,7 @@ def get_colour(text: str, foreground: bool = False) -> str:
|
|||||||
return rec.colour
|
return rec.colour
|
||||||
|
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def remove_colour_substring(text: str) -> str:
|
def remove_colour_substring(text: str) -> str:
|
||||||
"""
|
"""
|
||||||
Remove text that identifies the colour to be used if strip_substring is True
|
Remove text that identifies the colour to be used if strip_substring is True
|
||||||
@ -178,7 +178,7 @@ def remove_colour_substring(text: str) -> str:
|
|||||||
|
|
||||||
|
|
||||||
# Track functions
|
# Track functions
|
||||||
@log_call
|
# @log_call
|
||||||
def _tracks_where(query: BinaryExpression | ColumnElement[bool],) -> list[TrackDTO]:
|
def _tracks_where(query: BinaryExpression | ColumnElement[bool],) -> list[TrackDTO]:
|
||||||
"""
|
"""
|
||||||
filter_by_last_played: bool = False,
|
filter_by_last_played: bool = False,
|
||||||
@ -378,7 +378,7 @@ def get_filtered_tracks(filter: Filter) -> list[TrackDTO]:
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def add_track_to_header(playlistrow_id: int, track_id: int) -> None:
|
def add_track_to_header(playlistrow_id: int, track_id: int) -> None:
|
||||||
"""
|
"""
|
||||||
Add a track to this (header) row
|
Add a track to this (header) row
|
||||||
@ -393,7 +393,7 @@ def add_track_to_header(playlistrow_id: int, track_id: int) -> None:
|
|||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def create_track(path: str, metadata: dict[str, str | int | float]) -> TrackDTO:
|
def create_track(path: str, metadata: dict[str, str | int | float]) -> TrackDTO:
|
||||||
"""
|
"""
|
||||||
Create a track db entry from a track path and return the DTO
|
Create a track db entry from a track path and return the DTO
|
||||||
@ -425,7 +425,7 @@ def create_track(path: str, metadata: dict[str, str | int | float]) -> TrackDTO:
|
|||||||
return new_track
|
return new_track
|
||||||
|
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def update_track(
|
def update_track(
|
||||||
path: str, track_id: int, metadata: dict[str, str | int | float]
|
path: str, track_id: int, metadata: dict[str, str | int | float]
|
||||||
) -> TrackDTO:
|
) -> TrackDTO:
|
||||||
@ -480,7 +480,7 @@ def delete_track(track_id: int) -> None:
|
|||||||
|
|
||||||
|
|
||||||
# Playlist functions
|
# Playlist functions
|
||||||
@log_call
|
# @log_call
|
||||||
def _playlists_where(
|
def _playlists_where(
|
||||||
query: BinaryExpression | ColumnElement[bool],
|
query: BinaryExpression | ColumnElement[bool],
|
||||||
) -> list[PlaylistDTO]:
|
) -> list[PlaylistDTO]:
|
||||||
@ -513,7 +513,7 @@ def _playlists_where(
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def playlist_by_id(playlist_id: int) -> PlaylistDTO | None:
|
def playlist_by_id(playlist_id: int) -> PlaylistDTO | None:
|
||||||
"""
|
"""
|
||||||
Return playlist with specified id
|
Return playlist with specified id
|
||||||
@ -638,7 +638,7 @@ def _check_playlist_integrity(
|
|||||||
raise ApplicationError(msg)
|
raise ApplicationError(msg)
|
||||||
|
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def playlist_mark_status(playlist_id: int, open: bool) -> None:
|
def playlist_mark_status(playlist_id: int, open: bool) -> None:
|
||||||
"""Mark playlist as open or closed"""
|
"""Mark playlist as open or closed"""
|
||||||
|
|
||||||
@ -652,7 +652,7 @@ def playlist_mark_status(playlist_id: int, open: bool) -> None:
|
|||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def _shift_rows(
|
def _shift_rows(
|
||||||
session: Session, playlist_id: int, starting_row: int, shift_by: int
|
session: Session, playlist_id: int, starting_row: int, shift_by: int
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -671,7 +671,7 @@ def _shift_rows(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def move_rows(
|
def move_rows(
|
||||||
from_rows: list[int],
|
from_rows: list[int],
|
||||||
from_playlist_id: int,
|
from_playlist_id: int,
|
||||||
@ -763,7 +763,7 @@ def move_rows(
|
|||||||
_check_playlist_integrity(session, to_playlist_id, fix=False)
|
_check_playlist_integrity(session, to_playlist_id, fix=False)
|
||||||
|
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def update_row_numbers(
|
def update_row_numbers(
|
||||||
playlist_id: int, id_to_row_number: list[dict[int, int]]
|
playlist_id: int, id_to_row_number: list[dict[int, int]]
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -780,7 +780,7 @@ def update_row_numbers(
|
|||||||
_check_playlist_integrity(session, playlist_id, fix=False)
|
_check_playlist_integrity(session, playlist_id, fix=False)
|
||||||
|
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def create_playlist(name: str, template_id: int, as_template: bool = False) -> PlaylistDTO:
|
def create_playlist(name: str, template_id: int, as_template: bool = False) -> PlaylistDTO:
|
||||||
"""
|
"""
|
||||||
Create playlist and return DTO.
|
Create playlist and return DTO.
|
||||||
@ -840,7 +840,7 @@ def playlist_row_count(playlist_id: int) -> int:
|
|||||||
return count
|
return count
|
||||||
|
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def insert_row(
|
def insert_row(
|
||||||
playlist_id: int, row_number: int, track_id: int | None, note: str
|
playlist_id: int, row_number: int, track_id: int | None, note: str
|
||||||
) -> PlaylistRowDTO:
|
) -> PlaylistRowDTO:
|
||||||
@ -880,7 +880,7 @@ def insert_row(
|
|||||||
return new_playlist_row
|
return new_playlist_row
|
||||||
|
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def remove_comments(playlist_id: int, row_numbers: list[int]) -> None:
|
def remove_comments(playlist_id: int, row_numbers: list[int]) -> None:
|
||||||
"""
|
"""
|
||||||
Remove comments from rows in playlist
|
Remove comments from rows in playlist
|
||||||
@ -898,7 +898,7 @@ def remove_comments(playlist_id: int, row_numbers: list[int]) -> None:
|
|||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def remove_rows(playlist_id: int, row_numbers: list[int]) -> None:
|
def remove_rows(playlist_id: int, row_numbers: list[int]) -> None:
|
||||||
"""
|
"""
|
||||||
Remove rows from playlist
|
Remove rows from playlist
|
||||||
@ -920,7 +920,7 @@ def remove_rows(playlist_id: int, row_numbers: list[int]) -> None:
|
|||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def update_template_favourite(template_id: int, favourite: bool) -> None:
|
def update_template_favourite(template_id: int, favourite: bool) -> None:
|
||||||
"""Update template favourite"""
|
"""Update template favourite"""
|
||||||
|
|
||||||
@ -933,7 +933,7 @@ def update_template_favourite(template_id: int, favourite: bool) -> None:
|
|||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def playlist_save_tabs(playlist_id_to_tab: dict[int, int]) -> None:
|
def playlist_save_tabs(playlist_id_to_tab: dict[int, int]) -> None:
|
||||||
"""
|
"""
|
||||||
Save the tab numbers of the open playlists.
|
Save the tab numbers of the open playlists.
|
||||||
@ -957,7 +957,7 @@ def playlist_save_tabs(playlist_id_to_tab: dict[int, int]) -> None:
|
|||||||
|
|
||||||
# Playlist Rows
|
# Playlist Rows
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def get_playlist_row(playlistrow_id: int) -> PlaylistRowDTO | None:
|
def get_playlist_row(playlistrow_id: int) -> PlaylistRowDTO | None:
|
||||||
"""
|
"""
|
||||||
Return specific row DTO
|
Return specific row DTO
|
||||||
@ -1028,7 +1028,7 @@ def get_playlist_rows(
|
|||||||
|
|
||||||
|
|
||||||
# Playdates
|
# Playdates
|
||||||
@log_call
|
# @log_call
|
||||||
def get_last_played_dates(track_id: int, limit: int = 5) -> str:
|
def get_last_played_dates(track_id: int, limit: int = 5) -> str:
|
||||||
"""
|
"""
|
||||||
Return the most recent 'limit' dates that this track has been played
|
Return the most recent 'limit' dates that this track has been played
|
||||||
@ -1105,7 +1105,7 @@ def playdates_between_dates(
|
|||||||
|
|
||||||
|
|
||||||
# Queries
|
# Queries
|
||||||
@log_call
|
# @log_call
|
||||||
def _queries_where(
|
def _queries_where(
|
||||||
query: BinaryExpression | ColumnElement[bool],
|
query: BinaryExpression | ColumnElement[bool],
|
||||||
) -> list[QueryDTO]:
|
) -> list[QueryDTO]:
|
||||||
|
|||||||
@ -482,7 +482,7 @@ class ManageQueries(ItemlistManager):
|
|||||||
|
|
||||||
self.populate_table(query_list)
|
self.populate_table(query_list)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def delete_item(self, query_id: int) -> None:
|
def delete_item(self, query_id: int) -> None:
|
||||||
"""delete query"""
|
"""delete query"""
|
||||||
|
|
||||||
@ -579,7 +579,7 @@ class ManageTemplates(ItemlistManager):
|
|||||||
|
|
||||||
self.populate_table(template_list)
|
self.populate_table(template_list)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def delete_item(self, template_id: int) -> None:
|
def delete_item(self, template_id: int) -> None:
|
||||||
"""delete template"""
|
"""delete template"""
|
||||||
|
|
||||||
@ -1403,7 +1403,7 @@ class Window(QMainWindow):
|
|||||||
|
|
||||||
# # # # # # # # # # Playlist management functions # # # # # # # # # #
|
# # # # # # # # # # Playlist management functions # # # # # # # # # #
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def _create_playlist(self, name: str, template_id: int) -> Playlists:
|
def _create_playlist(self, name: str, template_id: int) -> Playlists:
|
||||||
"""
|
"""
|
||||||
Create a playlist in the database, populate it from the template
|
Create a playlist in the database, populate it from the template
|
||||||
@ -1412,7 +1412,7 @@ class Window(QMainWindow):
|
|||||||
|
|
||||||
return ds.create_playlist(name, template_id)
|
return ds.create_playlist(name, template_id)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def _open_playlist(self, playlist: PlaylistDTO, is_template: bool = False) -> int:
|
def _open_playlist(self, playlist: PlaylistDTO, is_template: bool = False) -> int:
|
||||||
"""
|
"""
|
||||||
With passed playlist:
|
With passed playlist:
|
||||||
@ -1441,7 +1441,7 @@ class Window(QMainWindow):
|
|||||||
|
|
||||||
return idx
|
return idx
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def create_playlist_from_template(self, template_id: int) -> None:
|
def create_playlist_from_template(self, template_id: int) -> None:
|
||||||
"""
|
"""
|
||||||
Prompt for new playlist name and create from passed template_id
|
Prompt for new playlist name and create from passed template_id
|
||||||
@ -1461,7 +1461,7 @@ class Window(QMainWindow):
|
|||||||
|
|
||||||
_ = ds.create_playlist(playlist_name, template_id)
|
_ = ds.create_playlist(playlist_name, template_id)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def delete_playlist(self, checked: bool = False) -> None:
|
def delete_playlist(self, checked: bool = False) -> None:
|
||||||
"""
|
"""
|
||||||
Delete current playlist. checked paramater passed by menu system
|
Delete current playlist. checked paramater passed by menu system
|
||||||
@ -1705,7 +1705,7 @@ class Window(QMainWindow):
|
|||||||
self.signals.search_songfacts_signal.connect(self.open_songfacts_browser)
|
self.signals.search_songfacts_signal.connect(self.open_songfacts_browser)
|
||||||
self.signals.search_wikipedia_signal.connect(self.open_wikipedia_browser)
|
self.signals.search_wikipedia_signal.connect(self.open_wikipedia_browser)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def current_row_or_end(self) -> int:
|
def current_row_or_end(self) -> int:
|
||||||
"""
|
"""
|
||||||
If a row or rows are selected, return the row number of the first
|
If a row or rows are selected, return the row number of the first
|
||||||
@ -1756,7 +1756,7 @@ class Window(QMainWindow):
|
|||||||
self.footer_section.btnDrop3db.isChecked()
|
self.footer_section.btnDrop3db.isChecked()
|
||||||
)
|
)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def enable_escape(self, enabled: bool) -> None:
|
def enable_escape(self, enabled: bool) -> None:
|
||||||
"""
|
"""
|
||||||
Manage signal to enable/disable handling ESC character.
|
Manage signal to enable/disable handling ESC character.
|
||||||
@ -1768,7 +1768,7 @@ class Window(QMainWindow):
|
|||||||
if "clear_selection" in self.menu_actions:
|
if "clear_selection" in self.menu_actions:
|
||||||
self.menu_actions["clear_selection"].setEnabled(enabled)
|
self.menu_actions["clear_selection"].setEnabled(enabled)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def end_of_track_actions(self) -> None:
|
def end_of_track_actions(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -1905,7 +1905,7 @@ class Window(QMainWindow):
|
|||||||
dlg = TrackInsertDialog(parent=self, playlist_id=self.active_tab().playlist_id)
|
dlg = TrackInsertDialog(parent=self, playlist_id=self.active_tab().playlist_id)
|
||||||
dlg.exec()
|
dlg.exec()
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def load_last_playlists(self) -> None:
|
def load_last_playlists(self) -> None:
|
||||||
"""Load the playlists that were open when app was last closed"""
|
"""Load the playlists that were open when app was last closed"""
|
||||||
|
|
||||||
@ -1956,7 +1956,7 @@ class Window(QMainWindow):
|
|||||||
f"mark_rows_for_moving(): {self.move_source_rows=} {self.move_source_model=}"
|
f"mark_rows_for_moving(): {self.move_source_rows=} {self.move_source_model=}"
|
||||||
)
|
)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def move_playlist_rows(self, row_numbers: list[int]) -> None:
|
def move_playlist_rows(self, row_numbers: list[int]) -> None:
|
||||||
"""
|
"""
|
||||||
Move passed playlist rows to another playlist
|
Move passed playlist rows to another playlist
|
||||||
@ -2033,7 +2033,7 @@ class Window(QMainWindow):
|
|||||||
|
|
||||||
webbrowser.get("browser").open_new_tab(url)
|
webbrowser.get("browser").open_new_tab(url)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def paste_rows(self, checked: bool = False) -> None:
|
def paste_rows(self, checked: bool = False) -> None:
|
||||||
"""
|
"""
|
||||||
Paste earlier cut rows.
|
Paste earlier cut rows.
|
||||||
@ -2067,7 +2067,7 @@ class Window(QMainWindow):
|
|||||||
if set_next_row:
|
if set_next_row:
|
||||||
to_playlist_model.set_next_row(set_next_row)
|
to_playlist_model.set_next_row(set_next_row)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def play_next(
|
def play_next(
|
||||||
self, position: Optional[float] = None, checked: bool = False
|
self, position: Optional[float] = None, checked: bool = False
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -2422,7 +2422,7 @@ class Window(QMainWindow):
|
|||||||
height = ds.get_setting("mainwindow_height") or 100
|
height = ds.get_setting("mainwindow_height") or 100
|
||||||
self.setGeometry(x, y, width, height)
|
self.setGeometry(x, y, width, height)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def set_selected_track_next(self, checked: bool = False) -> None:
|
def set_selected_track_next(self, checked: bool = False) -> None:
|
||||||
"""
|
"""
|
||||||
Set currently-selected row on visible playlist tab as next track
|
Set currently-selected row on visible playlist tab as next track
|
||||||
@ -2436,7 +2436,7 @@ class Window(QMainWindow):
|
|||||||
# else:
|
# else:
|
||||||
# log.error("No active tab")
|
# log.error("No active tab")
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def set_tab_colour(self, widget: PlaylistTab, colour: QColor) -> None:
|
def set_tab_colour(self, widget: PlaylistTab, colour: QColor) -> None:
|
||||||
"""
|
"""
|
||||||
Find the tab containing the widget and set the text colour
|
Find the tab containing the widget and set the text colour
|
||||||
@ -2498,7 +2498,7 @@ class Window(QMainWindow):
|
|||||||
|
|
||||||
self.active_tab().scroll_to_top(playlist_track.row_number)
|
self.active_tab().scroll_to_top(playlist_track.row_number)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def stop(self, checked: bool = False) -> None:
|
def stop(self, checked: bool = False) -> None:
|
||||||
"""Stop playing immediately"""
|
"""Stop playing immediately"""
|
||||||
|
|
||||||
|
|||||||
@ -147,7 +147,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
|
|
||||||
return header_row
|
return header_row
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def add_track_to_header(self, track_details: InsertTrack) -> None:
|
def add_track_to_header(self, track_details: InsertTrack) -> None:
|
||||||
"""
|
"""
|
||||||
Handle signal_add_track_to_header
|
Handle signal_add_track_to_header
|
||||||
@ -241,7 +241,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
|
|
||||||
return QBrush()
|
return QBrush()
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def begin_reset_model(self, playlist_id: int) -> None:
|
def begin_reset_model(self, playlist_id: int) -> None:
|
||||||
"""
|
"""
|
||||||
Reset model if playlist_id is ours
|
Reset model if playlist_id is ours
|
||||||
@ -256,7 +256,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
|
|
||||||
return len(Col)
|
return len(Col)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def track_started(self, play_track: PlayTrack) -> None:
|
def track_started(self, play_track: PlayTrack) -> None:
|
||||||
"""
|
"""
|
||||||
Notification from musicmuster that the current track has just
|
Notification from musicmuster that the current track has just
|
||||||
@ -382,7 +382,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
|
|
||||||
return QVariant()
|
return QVariant()
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def delete_rows(self, row_numbers: list[int]) -> None:
|
def delete_rows(self, row_numbers: list[int]) -> None:
|
||||||
"""
|
"""
|
||||||
Delete passed rows from model
|
Delete passed rows from model
|
||||||
@ -465,7 +465,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def end_reset_model(self, playlist_id: int) -> None:
|
def end_reset_model(self, playlist_id: int) -> None:
|
||||||
"""
|
"""
|
||||||
End model reset if this is our playlist
|
End model reset if this is our playlist
|
||||||
@ -544,7 +544,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
|
|
||||||
return boldfont
|
return boldfont
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def get_duplicate_rows(self) -> list[int]:
|
def get_duplicate_rows(self) -> list[int]:
|
||||||
"""
|
"""
|
||||||
Return a list of duplicate rows. If track appears in rows 2, 3 and 4, return [3, 4]
|
Return a list of duplicate rows. If track appears in rows 2, 3 and 4, return [3, 4]
|
||||||
@ -565,7 +565,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def _get_new_row_number(self) -> int:
|
def _get_new_row_number(self) -> int:
|
||||||
"""
|
"""
|
||||||
Get row number for new row.
|
Get row number for new row.
|
||||||
@ -586,7 +586,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
|
|
||||||
return self.playlist_rows[row_number]
|
return self.playlist_rows[row_number]
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def get_row_track_id(self, row_number: int) -> Optional[int]:
|
def get_row_track_id(self, row_number: int) -> Optional[int]:
|
||||||
"""
|
"""
|
||||||
Return id of track associated with row or None if no track associated
|
Return id of track associated with row or None if no track associated
|
||||||
@ -703,7 +703,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
]
|
]
|
||||||
self.invalidate_row(row_number, roles)
|
self.invalidate_row(row_number, roles)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def insert_row(self, track_id: Optional[int] = None, note: str = "",) -> None:
|
def insert_row(self, track_id: Optional[int] = None, note: str = "",) -> None:
|
||||||
"""
|
"""
|
||||||
Insert a row.
|
Insert a row.
|
||||||
@ -738,7 +738,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
list(range(new_row_number, len(self.playlist_rows))), roles_to_invalidate
|
list(range(new_row_number, len(self.playlist_rows))), roles_to_invalidate
|
||||||
)
|
)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def invalidate_row(self, modified_row: int, roles: list[Qt.ItemDataRole]) -> None:
|
def invalidate_row(self, modified_row: int, roles: list[Qt.ItemDataRole]) -> None:
|
||||||
"""
|
"""
|
||||||
Signal to view to refresh invalidated row
|
Signal to view to refresh invalidated row
|
||||||
@ -770,7 +770,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
return self.playlist_rows[row_number].path == ""
|
return self.playlist_rows[row_number].path == ""
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def is_played_row(self, row_number: int) -> bool:
|
def is_played_row(self, row_number: int) -> bool:
|
||||||
"""
|
"""
|
||||||
Return True if row is an unplayed track row, else False
|
Return True if row is an unplayed track row, else False
|
||||||
@ -806,7 +806,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
]
|
]
|
||||||
self.invalidate_rows(row_numbers, roles)
|
self.invalidate_rows(row_numbers, roles)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def move_rows(self, from_rows: list[int], to_row_number: int) -> bool:
|
def move_rows(self, from_rows: list[int], to_row_number: int) -> bool:
|
||||||
"""
|
"""
|
||||||
Move the playlist rows in from_rows to to_row. Return True if successful
|
Move the playlist rows in from_rows to to_row. Return True if successful
|
||||||
@ -856,7 +856,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
# self.invalidate_rows(list(row_map.keys()), roles)
|
# self.invalidate_rows(list(row_map.keys()), roles)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def move_rows_between_playlists(
|
def move_rows_between_playlists(
|
||||||
self,
|
self,
|
||||||
from_rows: list[PlaylistRow],
|
from_rows: list[PlaylistRow],
|
||||||
@ -924,7 +924,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
|
|
||||||
super().endInsertRows()
|
super().endInsertRows()
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def move_track_add_note(
|
def move_track_add_note(
|
||||||
self, new_row_number: int, existing_plr: PlaylistRow, note: str
|
self, new_row_number: int, existing_plr: PlaylistRow, note: str
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -943,7 +943,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
self.move_rows([existing_plr.row_number], new_row_number)
|
self.move_rows([existing_plr.row_number], new_row_number)
|
||||||
self.signals.resize_rows_signal.emit(self.playlist_id)
|
self.signals.resize_rows_signal.emit(self.playlist_id)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def obs_scene_change(self, row_number: int) -> None:
|
def obs_scene_change(self, row_number: int) -> None:
|
||||||
"""
|
"""
|
||||||
Check this row and any preceding headers for OBS scene change command
|
Check this row and any preceding headers for OBS scene change command
|
||||||
@ -978,7 +978,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
log.warning(f"{self}: OBS connection refused")
|
log.warning(f"{self}: OBS connection refused")
|
||||||
return
|
return
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def previous_track_ended(self) -> None:
|
def previous_track_ended(self) -> None:
|
||||||
"""
|
"""
|
||||||
Notification from musicmuster that the previous track has ended.
|
Notification from musicmuster that the previous track has ended.
|
||||||
@ -1043,7 +1043,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
|
|
||||||
self.playlist_rows[row_number] = PlaylistRow(refreshed_row)
|
self.playlist_rows[row_number] = PlaylistRow(refreshed_row)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def remove_track(self, row_number: int) -> None:
|
def remove_track(self, row_number: int) -> None:
|
||||||
"""
|
"""
|
||||||
Remove track from row, retaining row as a header row
|
Remove track from row, retaining row as a header row
|
||||||
@ -1074,7 +1074,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
self.invalidate_row(row_number, roles)
|
self.invalidate_row(row_number, roles)
|
||||||
self.signals.resize_rows_signal.emit(self.playlist_id)
|
self.signals.resize_rows_signal.emit(self.playlist_id)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def reset_track_sequence_row_numbers(self) -> None:
|
def reset_track_sequence_row_numbers(self) -> None:
|
||||||
"""
|
"""
|
||||||
Signal handler for when row ordering has changed.
|
Signal handler for when row ordering has changed.
|
||||||
@ -1114,7 +1114,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
]
|
]
|
||||||
self.invalidate_rows(row_numbers, roles)
|
self.invalidate_rows(row_numbers, roles)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def _reversed_contiguous_row_groups(
|
def _reversed_contiguous_row_groups(
|
||||||
self, row_numbers: list[int]
|
self, row_numbers: list[int]
|
||||||
) -> list[list[int]]:
|
) -> list[list[int]]:
|
||||||
@ -1255,7 +1255,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def set_selected_rows(self, playlist_id: int, selected_row_numbers: list[int]) -> None:
|
def set_selected_rows(self, playlist_id: int, selected_row_numbers: list[int]) -> None:
|
||||||
"""
|
"""
|
||||||
Handle signal_playlist_selected_rows to keep track of which rows
|
Handle signal_playlist_selected_rows to keep track of which rows
|
||||||
@ -1267,7 +1267,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
|
|
||||||
self.selected_rows = [self.playlist_rows[a] for a in selected_row_numbers]
|
self.selected_rows = [self.playlist_rows[a] for a in selected_row_numbers]
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def set_next_row(self, playlist_id: int) -> None:
|
def set_next_row(self, playlist_id: int) -> None:
|
||||||
"""
|
"""
|
||||||
Handle signal_set_next_row
|
Handle signal_set_next_row
|
||||||
@ -1312,7 +1312,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
self.signals.next_track_changed_signal.emit()
|
self.signals.next_track_changed_signal.emit()
|
||||||
self.update_track_times()
|
self.update_track_times()
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def setData(
|
def setData(
|
||||||
self,
|
self,
|
||||||
index: QModelIndex,
|
index: QModelIndex,
|
||||||
@ -1449,7 +1449,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
|
|
||||||
return ds.get_last_played_dates(track_id)
|
return ds.get_last_played_dates(track_id)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def update_or_insert(self, track_id: int, row_number: int) -> None:
|
def update_or_insert(self, track_id: int, row_number: int) -> None:
|
||||||
"""
|
"""
|
||||||
If the passed track_id exists in this playlist, update the
|
If the passed track_id exists in this playlist, update the
|
||||||
@ -1473,7 +1473,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
else:
|
else:
|
||||||
self.insert_row(track_id=track_id)
|
self.insert_row(track_id=track_id)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def update_track_times(self) -> None:
|
def update_track_times(self) -> None:
|
||||||
"""
|
"""
|
||||||
Update track start/end times in self.playlist_rows
|
Update track start/end times in self.playlist_rows
|
||||||
|
|||||||
@ -367,7 +367,7 @@ class PlaylistTab(QTableView):
|
|||||||
# Deselect edited line
|
# Deselect edited line
|
||||||
self.clear_selection()
|
self.clear_selection()
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def dropEvent(self, event: Optional[QDropEvent]) -> None:
|
def dropEvent(self, event: Optional[QDropEvent]) -> None:
|
||||||
"""
|
"""
|
||||||
Move dropped rows
|
Move dropped rows
|
||||||
@ -723,7 +723,7 @@ class PlaylistTab(QTableView):
|
|||||||
cb.clear(mode=cb.Mode.Clipboard)
|
cb.clear(mode=cb.Mode.Clipboard)
|
||||||
cb.setText(track_path, mode=cb.Mode.Clipboard)
|
cb.setText(track_path, mode=cb.Mode.Clipboard)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def track_started(self, play_track: PlayTrack) -> None:
|
def track_started(self, play_track: PlayTrack) -> None:
|
||||||
"""
|
"""
|
||||||
Called when track starts playing
|
Called when track starts playing
|
||||||
@ -816,7 +816,7 @@ class PlaylistTab(QTableView):
|
|||||||
else:
|
else:
|
||||||
return TrackInfo(track_id, selected_row)
|
return TrackInfo(track_id, selected_row)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def get_selected_row(self) -> Optional[int]:
|
def get_selected_row(self) -> Optional[int]:
|
||||||
"""
|
"""
|
||||||
Return selected row number. If no rows or multiple rows selected, return None
|
Return selected row number. If no rows or multiple rows selected, return None
|
||||||
@ -828,7 +828,7 @@ class PlaylistTab(QTableView):
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def get_selected_rows(self) -> list[int]:
|
def get_selected_rows(self) -> list[int]:
|
||||||
"""Return a list of model-selected row numbers sorted by row"""
|
"""Return a list of model-selected row numbers sorted by row"""
|
||||||
|
|
||||||
@ -841,7 +841,7 @@ class PlaylistTab(QTableView):
|
|||||||
|
|
||||||
return sorted(list(set([self.model().mapToSource(a).row() for a in selected_indexes])))
|
return sorted(list(set([self.model().mapToSource(a).row() for a in selected_indexes])))
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def get_top_visible_row(self) -> int:
|
def get_top_visible_row(self) -> int:
|
||||||
"""
|
"""
|
||||||
Get the viewport of the table view
|
Get the viewport of the table view
|
||||||
@ -1010,7 +1010,7 @@ class PlaylistTab(QTableView):
|
|||||||
# Reset selection mode
|
# Reset selection mode
|
||||||
self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
|
self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def source_model_selected_row_number(self) -> Optional[int]:
|
def source_model_selected_row_number(self) -> Optional[int]:
|
||||||
"""
|
"""
|
||||||
Return the model row number corresponding to the selected row or None
|
Return the model row number corresponding to the selected row or None
|
||||||
@ -1021,7 +1021,7 @@ class PlaylistTab(QTableView):
|
|||||||
return None
|
return None
|
||||||
return self.model().mapToSource(selected_index).row()
|
return self.model().mapToSource(selected_index).row()
|
||||||
|
|
||||||
@log_call
|
# @log_call
|
||||||
def selected_model_row_numbers(self) -> list[int]:
|
def selected_model_row_numbers(self) -> list[int]:
|
||||||
"""
|
"""
|
||||||
Return a list of model row numbers corresponding to the selected rows or
|
Return a list of model row numbers corresponding to the selected rows or
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user