v0.67.3: the rating column is never narrower than five stars

This commit is contained in:
2026-10-19 22:10:47 -07:00
parent 2e5ebf0b0b
commit 1d215fd045
3 changed files with 56 additions and 4 deletions
+35
View File
@@ -0,0 +1,35 @@
"""Round 100: the rating column is never narrower than five stars."""
from PyQt6.QtGui import QFontMetrics
from lintunes.gui.track_table import TrackTableView, rating_min_width
from lintunes.models.playlist import PlaylistSettings
def _view(widths):
view = TrackTableView(playlist_mode=False)
view.apply_settings(PlaylistSettings(
visible_columns=["name", "rating", "date_added"], sort_column="name",
column_widths=widths))
return view
def test_saved_narrow_width_is_widened(qapp):
view = _view({"rating": 20})
least = rating_min_width(QFontMetrics(view.font()))
assert view.columnWidth(view.model_.fields.index("rating")) == least
def test_dragging_narrower_snaps_back_and_saves_the_minimum(qapp):
view = _view({})
col = view.model_.fields.index("rating")
saved = []
view.column_width_changed.connect(lambda f, w: saved.append((f, w)))
view.horizontalHeader().resizeSection(col, 10)
least = rating_min_width(QFontMetrics(view.font()))
assert view.columnWidth(col) == least
assert saved == [("rating", least)]
def test_wider_widths_are_left_alone(qapp):
view = _view({"rating": 200})
assert view.columnWidth(view.model_.fields.index("rating")) == 200