No more sessions in playlists!
Save/restore playlist column widths.
This commit is contained in:
parent
098ce7198e
commit
ed7ac0758c
@ -38,7 +38,6 @@ from audacity_controller import AudacityController
|
|||||||
from classes import (
|
from classes import (
|
||||||
ApplicationError,
|
ApplicationError,
|
||||||
Col,
|
Col,
|
||||||
InsertTrack,
|
|
||||||
MusicMusterSignals,
|
MusicMusterSignals,
|
||||||
PlaylistStyle,
|
PlaylistStyle,
|
||||||
TrackInfo
|
TrackInfo
|
||||||
@ -55,6 +54,7 @@ from log import log, log_call
|
|||||||
from models import db, Settings
|
from models import db, Settings
|
||||||
from playlistrow import TrackSequence
|
from playlistrow import TrackSequence
|
||||||
from playlistmodel import PlaylistModel, PlaylistProxyModel
|
from playlistmodel import PlaylistModel, PlaylistProxyModel
|
||||||
|
import repository
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from musicmuster import Window
|
from musicmuster import Window
|
||||||
@ -686,11 +686,10 @@ class PlaylistTab(QTableView):
|
|||||||
# Resize rows if necessary
|
# Resize rows if necessary
|
||||||
self.resizeRowsToContents()
|
self.resizeRowsToContents()
|
||||||
|
|
||||||
with db.Session() as session:
|
# Save settings
|
||||||
attr_name = f"playlist_col_{column_number}_width"
|
repository.set_setting(
|
||||||
record = Settings.get_setting(session, attr_name)
|
f"playlist_col_{column_number}_width", self.columnWidth(column_number)
|
||||||
record.f_int = self.columnWidth(column_number)
|
)
|
||||||
session.commit()
|
|
||||||
|
|
||||||
def _context_menu(self, pos):
|
def _context_menu(self, pos):
|
||||||
"""Display right-click menu"""
|
"""Display right-click menu"""
|
||||||
@ -1064,12 +1063,11 @@ class PlaylistTab(QTableView):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Last column is set to stretch so ignore it here
|
# Last column is set to stretch so ignore it here
|
||||||
with db.Session() as session:
|
|
||||||
for column_number in range(header.count() - 1):
|
for column_number in range(header.count() - 1):
|
||||||
attr_name = f"playlist_col_{column_number}_width"
|
attr_name = f"playlist_col_{column_number}_width"
|
||||||
record = Settings.get_setting(session, attr_name)
|
value = repository.get_setting(attr_name)
|
||||||
if record.f_int is not None:
|
if value is not None:
|
||||||
self.setColumnWidth(column_number, record.f_int)
|
self.setColumnWidth(column_number, value)
|
||||||
else:
|
else:
|
||||||
self.setColumnWidth(column_number, Config.DEFAULT_COLUMN_WIDTH)
|
self.setColumnWidth(column_number, Config.DEFAULT_COLUMN_WIDTH)
|
||||||
|
|
||||||
|
|||||||
@ -527,7 +527,7 @@ def get_playlist_row(playlistrow_id: int) -> PlaylistRowDTO | None:
|
|||||||
|
|
||||||
|
|
||||||
def get_playlist_rows(
|
def get_playlist_rows(
|
||||||
playlist_id: int, check_playlist_itegrity=True
|
playlist_id: int, check_playlist_itegrity: bool = True
|
||||||
) -> list[PlaylistRowDTO]:
|
) -> list[PlaylistRowDTO]:
|
||||||
# Alias PlaydatesTable for subquery
|
# Alias PlaydatesTable for subquery
|
||||||
LatestPlaydate = aliased(Playdates)
|
LatestPlaydate = aliased(Playdates)
|
||||||
@ -724,7 +724,7 @@ def get_setting(name: str) -> int | None:
|
|||||||
with db.Session() as session:
|
with db.Session() as session:
|
||||||
record = session.execute(
|
record = session.execute(
|
||||||
select(Settings).where(Settings.name == name)
|
select(Settings).where(Settings.name == name)
|
||||||
).one_or_none()
|
).scalars().one_or_none()
|
||||||
if not record:
|
if not record:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -739,7 +739,7 @@ def set_setting(name: str, value: int) -> None:
|
|||||||
with db.Session() as session:
|
with db.Session() as session:
|
||||||
record = session.execute(
|
record = session.execute(
|
||||||
select(Settings).where(Settings.name == name)
|
select(Settings).where(Settings.name == name)
|
||||||
).one_or_none()
|
).scalars().one_or_none()
|
||||||
if not record:
|
if not record:
|
||||||
record = Settings(session=session, name=name)
|
record = Settings(session=session, name=name)
|
||||||
if not record:
|
if not record:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user