Compare commits

..

No commits in common. "b86b7f7f331ad19052382b5d5a2011829e537a8b" and "243bc765f910d5584b5818bd513c38484150d669" have entirely different histories.

5 changed files with 16 additions and 60 deletions

View File

@ -54,10 +54,6 @@ class TrackSelectDialog(QDialog):
height = record.f_int or 600
self.resize(width, height)
if add_to_header:
self.ui.lblNote.setVisible(False)
self.ui.txtNote.setVisible(False)
def add_selected(self) -> None:
"""Handle Add button"""
@ -69,22 +65,18 @@ class TrackSelectDialog(QDialog):
track = item.data(Qt.ItemDataRole.UserRole)
note = self.ui.txtNote.text()
track_id = None
if track:
track_id = track.id
if not track_id:
if note:
self.model.insert_row(self.new_row_number, track_id, note)
self.ui.txtNote.clear()
return
else:
# No note, no track
return
if not note and not track:
return
self.ui.txtNote.clear()
self.select_searchtext()
track_id = None
if track:
track_id = track.id
else:
return
# Check whether track is already in playlist
move_existing = False
existing_prd = self.model.is_track_in_playlist(track_id)
@ -95,16 +87,14 @@ class TrackSelectDialog(QDialog):
default_yes=True,
):
move_existing = True
if self.add_to_header:
if move_existing and existing_prd: # "and existing_prd" for mypy's benefit
if self.add_to_header and existing_prd: # "and existing_prd" for mypy's benefit
if move_existing:
self.model.move_track_to_header(self.new_row_number, existing_prd, note)
else:
self.model.add_track_to_header(self.new_row_number, track_id)
# Close dialog - we can only add one track to a header
self.accept()
else:
# Adding a new track row
if move_existing and existing_prd: # "and existing_prd" for mypy's benefit
self.model.move_track_add_note(self.new_row_number, existing_prd, note)
else:

View File

@ -239,20 +239,6 @@ class Playlists(Base):
session.add(self)
session.flush()
@staticmethod
def clear_tabs(session: scoped_session, playlist_ids: List[int]) -> None:
"""
Make all tab records NULL
"""
session.execute(
update(Playlists)
.where(
(Playlists.id.in_(playlist_ids))
)
.values(tab=None)
)
def close(self) -> None:
"""Mark playlist as unloaded"""

View File

@ -875,23 +875,15 @@ class Window(QMainWindow, Ui_MainWindow):
def load_last_playlists(self) -> None:
"""Load the playlists that were open when the last session closed"""
playlist_ids = []
with Session() as session:
for playlist in Playlists.get_open(session):
if playlist:
_ = self.create_playlist_tab(playlist)
playlist_ids.append(playlist.id)
# Set active tab
record = Settings.get_int_settings(session, "active_tab")
if record.f_int is not None and record.f_int >= 0:
if record.f_int and record.f_int >= 0:
self.tabPlaylist.setCurrentIndex(record.f_int)
# Tabs may move during use. Rather than track where tabs
# are, we record the tab index when we close the main
# window. To avoid possible duplicate tab entries, we null
# them all out now.
Playlists.clear_tabs(session, playlist_ids)
def lookup_row_in_songfacts(self) -> None:
"""
Display songfacts page for title in highlighted row

View File

@ -306,13 +306,7 @@ class PlaylistModel(QAbstractTableModel):
if unplayed_rows:
try:
# Find next row after current track
next_row = min(
[
a
for a in unplayed_rows
if a > row_number and not self.is_header_row(a)
]
)
next_row = min([a for a in unplayed_rows if a > row_number])
except ValueError:
# Find first unplayed track
next_row = min(unplayed_rows)
@ -730,7 +724,6 @@ class PlaylistModel(QAbstractTableModel):
self.refresh_data(session)
super().endInsertRows()
self.signals.resize_rows_signal.emit(self.playlist_id)
self.reset_track_sequence_row_numbers()
self.invalidate_rows(list(range(new_row_number, len(self.playlist_rows))))
@ -1479,9 +1472,6 @@ class PlaylistProxyModel(QSortFilterProxyModel):
def get_row_track_path(self, row_number: int) -> str:
return self.data_model.get_row_track_path(row_number)
def get_unplayed_rows(self) -> List[int]:
return self.data_model.get_unplayed_rows()
def hide_played_tracks(self, hide: bool) -> None:
return self.data_model.hide_played_tracks(hide)

View File

@ -234,15 +234,13 @@ class PlaylistTab(QTableView):
super().dropEvent(event)
from_rows = self.selected_model_row_numbers()
to_index = self.indexAt(event.position().toPoint())
to_model_row = self.proxy_model.mapToSource(to_index).row()
to_row = self.indexAt(event.position().toPoint()).row()
if (
0 <= min(from_rows) <= self.data_model.rowCount()
and 0 <= max(from_rows) <= self.data_model.rowCount()
and 0 <= to_model_row <= self.data_model.rowCount()
0 <= min(from_rows) <= self.model().rowCount()
and 0 <= max(from_rows) <= self.model().rowCount()
and 0 <= to_row <= self.model().rowCount()
):
self.data_model.move_rows(from_rows, to_model_row)
self.model().move_rows(from_rows, to_row)
# Reset drag mode to allow row selection by dragging
self.setDragEnabled(False)