feat: full-name tooltips on the glyph count column headers
CI / lint (push) Successful in 32s
Docs build and publish / docker (push) Successful in 15s
CI / test (3.12) (push) Canceled after 36s
CI / test (3.13) (push) Canceled after 32s
CI / test-with-beamline-plugins (pxiii_bec) (push) Canceled after 22s
CI / test (3.14) (push) Canceled after 31s
CI / test-with-beamline-plugins (pxi_bec) (push) Canceled after 27s
CI / test-with-beamline-plugins (pxii_bec) (push) Canceled after 26s
CI / test-with-coverage (push) Canceled after 21s
CI / coverage-analysis (push) Canceled after 0s
Build and Publish / release (push) Successful in 22s

The sample list's Mount/Gridscan/Screening/Rotation count columns show
only a glyph in the header to save width; hovering now shows the full
name via ToolTipRole. Text headers stay tooltip-free.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit was merged in pull request #224.
This commit is contained in:
2026-09-14 13:23:32 +02:00
committed by perl_d
co-authored by Claude Fable 5
parent 1fe3c7f4e5
commit f1f932bc7c
2 changed files with 30 additions and 0 deletions
+12
View File
@@ -1,4 +1,5 @@
import re
from typing import ClassVar
from aarecommon.config.logger import setup_logger
from aarecommon.models.models import SampleShortInfo, SampleShortInfoList
@@ -235,12 +236,23 @@ class UserSampleSpreadsheet(QAbstractTableModel):
[Qt.ItemDataRole.BackgroundRole, Qt.ItemDataRole.ForegroundRole],
)
# Hover tooltips for the glyph-only count columns — the icons save header
# width but don't explain themselves.
HEADER_TOOLTIPS: ClassVar[dict[str, str]] = {
"⧂": "Mount count",
"▦": "Gridscan count",
"⌕": "Screening count",
"↻": "Rotation count",
}
def headerData(self, section, orientation, role=None):
if role == Qt.ItemDataRole.DisplayRole:
if orientation == Qt.Orientation.Horizontal: # Column header
return self.header[section] if self.header else f"Column {section + 1}"
if orientation == Qt.Orientation.Vertical: # Row header
return str(section + 1) # Row numbers start from 1
if role == Qt.ItemDataRole.ToolTipRole and orientation == Qt.Orientation.Horizontal:
return self.HEADER_TOOLTIPS.get(self.header[section])
return None
def updateCurrentSample(
+18
View File
@@ -304,3 +304,21 @@ def test_spreadsheet_param_columns(status_model):
model.sort(osc, Qt.SortOrder.AscendingOrder)
assert model.get_id(0).db_id == 1
assert model.headerData(hdr.index("Comment"), Qt.Orientation.Horizontal, 0) == "Comment"
def test_glyph_count_headers_have_full_name_tooltips(status_model):
model = status_model
tip = lambda glyph: model.headerData(
model.header.index(glyph), Qt.Orientation.Horizontal, Qt.ItemDataRole.ToolTipRole
)
assert tip("⧂") == "Mount count"
assert tip("▦") == "Gridscan count"
assert tip("⌕") == "Screening count"
assert tip("↻") == "Rotation count"
# Text headers explain themselves: no tooltip.
assert (
model.headerData(
model.header.index("Comment"), Qt.Orientation.Horizontal, Qt.ItemDataRole.ToolTipRole
)
is None
)