Add section header working
This commit is contained in:
parent
dfc1344c69
commit
56fb1aeb3d
@ -148,7 +148,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
event.accept()
|
||||
|
||||
def connect_signals_slots(self) -> None:
|
||||
# self.actionInsertSectionHeader.triggered.connect(self.insert_header)
|
||||
self.actionInsertSectionHeader.triggered.connect(self.insert_header)
|
||||
self.action_Clear_selection.triggered.connect(self.clear_selection)
|
||||
self.actionClosePlaylist.triggered.connect(self.close_playlist_tab)
|
||||
self.actionDownload_CSV_of_played_tracks.triggered.connect(
|
||||
@ -213,15 +213,25 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
# Close playlist and remove tab
|
||||
self.tabPlaylist.widget(tab_index).close()
|
||||
self.tabPlaylist.removeTab(tab_index)
|
||||
#
|
||||
# def insert_header(self) -> None:
|
||||
# """Call playlist to create note"""
|
||||
#
|
||||
# try:
|
||||
# self.visible_playlist_tab().create_note()
|
||||
# except AttributeError:
|
||||
# # Just return if there's no visible playlist tab
|
||||
# return
|
||||
|
||||
def insert_header(self) -> None:
|
||||
"""Show dialog box to enter header text and add to playlist"""
|
||||
|
||||
try:
|
||||
playlist_tab = self.visible_playlist_tab()
|
||||
except AttributeError:
|
||||
# Just return if there's no visible playlist tab
|
||||
return
|
||||
|
||||
# Get header text
|
||||
dlg: QInputDialog = QInputDialog(self)
|
||||
dlg.setInputMode(QInputDialog.TextInput)
|
||||
dlg.setLabelText("Header text:")
|
||||
dlg.resize(500, 100)
|
||||
ok = dlg.exec()
|
||||
if ok:
|
||||
with Session() as session:
|
||||
playlist_tab.insert_header(session, dlg.textValue())
|
||||
|
||||
def create_playlist(self) -> None:
|
||||
"""Create new playlist"""
|
||||
@ -934,14 +944,14 @@ class DbDialog(QDialog):
|
||||
self.add_selected()
|
||||
self.close()
|
||||
|
||||
def title_artist_toggle(self) -> None:
|
||||
"""
|
||||
Handle switching between searching for artists and searching for
|
||||
titles
|
||||
"""
|
||||
def add_track(self, track: Tracks) -> None:
|
||||
"""Add passed track to playlist on screen"""
|
||||
|
||||
# Logic is handled already in chars_typed(), so just call that.
|
||||
self.chars_typed(self.ui.searchString.text())
|
||||
self.parent().visible_playlist_tab().insert_track(self.session, track)
|
||||
# Commit session to get correct row numbers if more tracks added
|
||||
self.session.commit()
|
||||
# Select search text to make it easier for next search
|
||||
self.select_searchtext()
|
||||
|
||||
def chars_typed(self, s: str) -> None:
|
||||
"""Handle text typed in search box"""
|
||||
@ -972,15 +982,6 @@ class DbDialog(QDialog):
|
||||
# Select search text to make it easier for next search
|
||||
self.select_searchtext()
|
||||
|
||||
def add_track(self, track: Tracks) -> None:
|
||||
"""Add passed track to playlist on screen"""
|
||||
|
||||
self.parent().visible_playlist_tab().insert_track(self.session, track)
|
||||
# Commit session to get correct row numbers if more tracks added
|
||||
self.session.commit()
|
||||
# Select search text to make it easier for next search
|
||||
self.select_searchtext()
|
||||
|
||||
def select_searchtext(self) -> None:
|
||||
"""Select the searchbox"""
|
||||
|
||||
@ -996,6 +997,15 @@ class DbDialog(QDialog):
|
||||
item = self.ui.matchList.currentItem()
|
||||
track = item.data(Qt.UserRole)
|
||||
self.ui.dbPath.setText(track.path)
|
||||
|
||||
def title_artist_toggle(self) -> None:
|
||||
"""
|
||||
Handle switching between searching for artists and searching for
|
||||
titles
|
||||
"""
|
||||
|
||||
# Logic is handled already in chars_typed(), so just call that.
|
||||
self.chars_typed(self.ui.searchString.text())
|
||||
|
||||
|
||||
class DownloadCSV(QDialog):
|
||||
|
||||
@ -17,7 +17,6 @@ from PyQt5.QtWidgets import (
|
||||
QAbstractItemDelegate,
|
||||
QAbstractItemView,
|
||||
QApplication,
|
||||
# QInputDialog,
|
||||
QLineEdit,
|
||||
QMainWindow,
|
||||
QMenu,
|
||||
@ -478,30 +477,28 @@ class PlaylistTab(QTableWidget):
|
||||
|
||||
return [self._get_playlistrow_id(a) for a in self._selected_rows()]
|
||||
|
||||
#
|
||||
# def create_note(self) -> None:
|
||||
# """
|
||||
# Create note
|
||||
#
|
||||
# If a row is selected, set note row to be row above. Otherwise,
|
||||
# set note row to be end of playlist.
|
||||
# """
|
||||
#
|
||||
# row: Optional[int] = self._get_selected_row()
|
||||
# if not row:
|
||||
# row = self.rowCount()
|
||||
#
|
||||
# # Get note text
|
||||
# dlg: QInputDialog = QInputDialog(self)
|
||||
# dlg.setInputMode(QInputDialog.TextInput)
|
||||
# dlg.setLabelText("Note:")
|
||||
# dlg.resize(500, 100)
|
||||
# ok: int = dlg.exec()
|
||||
# if ok:
|
||||
# with Session() as session:
|
||||
# note: Notes = Notes(
|
||||
# session, self.playlist_id, row, dlg.textValue())
|
||||
# self._insert_note(session, note, row, True) # checked
|
||||
def insert_header(self, session: Session, note: str,
|
||||
repaint: bool = True) -> None:
|
||||
"""
|
||||
Insert section header into playlist tab.
|
||||
|
||||
If a row is selected, add header above. Otherwise, add to end of
|
||||
playlist.
|
||||
|
||||
We simply build a PlaylistRows object and pass it to insert_row()
|
||||
to do the heavy lifing.
|
||||
"""
|
||||
|
||||
# PlaylistRows object requires a row number, but that number
|
||||
# can be reset by calling PlaylistRows.fixup_rownumbers() later,
|
||||
# so just fudge a row number for now.
|
||||
row_number = 0
|
||||
plr = PlaylistRows(session, self.playlist_id, None, row_number)
|
||||
plr.note = note
|
||||
self.insert_row(session, plr)
|
||||
PlaylistRows.fixup_rownumbers(session, self.playlist_id)
|
||||
if repaint:
|
||||
self.update_display(session)
|
||||
#
|
||||
# def _get_selected_rows(self) -> List[int]:
|
||||
# """Return a sorted list of selected row numbers"""
|
||||
@ -618,6 +615,8 @@ class PlaylistTab(QTableWidget):
|
||||
plr = PlaylistRows(session, self.playlist_id, track.id, row_number)
|
||||
self.insert_row(session, plr)
|
||||
PlaylistRows.fixup_rownumbers(session, self.playlist_id)
|
||||
if repaint:
|
||||
self.update_display(session)
|
||||
#
|
||||
# def move_selected_to_playlist(self, session: Session, playlist_id: int) \
|
||||
# -> None:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user