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