From ccae351e6536d893ba68e72740b6164c7321df4a Mon Sep 17 00:00:00 2001 From: mailchuck Date: Sun, 4 Oct 2015 10:57:14 +0200 Subject: [PATCH] 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. --- src/bitmessageqt/__init__.py | 37 ++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index ab9ce330..0c7a7e95 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -535,7 +535,6 @@ class MyForm(QtGui.QMainWindow): j += 1 widget.setUnreadCount(unread) if (tab == 'messages'): - print "setting %s editable" % (toAddress) widget.setFlags (widget.flags() | QtCore.Qt.ItemIsEditable) i += 1 @@ -3469,19 +3468,29 @@ more work your computer must do to send the message. A Time-To-Live of four or f self.loadMessagelist(messagelist, account, folder) def treeWidgetItemChanged(self, item, column): - widget = self.getCurrentTreeWidget() - if item.address == widget.currentItem().address: - newLabel = str(item.text(0)) - newLabel = newLabel.replace("(" + str(item.address) + ")", '') - newLabel = newLabel.rstrip() - oldLabel = shared.config.get(str(item.address), 'label') - oldLabel = oldLabel.replace("(" + str(item.address) + ")", '') - oldLabel = oldLabel.rstrip() - if newLabel == oldLabel: - return - shared.config.set(str(item.address), 'label', newLabel) - item.updateText() - shared.writeKeysFile() + # only for manual edits. automatic edits (setText) are ignored + 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 = newLabel.replace("(" + str(item.address) + ")", '') + newLabel = newLabel.rstrip() + oldLabel = shared.config.get(str(item.address), 'label') + oldLabel = oldLabel.replace("(" + str(item.address) + ")", '') + oldLabel = oldLabel.rstrip() + # unchanged, do not do anything either + if newLabel == oldLabel: + return + + shared.config.set(str(item.address), 'label', newLabel) + item.updateText() + shared.writeKeysFile() def tableWidgetInboxItemClicked(self): folder = self.getCurrentFolder()