This commit is contained in:
Kovid Goyal 2014-01-06 13:13:11 +05:30
parent e3b0de4829
commit 1815ea092a

View File

@ -476,6 +476,7 @@ class CharDelegate(QStyledItemDelegate):
def __init__(self, parent=None): def __init__(self, parent=None):
QStyledItemDelegate.__init__(self, parent) QStyledItemDelegate.__init__(self, parent)
self.item_size = QSize(32, 32) self.item_size = QSize(32, 32)
self.np_pat = re.compile(r'(sp|j|nj|ss|fs|ds)$')
def sizeHint(self, option, index): def sizeHint(self, option, index):
return self.item_size return self.item_size
@ -501,10 +502,10 @@ class CharDelegate(QStyledItemDelegate):
painter.drawText(option.rect, Qt.AlignHCenter | Qt.AlignBottom | Qt.TextSingleLine, chr(charcode)) painter.drawText(option.rect, Qt.AlignHCenter | Qt.AlignBottom | Qt.TextSingleLine, chr(charcode))
def paint_non_printing(self, painter, option, charcode): def paint_non_printing(self, painter, option, charcode):
text = re.sub(r'(sp|j|nj|ss|fs|ds)$', r'\n\1', non_printing[charcode]) text = self.np_pat.sub(r'\n\1', non_printing[charcode])
painter.drawText(option.rect, Qt.AlignCenter | Qt.TextWordWrap | Qt.TextWrapAnywhere, text) painter.drawText(option.rect, Qt.AlignCenter | Qt.TextWordWrap | Qt.TextWrapAnywhere, text)
painter.setPen(QPen(Qt.DashLine)) painter.setPen(QPen(Qt.DashLine))
painter.drawRect(option.rect) painter.drawRect(option.rect.adjusted(1, 1, -1, -1))
class CharView(QListView): class CharView(QListView):