Completer unicode fixes

This commit is contained in:
mailchuck 2016-04-29 11:43:40 +02:00 committed by Peter Surda
parent 46edb72b4f
commit 58481afda2
2 changed files with 7 additions and 7 deletions

View File

@ -1895,13 +1895,13 @@ class MyForm(settingsmixin.SMainWindow):
completerList = [] completerList = []
for address in sorted(oldRows, key = lambda x: oldRows[x][2], reverse = True): for address in sorted(oldRows, key = lambda x: oldRows[x][2], reverse = True):
if address in newRows: if address in newRows:
completerList.append(newRows[address][0] + " <" + address + ">") completerList.append(unicode(newRows[address][0], encoding="UTF-8") + " <" + address + ">")
newRows.pop(address) newRows.pop(address)
else: else:
self.ui.tableWidgetAddressBook.removeRow(oldRows[address][2]) self.ui.tableWidgetAddressBook.removeRow(oldRows[address][2])
for address in newRows: for address in newRows:
addRow(address, newRows[address][0], newRows[address][1]) addRow(address, newRows[address][0], newRows[address][1])
completerList.append(newRows[address][0] + " <" + address + ">") completerList.append(unicode(newRows[address][0], encoding="UTF-8") + " <" + address + ">")
# sort # sort
self.ui.tableWidgetAddressBook.sortByColumn(0, Qt.AscendingOrder) self.ui.tableWidgetAddressBook.sortByColumn(0, Qt.AscendingOrder)
@ -3187,8 +3187,8 @@ class MyForm(settingsmixin.SMainWindow):
if self.ui.lineEditTo.text() == '': if self.ui.lineEditTo.text() == '':
self.ui.lineEditTo.setText(stringToAdd) self.ui.lineEditTo.setText(stringToAdd)
else: else:
self.ui.lineEditTo.setText(str( self.ui.lineEditTo.setText(unicode(
self.ui.lineEditTo.text()) + '; ' + stringToAdd) self.ui.lineEditTo.text().toUtf8(), encoding="UTF-8") + '; ' + stringToAdd)
if listOfSelectedRows == {}: if listOfSelectedRows == {}:
self.statusBar().showMessage(_translate( self.statusBar().showMessage(_translate(
"MainWindow", "No addresses selected.")) "MainWindow", "No addresses selected."))

View File

@ -491,7 +491,7 @@ class AddressBookCompleter(QtGui.QCompleter):
def splitPath(self, path): def splitPath(self, path):
stringList = [] stringList = []
text = unicode(path.toUtf8()) text = unicode(path.toUtf8(), encoding="UTF-8")
splitIndex = rfind(text[0:self.widget().cursorPosition()], ";") + 1 splitIndex = rfind(text[0:self.widget().cursorPosition()], ";") + 1
str = text[splitIndex:self.widget().cursorPosition()] str = text[splitIndex:self.widget().cursorPosition()]
str = rstrip(lstrip(str)) str = rstrip(lstrip(str))
@ -499,8 +499,8 @@ class AddressBookCompleter(QtGui.QCompleter):
return stringList return stringList
def pathFromIndex(self, index): def pathFromIndex(self, index):
autoString = unicode(index.data(QtCore.Qt.EditRole).toString()) autoString = unicode(index.data(QtCore.Qt.EditRole).toString().toUtf8(), encoding="UTF-8")
text = unicode(self.widget().text().toUtf8()) text = unicode(self.widget().text().toUtf8(), encoding="UTF-8")
# If cursor position was saved, restore it, else save it # If cursor position was saved, restore it, else save it
if self.cursorPos != -1: if self.cursorPos != -1: