diff -r 27f636beebad -r 2c730d5fd177 eric6/UI/SymbolsWidget.py --- a/eric6/UI/SymbolsWidget.py Mon Mar 01 17:48:43 2021 +0100 +++ b/eric6/UI/SymbolsWidget.py Tue Mar 02 17:17:09 2021 +0100 @@ -330,21 +330,25 @@ self.__currentTableIndex = index self.endResetModel() - def headerData(self, section, orientation, role=Qt.DisplayRole): + def headerData(self, section, orientation, + role=Qt.ItemDataRole.DisplayRole): """ Public method to get header data from the model. @param section section number (integer) @param orientation orientation (Qt.Orientation) - @param role role of the data to retrieve (integer) + @param role role of the data to retrieve (Qt.ItemDataRole) @return requested data """ - if orientation == Qt.Horizontal and role == Qt.DisplayRole: + if ( + orientation == Qt.Orientation.Horizontal and + role == Qt.ItemDataRole.DisplayRole + ): return self.__headerData[section] return QAbstractTableModel.headerData(self, section, orientation, role) - def data(self, index, role=Qt.DisplayRole): + def data(self, index, role=Qt.ItemDataRole.DisplayRole): """ Public method to get data from the model. @@ -354,7 +358,7 @@ """ symbolId = self.__tables[self.__currentTableIndex][0] + index.row() - if role == Qt.DisplayRole: + if role == Qt.ItemDataRole.DisplayRole: col = index.column() if col == 0: return self.__locale.toString(symbolId) @@ -369,28 +373,28 @@ elif col == 4: return unicodedata.name(chr(symbolId), '').title() - if role == Qt.BackgroundColorRole: + if role == Qt.ItemDataRole.BackgroundColorRole: if index.column() == 0: - return QColor(Qt.lightGray) + return QColor(Qt.GlobalColor.lightGray) - if role == Qt.TextColorRole: + if role == Qt.ItemDataRole.TextColorRole: char = chr(symbolId) if self.__isDigit(char): - return QColor(Qt.darkBlue) + return QColor(Qt.GlobalColor.darkBlue) elif self.__isLetter(char): - return QColor(Qt.darkGreen) + return QColor(Qt.GlobalColor.darkGreen) elif self.__isMark(char): - return QColor(Qt.darkRed) + return QColor(Qt.GlobalColor.darkRed) elif self.__isSymbol(char): - return QColor(Qt.black) + return QColor(Qt.GlobalColor.black) elif self.__isPunct(char): - return QColor(Qt.darkMagenta) + return QColor(Qt.GlobalColor.darkMagenta) else: - return QColor(Qt.darkGray) + return QColor(Qt.GlobalColor.darkGray) - if role == Qt.TextAlignmentRole: + if role == Qt.ItemDataRole.TextAlignmentRole: if index.column() in [0, 1, 3]: - return Qt.AlignHCenter + return Qt.AlignmentFlag.AlignHCenter return None @@ -501,7 +505,7 @@ self.__currentRowChanged) self.symbolsTable.horizontalHeader().setSectionResizeMode( - QHeaderView.Fixed) + QHeaderView.ResizeMode.Fixed) fm = self.fontMetrics() try: em = fm.horizontalAdvance("M") @@ -523,10 +527,13 @@ index = self.__model.index( int(Preferences.Prefs.settings.value("Symbols/Top", 0)), 0) - self.symbolsTable.scrollTo(index, QAbstractItemView.PositionAtTop) + self.symbolsTable.scrollTo( + index, QAbstractItemView.ScrollHint.PositionAtTop) self.symbolsTable.selectionModel().setCurrentIndex( index, - QItemSelectionModel.SelectCurrent | QItemSelectionModel.Rows) + QItemSelectionModel.SelectionFlag.SelectCurrent | + QItemSelectionModel.SelectionFlag.Rows + ) @pyqtSlot(QModelIndex) def on_symbolsTable_activated(self, index): @@ -550,7 +557,8 @@ row = symbolId - first self.symbolsTable.selectRow(row) self.symbolsTable.scrollTo( - self.__model.index(row, 0), QAbstractItemView.PositionAtCenter) + self.__model.index(row, 0), + QAbstractItemView.ScrollHint.PositionAtCenter) @pyqtSlot(int) def on_tableCombo_currentIndexChanged(self, index):