230 if role == Qt.DisplayRole: |
230 if role == Qt.DisplayRole: |
231 col = index.column() |
231 col = index.column() |
232 if col == 0: |
232 if col == 0: |
233 return str(id) |
233 return str(id) |
234 elif col == 1: |
234 elif col == 1: |
235 return chr(id) |
235 try: |
|
236 return chr(id) |
|
237 except ValueError: |
|
238 return chr(65533) |
236 elif col == 2: |
239 elif col == 2: |
237 return "0x{0:04x}".format(id) |
240 return "0x{0:04x}".format(id) |
238 elif col == 3: |
241 elif col == 3: |
239 if id in html_entities.codepoint2name: |
242 if id in html_entities.codepoint2name: |
240 return "&{0};".format(html_entities.codepoint2name[id]) |
243 return "&{0};".format(html_entities.codepoint2name[id]) |
241 elif col == 4: |
244 elif col == 4: |
242 return unicodedata.name(chr(id), '').title() |
245 try: |
|
246 return unicodedata.name(chr(id), '').title() |
|
247 except ValueError: |
|
248 return self.trUtf8("not possible: narrow Python build") |
243 |
249 |
244 if role == Qt.BackgroundColorRole: |
250 if role == Qt.BackgroundColorRole: |
245 if index.column() == 0: |
251 if index.column() == 0: |
246 return QColor(Qt.lightGray) |
252 return QColor(Qt.lightGray) |
247 |
253 |
248 if role == Qt.TextColorRole: |
254 if role == Qt.TextColorRole: |
249 char = chr(id) |
255 try: |
|
256 char = chr(id) |
|
257 except ValueError: |
|
258 char = chr(65533) |
250 if self.__isDigit(char): |
259 if self.__isDigit(char): |
251 return QColor(Qt.darkBlue) |
260 return QColor(Qt.darkBlue) |
252 elif self.__isLetter(char): |
261 elif self.__isLetter(char): |
253 return QColor(Qt.darkGreen) |
262 return QColor(Qt.darkGreen) |
254 elif self.__isMark(char): |
263 elif self.__isMark(char): |