mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 15:02:21 -04:00
Show tooltip on browser cells
Oftentimes, a cell's text is too long to be fully displayed inside the table, so show it as a tooltip.
This commit is contained in:
parent
de73232f0d
commit
a6fb72780a
1 changed files with 5 additions and 7 deletions
|
@ -225,17 +225,16 @@ class DataModel(QAbstractTableModel):
|
||||||
|
|
||||||
def data(self, index: QModelIndex = QModelIndex(), role: int = 0) -> Any:
|
def data(self, index: QModelIndex = QModelIndex(), role: int = 0) -> Any:
|
||||||
if not index.isValid():
|
if not index.isValid():
|
||||||
return
|
return QVariant()
|
||||||
if role == Qt.FontRole:
|
if role == Qt.FontRole:
|
||||||
if self.activeCols[index.column()] not in ("question", "answer", "noteFld"):
|
if self.activeCols[index.column()] not in ("question", "answer", "noteFld"):
|
||||||
return
|
return QVariant()
|
||||||
qfont = QFont()
|
qfont = QFont()
|
||||||
row = self.get_row(index)
|
row = self.get_row(index)
|
||||||
qfont.setFamily(row.font_name)
|
qfont.setFamily(row.font_name)
|
||||||
qfont.setPixelSize(row.font_size)
|
qfont.setPixelSize(row.font_size)
|
||||||
return qfont
|
return qfont
|
||||||
|
if role == Qt.TextAlignmentRole:
|
||||||
elif role == Qt.TextAlignmentRole:
|
|
||||||
align: Union[Qt.AlignmentFlag, int] = Qt.AlignVCenter
|
align: Union[Qt.AlignmentFlag, int] = Qt.AlignVCenter
|
||||||
if self.activeCols[index.column()] not in (
|
if self.activeCols[index.column()] not in (
|
||||||
"question",
|
"question",
|
||||||
|
@ -248,10 +247,9 @@ class DataModel(QAbstractTableModel):
|
||||||
):
|
):
|
||||||
align |= Qt.AlignHCenter
|
align |= Qt.AlignHCenter
|
||||||
return align
|
return align
|
||||||
elif role == Qt.DisplayRole or role == Qt.EditRole:
|
if role in (Qt.DisplayRole, Qt.ToolTipRole):
|
||||||
return self.get_cell(index).text
|
return self.get_cell(index).text
|
||||||
else:
|
return QVariant()
|
||||||
return
|
|
||||||
|
|
||||||
def headerData(
|
def headerData(
|
||||||
self, section: int, orientation: Qt.Orientation, role: int = 0
|
self, section: int, orientation: Qt.Orientation, role: int = 0
|
||||||
|
|
Loading…
Reference in a new issue