Open playlists working; playlist queries refactored
This commit is contained in:
parent
c7034cf35a
commit
cb5eedd8c8
@ -324,19 +324,27 @@ class Playlists(Base):
|
||||
"""Returns a list of all playlists ordered by last use"""
|
||||
|
||||
return (
|
||||
session.query(cls).order_by(
|
||||
cls.loaded.desc(), cls.last_used.desc())
|
||||
).all()
|
||||
#
|
||||
# @classmethod
|
||||
# def get_closed(cls, session: Session) -> List["Playlists"]:
|
||||
# """Returns a list of all closed playlists ordered by last use"""
|
||||
#
|
||||
# return (
|
||||
# session.query(cls)
|
||||
# .filter(cls.loaded.is_(False))
|
||||
# .order_by(cls.last_used.desc())
|
||||
# ).all()
|
||||
session.execute(
|
||||
select(cls)
|
||||
.order_by(cls.loaded.desc(), cls.last_used.desc())
|
||||
)
|
||||
.scalars()
|
||||
.all()
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def get_closed(cls, session: Session) -> List["Playlists"]:
|
||||
"""Returns a list of all closed playlists ordered by last use"""
|
||||
|
||||
return (
|
||||
session.execute(
|
||||
select(cls)
|
||||
.filter(cls.loaded.is_(False))
|
||||
.order_by(cls.last_used.desc())
|
||||
)
|
||||
.scalars()
|
||||
.all()
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def get_open(cls, session: Session) -> List[Optional["Playlists"]]:
|
||||
|
||||
@ -175,13 +175,12 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
self.actionEnable_controls.triggered.connect(
|
||||
self.enable_play_next_controls)
|
||||
self.actionExport_playlist.triggered.connect(self.export_playlist_tab)
|
||||
# ***kae
|
||||
# self.actionImport.triggered.connect(self.import_track)
|
||||
self.actionFade.triggered.connect(self.fade)
|
||||
# self.actionMoveSelected.triggered.connect(self.move_selected)
|
||||
self.actionNewPlaylist.triggered.connect(self.create_playlist)
|
||||
self.actionOpenPlaylist.triggered.connect(self.open_playlist)
|
||||
# ***kae
|
||||
# self.actionOpenPlaylist.triggered.connect(self.open_playlist)
|
||||
self.actionPlay_next.triggered.connect(self.play_next)
|
||||
# self.actionSearch.triggered.connect(self.search_playlist)
|
||||
# self.actionSearch_database.triggered.connect(self.search_database)
|
||||
@ -652,17 +651,17 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
# """Update search when search string changes"""
|
||||
#
|
||||
# self.visible_playlist_tab().set_filter(self.txtSearch.text())
|
||||
#
|
||||
# def open_playlist(self):
|
||||
# with Session() as session:
|
||||
# playlists = Playlists.get_closed(session)
|
||||
# dlg = SelectPlaylistDialog(self, playlists=playlists,
|
||||
# session=session)
|
||||
# dlg.exec()
|
||||
# playlist = dlg.playlist
|
||||
# if playlist:
|
||||
# playlist.mark_open(session)
|
||||
# self.create_playlist_tab(session, playlist)
|
||||
|
||||
def open_playlist(self):
|
||||
with Session() as session:
|
||||
playlists = Playlists.get_closed(session)
|
||||
dlg = SelectPlaylistDialog(self, playlists=playlists,
|
||||
session=session)
|
||||
dlg.exec()
|
||||
playlist = dlg.playlist
|
||||
if playlist:
|
||||
playlist.mark_open(session)
|
||||
self.create_playlist_tab(session, playlist)
|
||||
#
|
||||
# def select_next_row(self) -> None:
|
||||
# """Select next or first row in playlist"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user