UTF fixes
Label edits now accept and save utf8 characters. Addresses #180 Still need to check how it behaves on invalid chars.
This commit is contained in:
parent
47bc85f0b6
commit
da036c6b6b
|
@ -3998,7 +3998,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
if item.type == AccountMixin.ALL:
|
if item.type == AccountMixin.ALL:
|
||||||
return
|
return
|
||||||
|
|
||||||
newLabel = str(item.text(0))
|
newLabel = unicode(item.text(0), 'utf-8', 'ignore')
|
||||||
oldLabel = item.defaultLabel()
|
oldLabel = item.defaultLabel()
|
||||||
|
|
||||||
# unchanged, do not do anything either
|
# unchanged, do not do anything either
|
||||||
|
|
|
@ -171,7 +171,7 @@ class Ui_AddressWidget(QtGui.QTreeWidgetItem, AccountMixin, SettingsMixin):
|
||||||
return unicode(str(QtGui.QApplication.translate("MainWindow", "All accounts")), 'utf-8')
|
return unicode(str(QtGui.QApplication.translate("MainWindow", "All accounts")), 'utf-8')
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
return unicode(shared.config.get(self.address, 'label'), 'utf-8)')
|
return unicode(shared.config.get(self.address, 'label'), 'utf-8', 'ignore')
|
||||||
except:
|
except:
|
||||||
return unicode(self.address, 'utf-8')
|
return unicode(self.address, 'utf-8')
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ class Ui_AddressWidget(QtGui.QTreeWidgetItem, AccountMixin, SettingsMixin):
|
||||||
def setData(self, column, role, value):
|
def setData(self, column, role, value):
|
||||||
if role == QtCore.Qt.EditRole and self.type != AccountMixin.SUBSCRIPTION:
|
if role == QtCore.Qt.EditRole and self.type != AccountMixin.SUBSCRIPTION:
|
||||||
if isinstance(value, QtCore.QVariant):
|
if isinstance(value, QtCore.QVariant):
|
||||||
shared.config.set(str(self.address), 'label', str(value.toString()))
|
shared.config.set(str(self.address), 'label', str(value.toString().toUtf8()))
|
||||||
else:
|
else:
|
||||||
shared.config.set(str(self.address), 'label', str(value))
|
shared.config.set(str(self.address), 'label', str(value))
|
||||||
shared.writeKeysFile()
|
shared.writeKeysFile()
|
||||||
|
@ -236,8 +236,8 @@ class Ui_AddressWidget(QtGui.QTreeWidgetItem, AccountMixin, SettingsMixin):
|
||||||
if self.treeWidget().header().sortIndicatorOrder() == QtCore.Qt.DescendingOrder:
|
if self.treeWidget().header().sortIndicatorOrder() == QtCore.Qt.DescendingOrder:
|
||||||
reverse = True
|
reverse = True
|
||||||
if self._getSortRank() == other._getSortRank():
|
if self._getSortRank() == other._getSortRank():
|
||||||
x = self._getLabel().decode('utf-8').lower()
|
x = self._getLabel().lower()
|
||||||
y = other._getLabel().decode('utf-8').lower()
|
y = other._getLabel().lower()
|
||||||
return x < y
|
return x < y
|
||||||
return (not reverse if self._getSortRank() < other._getSortRank() else reverse)
|
return (not reverse if self._getSortRank() < other._getSortRank() else reverse)
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ class Ui_SubscriptionWidget(Ui_AddressWidget, AccountMixin):
|
||||||
if queryreturn != []:
|
if queryreturn != []:
|
||||||
for row in queryreturn:
|
for row in queryreturn:
|
||||||
retval, = row
|
retval, = row
|
||||||
return unicode(retval, 'utf-8')
|
return unicode(retval, 'utf-8', 'ignore')
|
||||||
return unicode(self.address, 'utf-8')
|
return unicode(self.address, 'utf-8')
|
||||||
|
|
||||||
def setType(self):
|
def setType(self):
|
||||||
|
@ -270,10 +270,11 @@ class Ui_SubscriptionWidget(Ui_AddressWidget, AccountMixin):
|
||||||
|
|
||||||
def setData(self, column, role, value):
|
def setData(self, column, role, value):
|
||||||
if role == QtCore.Qt.EditRole:
|
if role == QtCore.Qt.EditRole:
|
||||||
|
from debug import logger
|
||||||
if isinstance(value, QtCore.QVariant):
|
if isinstance(value, QtCore.QVariant):
|
||||||
label = str(value.toString())
|
label = str(value.toString().toUtf8()).decode('utf-8', 'ignore')
|
||||||
else:
|
else:
|
||||||
label = str(value)
|
label = unicode(value, 'utf-8', 'ignore')
|
||||||
sqlExecute(
|
sqlExecute(
|
||||||
'''UPDATE subscriptions SET label=? WHERE address=?''',
|
'''UPDATE subscriptions SET label=? WHERE address=?''',
|
||||||
label, self.address)
|
label, self.address)
|
||||||
|
@ -300,7 +301,7 @@ class MessageList_AddressWidget(QtGui.QTableWidgetItem, AccountMixin, SettingsMi
|
||||||
queryreturn = None
|
queryreturn = None
|
||||||
if self.type in (AccountMixin.NORMAL, AccountMixin.CHAN, AccountMixin.MAILINGLIST):
|
if self.type in (AccountMixin.NORMAL, AccountMixin.CHAN, AccountMixin.MAILINGLIST):
|
||||||
try:
|
try:
|
||||||
newLabel = unicode(shared.config.get(self.address, 'label'), 'utf-8)')
|
newLabel = unicode(shared.config.get(self.address, 'label'), 'utf-8', 'ignore')
|
||||||
except:
|
except:
|
||||||
queryreturn = sqlQuery(
|
queryreturn = sqlQuery(
|
||||||
'''select label from addressbook where address=?''', self.address)
|
'''select label from addressbook where address=?''', self.address)
|
||||||
|
@ -455,7 +456,7 @@ class Ui_AddressBookWidgetItem(QtGui.QTableWidgetItem, AccountMixin):
|
||||||
if self.tableWidget().horizontalHeader().sortIndicatorOrder() == QtCore.Qt.DescendingOrder:
|
if self.tableWidget().horizontalHeader().sortIndicatorOrder() == QtCore.Qt.DescendingOrder:
|
||||||
reverse = True
|
reverse = True
|
||||||
if self.type == other.type:
|
if self.type == other.type:
|
||||||
return self.label.decode('utf-8').lower() < other.label.decode('utf-8').lower()
|
return self.label.lower() < other.label.lower()
|
||||||
else:
|
else:
|
||||||
return (not reverse if self.type < other.type else reverse)
|
return (not reverse if self.type < other.type else reverse)
|
||||||
return super(QtGui.QTableWidgetItem, self).__lt__(other)
|
return super(QtGui.QTableWidgetItem, self).__lt__(other)
|
||||||
|
|
Reference in New Issue
Block a user