Fix: do not update account name from folder name

Last commit caused changes in unread count of folder to change the
account name. This is now fixed.
This commit is contained in:
mailchuck 2015-10-04 10:57:14 +02:00
parent 8c8795cfa4
commit 8ff7903964

View File

@ -535,7 +535,6 @@ class MyForm(QtGui.QMainWindow):
j += 1 j += 1
widget.setUnreadCount(unread) widget.setUnreadCount(unread)
if (tab == 'messages'): if (tab == 'messages'):
print "setting %s editable" % (toAddress)
widget.setFlags (widget.flags() | QtCore.Qt.ItemIsEditable) widget.setFlags (widget.flags() | QtCore.Qt.ItemIsEditable)
i += 1 i += 1
@ -3467,16 +3466,26 @@ more work your computer must do to send the message. A Time-To-Live of four or f
self.loadMessagelist(messagelist, account, folder) self.loadMessagelist(messagelist, account, folder)
def treeWidgetItemChanged(self, item, column): def treeWidgetItemChanged(self, item, column):
widget = self.getCurrentTreeWidget() # only for manual edits. automatic edits (setText) are ignored
if item.address == widget.currentItem().address: if column != 0:
return
# only account names
if not isinstance(item, Ui_AddressWidget):
return
# only currently selected item
if item.address != self.getCurrentTreeWidget().currentItem().address:
return
newLabel = str(item.text(0)) newLabel = str(item.text(0))
newLabel = newLabel.replace("(" + str(item.address) + ")", '') newLabel = newLabel.replace("(" + str(item.address) + ")", '')
newLabel = newLabel.rstrip() newLabel = newLabel.rstrip()
oldLabel = shared.config.get(str(item.address), 'label') oldLabel = shared.config.get(str(item.address), 'label')
oldLabel = oldLabel.replace("(" + str(item.address) + ")", '') oldLabel = oldLabel.replace("(" + str(item.address) + ")", '')
oldLabel = oldLabel.rstrip() oldLabel = oldLabel.rstrip()
# unchanged, do not do anything either
if newLabel == oldLabel: if newLabel == oldLabel:
return return
shared.config.set(str(item.address), 'label', newLabel) shared.config.set(str(item.address), 'label', newLabel)
item.updateText() item.updateText()
shared.writeKeysFile() shared.writeKeysFile()