From f1f932bc7cd1d72805916c1f09d740054934f3c1 Mon Sep 17 00:00:00 2001 From: Dawn Date: Mon, 14 Sep 2026 10:38:30 +0200 Subject: [PATCH] feat: full-name tooltips on the glyph count column headers 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 --- src/aare/gui/models/user_sample_model.py | 12 ++++++++++++ tests/unit/gui/test_models.py | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/aare/gui/models/user_sample_model.py b/src/aare/gui/models/user_sample_model.py index 9751862f..866cd6c2 100644 --- a/src/aare/gui/models/user_sample_model.py +++ b/src/aare/gui/models/user_sample_model.py @@ -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( diff --git a/tests/unit/gui/test_models.py b/tests/unit/gui/test_models.py index e11ec6a6..56c215d4 100644 --- a/tests/unit/gui/test_models.py +++ b/tests/unit/gui/test_models.py @@ -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 + )