def data(self, index: QModelIndex, role=Qt.DisplayRole):
if not index.isValid():
return None
i = index.row()
j = index.column()
if role == Qt.DisplayRole and self.display_data:
try:
if self.proto_view == 0:
return self.display_data[i][j]
elif self.proto_view == 1:
return "{0:x}".format(self.display_data[i][j])
elif self.proto_view == 2:
return chr(self.display_data[i][j])
except IndexError:
return None
elif role == Qt.TextAlignmentRole:
if i in self.first_messages:
return Qt.AlignHCenter + Qt.AlignBottom
else:
return Qt.AlignCenter
elif role == Qt.BackgroundColorRole:
return self.background_colors[i, j]
elif role == Qt.FontRole:
font = QFont()
font.setBold(self.bold_fonts[i, j])
font.setItalic(self.italic_fonts[i, j])
return font
elif role == Qt.TextColorRole:
return self.text_colors[i, j]
elif role == Qt.ToolTipRole:
return self.get_tooltip(i, j)
else:
return None
评论列表
文章目录