|
6 | 6 | import time |
7 | 7 | from typing import Any, Dict, List, Optional, Sequence, Union, cast |
8 | 8 |
|
| 9 | +import aqt |
9 | 10 | from anki.cards import Card, CardId |
10 | 11 | from anki.collection import BrowserColumns as Columns |
11 | 12 | from anki.collection import Collection |
@@ -43,6 +44,7 @@ def __init__(self, col: Collection, state: ItemState) -> None: |
43 | 44 | self._rows: Dict[int, CellRow] = {} |
44 | 45 | self._block_updates = False |
45 | 46 | self._stale_cutoff = 0.0 |
| 47 | + self._want_tooltips = aqt.mw.pm.show_browser_table_tooltips() |
46 | 48 |
|
47 | 49 | # Row Object Interface |
48 | 50 | ###################################################################### |
@@ -274,12 +276,14 @@ def data(self, index: QModelIndex = QModelIndex(), role: int = 0) -> Any: |
274 | 276 | qfont.setFamily(row.font_name) |
275 | 277 | qfont.setPixelSize(row.font_size) |
276 | 278 | return qfont |
277 | | - if role == Qt.TextAlignmentRole: |
| 279 | + elif role == Qt.TextAlignmentRole: |
278 | 280 | align: Union[Qt.AlignmentFlag, int] = Qt.AlignVCenter |
279 | 281 | if self.column_at(index).alignment == Columns.ALIGNMENT_CENTER: |
280 | 282 | align |= Qt.AlignHCenter |
281 | 283 | return align |
282 | | - if role in (Qt.DisplayRole, Qt.ToolTipRole): |
| 284 | + elif role == Qt.DisplayRole: |
| 285 | + return self.get_cell(index).text |
| 286 | + elif role == Qt.ToolTipRole and self._want_tooltips: |
283 | 287 | return self.get_cell(index).text |
284 | 288 | return QVariant() |
285 | 289 |
|
|
0 commit comments