UI/SymbolsWidget.py

changeset 5603
4f2dd0850803
parent 5587
ea526b78ee6c
child 5624
cdd346d8858b
equal deleted inserted replaced
5602:77755a5ea30c 5603:4f2dd0850803
358 358
359 @param index index to get data for (QModelIndex) 359 @param index index to get data for (QModelIndex)
360 @param role role of the data to retrieve (integer) 360 @param role role of the data to retrieve (integer)
361 @return requested data 361 @return requested data
362 """ 362 """
363 id = self.__tables[self.__currentTableIndex][0] + index.row() 363 symbolId = self.__tables[self.__currentTableIndex][0] + index.row()
364 364
365 if role == Qt.DisplayRole: 365 if role == Qt.DisplayRole:
366 col = index.column() 366 col = index.column()
367 if col == 0: 367 if col == 0:
368 return self.__locale.toString(id) 368 return self.__locale.toString(symbolId)
369 elif col == 1: 369 elif col == 1:
370 return chr(id) 370 return chr(symbolId)
371 elif col == 2: 371 elif col == 2:
372 return "0x{0:04x}".format(id) 372 return "0x{0:04x}".format(symbolId)
373 elif col == 3: 373 elif col == 3:
374 if id in html_entities.codepoint2name: 374 if symbolId in html_entities.codepoint2name:
375 return "&{0};".format(html_entities.codepoint2name[id]) 375 return "&{0};".format(
376 html_entities.codepoint2name[symbolId])
376 elif col == 4: 377 elif col == 4:
377 return unicodedata.name(chr(id), '').title() 378 return unicodedata.name(chr(symbolId), '').title()
378 379
379 if role == Qt.BackgroundColorRole: 380 if role == Qt.BackgroundColorRole:
380 if index.column() == 0: 381 if index.column() == 0:
381 return QColor(Qt.lightGray) 382 return QColor(Qt.lightGray)
382 383
383 if role == Qt.TextColorRole: 384 if role == Qt.TextColorRole:
384 char = chr(id) 385 char = chr(symbolId)
385 if self.__isDigit(char): 386 if self.__isDigit(char):
386 return QColor(Qt.darkBlue) 387 return QColor(Qt.darkBlue)
387 elif self.__isLetter(char): 388 elif self.__isLetter(char):
388 return QColor(Qt.darkGreen) 389 return QColor(Qt.darkGreen)
389 elif self.__isMark(char): 390 elif self.__isMark(char):
550 @pyqtSlot() 551 @pyqtSlot()
551 def on_symbolSpinBox_editingFinished(self): 552 def on_symbolSpinBox_editingFinished(self):
552 """ 553 """
553 Private slot to move the table to the entered symbol id. 554 Private slot to move the table to the entered symbol id.
554 """ 555 """
555 id = self.symbolSpinBox.value() 556 symbolId = self.symbolSpinBox.value()
556 first, last = self.__model.getTableBoundaries( 557 first, last = self.__model.getTableBoundaries(
557 self.__model.getTableIndex()) 558 self.__model.getTableIndex())
558 row = id - first 559 row = symbolId - first
559 self.symbolsTable.selectRow(row) 560 self.symbolsTable.selectRow(row)
560 self.symbolsTable.scrollTo( 561 self.symbolsTable.scrollTo(
561 self.__model.index(row, 0), QAbstractItemView.PositionAtCenter) 562 self.__model.index(row, 0), QAbstractItemView.PositionAtCenter)
562 563
563 @pyqtSlot(int) 564 @pyqtSlot(int)

eric ide

mercurial