Compare commits

...

4 Commits

Author SHA1 Message Date
Keith Edmunds
aef8cb5cb5 Fix hide played button 2025-02-15 10:39:26 +00:00
Keith Edmunds
53664857c1 "=" header fixes
Fixes: #276
2025-02-14 21:45:23 +00:00
Keith Edmunds
c8b571b38f Misc cleanups from query_tabs branch 2025-02-14 21:44:20 +00:00
Keith Edmunds
b3bd93d71c Only have one db.create_all(), and that in dbmanager 2025-02-14 21:39:10 +00:00
4 changed files with 11 additions and 9 deletions

View File

@ -50,7 +50,8 @@ class PlaydatesTable(Model):
lastplayed: Mapped[dt.datetime] = mapped_column(index=True)
track_id: Mapped[int] = mapped_column(ForeignKey("tracks.id"))
track: Mapped["TracksTable"] = relationship(
"TracksTable", back_populates="playdates"
"TracksTable",
back_populates="playdates",
)
def __repr__(self) -> str:
@ -103,7 +104,7 @@ class PlaylistRowsTable(Model):
)
playlist: Mapped[PlaylistsTable] = relationship(back_populates="rows")
track_id: Mapped[Optional[int]] = mapped_column(ForeignKey("tracks.id"))
track_id: Mapped[Optional[int]] = mapped_column(ForeignKey("tracks.id", ondelete="CASCADE"))
track: Mapped["TracksTable"] = relationship(
"TracksTable",
back_populates="playlistrows",

View File

@ -36,7 +36,6 @@ if DATABASE_URL is None:
if "unittest" in sys.modules and "sqlite" not in DATABASE_URL:
raise ValueError("Unit tests running on non-Sqlite database")
db = DatabaseManager.get_instance(DATABASE_URL, engine_options=Config.ENGINE_OPTIONS).db
db.create_all()
# Database classes

View File

@ -502,9 +502,7 @@ class Window(QMainWindow):
)
)
file_menu.addSeparator()
file_menu.addAction(
self.create_action("Exit", self.close)
) # Default action for closing
file_menu.addAction(self.create_action("Exit", self.close))
# Playlist Menu
playlist_menu = menu_bar.addMenu("&Playlist")
@ -768,7 +766,7 @@ class Window(QMainWindow):
def create_playlist_tab(self, playlist: Playlists) -> int:
"""
Take the passed proxy model, create a playlist tab and
Take the passed playlist, create a playlist tab and
add tab to display. Return index number of tab.
"""
@ -959,10 +957,10 @@ class Window(QMainWindow):
if self.hide_played_tracks:
self.hide_played_tracks = False
self.current.base_model.hide_played_tracks(False)
self.btnHidePlayed.setText("Hide played")
self.footer_section.btnHidePlayed.setText("Hide played")
else:
self.hide_played_tracks = True
self.btnHidePlayed.setText("Show played")
self.footer_section.btnHidePlayed.setText("Show played")
if Config.HIDE_PLAYED_MODE == Config.HIDE_PLAYED_MODE_SECTIONS:
self.active_tab().hide_played_sections()
else:

View File

@ -1279,6 +1279,10 @@ class PlaylistModel(QAbstractTableModel):
unplayed_count: int = 0
duration: int = 0
if rat.row_number == 0:
# Meaningless to have a subtotal on row 0
return Config.SUBTOTAL_ON_ROW_ZERO
# Show subtotal
for row_number in range(rat.row_number - 1, -1, -1):
row_rat = self.playlist_rows[row_number]