Book list: When displaying yes/no custom columns, render the icon in the center of the column. Fixes #1992261 [Place checkmarks for custom columns in the center](https://bugs.launchpad.net/calibre/+bug/1992261)

This commit is contained in:
Kovid Goyal 2022-10-09 10:25:23 +05:30
parent 37fd854e33
commit e708be5e61
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 10 additions and 1 deletions

View File

@ -747,6 +747,15 @@ class CcBoolDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
else 1 if not val else 0
editor.setCurrentIndex(val)
def paint(self, painter, option, index):
text, icon = index.data(Qt.ItemDataRole.DisplayRole), index.data(Qt.ItemDataRole.DecorationRole)
if (not text and not icon) or text or not icon:
return super().paint(painter, option, index)
dummy = index.model().index(-1, -1)
super().paint(painter, option, dummy)
style = QApplication.style()
style.drawItemPixmap(painter, option.rect, Qt.AlignmentFlag.AlignCenter, icon)
# }}}

View File

@ -927,7 +927,7 @@ class BooksModel(QAbstractTableModel): # {{{
return (None if v is None else (_('Yes') if v else _('No')))
else:
def func(idx):
return(None)
return None
else:
def func(idx):
return None