From 6d197e97b147834fcaf3f817bcc9b29ab7e54839 Mon Sep 17 00:00:00 2001 From: bikash617 Date: Sun, 1 Dec 2013 13:23:34 +0400 Subject: [PATCH 1/3] populate from field feature implementation --- src/bitmessageqt/__init__.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index a3bf7ec3..a4621c75 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -2548,6 +2548,11 @@ class MyForm(QtGui.QMainWindow): currentInboxRow = self.ui.tableWidgetInbox.currentRow() toAddressAtCurrentInboxRow = str(self.ui.tableWidgetInbox.item( currentInboxRow, 0).data(Qt.UserRole).toPyObject()) + + + toAddressAtCurrentInboxRow_label = str(self.ui.tableWidgetInbox.item( + currentInboxRow, 0).text()) + fromAddressAtCurrentInboxRow = str(self.ui.tableWidgetInbox.item( currentInboxRow, 1).data(Qt.UserRole).toPyObject()) msgid = str(self.ui.tableWidgetInbox.item( @@ -2578,8 +2583,27 @@ class MyForm(QtGui.QMainWindow): if shared.safeConfigGetBoolean(toAddressAtCurrentInboxRow, 'chan'): print 'original sent to a chan. Setting the to address in the reply to the chan address.' self.ui.lineEditTo.setText(str(toAddressAtCurrentInboxRow)) - - self.ui.comboBoxSendFrom.setCurrentIndex(0) + + + + AllItems = [str(self.ui.comboBoxSendFrom.itemText(i)) for i in range(self.ui.comboBoxSendFrom.count())] + AllItems_address = [str(self.ui.comboBoxSendFrom.itemData(i).toPyObject()) for i in range(self.ui.comboBoxSendFrom.count())] + + isPresent_Label = False + for item in AllItems: + if toAddressAtCurrentInboxRow_label == item: + isPresent_Label = True + break; + if(isPresent_Label == True): + currentIndex = AllItems.index(toAddressAtCurrentInboxRow_label) + self.ui.comboBoxSendFrom.setCurrentIndex(currentIndex) + + else: + currentIndex = AllItems_address.index(toAddressAtCurrentInboxRow) + self.ui.comboBoxSendFrom.setCurrentIndex(currentIndex) + + + #self.ui.comboBoxSendFrom.setCurrentIndex(0) self.ui.textEditMessage.setText('\n\n------------------------------------------------------\n' + unicode(messageAtCurrentInboxRow, 'utf-8)')) if self.ui.tableWidgetInbox.item(currentInboxRow, 2).text()[0:3] in ['Re:', 'RE:']: self.ui.lineEditSubject.setText( -- 2.45.1 From 3c00a443ae9db620b5ece38f48b6b685f24c3f4f Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Wed, 25 Dec 2013 01:30:39 -0500 Subject: [PATCH 2/3] added error handling to previous commit: populate 'from' combo box when replying --- src/bitmessageqt/__init__.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index e4901139..2b0ad2cc 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -2655,24 +2655,29 @@ class MyForm(QtGui.QMainWindow): - AllItems = [str(self.ui.comboBoxSendFrom.itemText(i)) for i in range(self.ui.comboBoxSendFrom.count())] - AllItems_address = [str(self.ui.comboBoxSendFrom.itemData(i).toPyObject()) for i in range(self.ui.comboBoxSendFrom.count())] - + listOfLabelsInComboBoxSendFrom = [str(self.ui.comboBoxSendFrom.itemText(i)) for i in range(self.ui.comboBoxSendFrom.count())] + listOfAddressesInComboBoxSendFrom = [str(self.ui.comboBoxSendFrom.itemData(i).toPyObject()) for i in range(self.ui.comboBoxSendFrom.count())] + """ isPresent_Label = False - for item in AllItems: + for item in listOfLabelsInComboBoxSendFrom: if toAddressAtCurrentInboxRow_label == item: isPresent_Label = True break; - if(isPresent_Label == True): - currentIndex = AllItems.index(toAddressAtCurrentInboxRow_label) + """ + #if isPresent_Label: + if toAddressAtCurrentInboxRow_label in listOfLabelsInComboBoxSendFrom: + currentIndex = listOfLabelsInComboBoxSendFrom.index(toAddressAtCurrentInboxRow_label) self.ui.comboBoxSendFrom.setCurrentIndex(currentIndex) else: - currentIndex = AllItems_address.index(toAddressAtCurrentInboxRow) - self.ui.comboBoxSendFrom.setCurrentIndex(currentIndex) - - - #self.ui.comboBoxSendFrom.setCurrentIndex(0) + try: + currentIndex = listOfAddressesInComboBoxSendFrom.index(toAddressAtCurrentInboxRow) + self.ui.comboBoxSendFrom.setCurrentIndex(currentIndex) + except: + # The toAddressAtCurrentInboxRow isn't in our combo box which can happen if + # we are replying to a broadcast address or if the address is disabled. + self.ui.comboBoxSendFrom.setCurrentIndex(0) + self.ui.textEditMessage.setText('\n\n------------------------------------------------------\n' + unicode(messageAtCurrentInboxRow, 'utf-8)')) if self.ui.tableWidgetInbox.item(currentInboxRow, 2).text()[0:3] in ['Re:', 'RE:']: self.ui.lineEditSubject.setText( -- 2.45.1 From 9fdff73ee151df91b4e2dcf73d500f07922c2f6e Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Wed, 25 Dec 2013 01:48:01 -0500 Subject: [PATCH 3/3] simplify last commit --- src/bitmessageqt/__init__.py | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 2b0ad2cc..d43a22e9 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -2617,10 +2617,6 @@ class MyForm(QtGui.QMainWindow): currentInboxRow = self.ui.tableWidgetInbox.currentRow() toAddressAtCurrentInboxRow = str(self.ui.tableWidgetInbox.item( currentInboxRow, 0).data(Qt.UserRole).toPyObject()) - - - toAddressAtCurrentInboxRow_label = str(self.ui.tableWidgetInbox.item( - currentInboxRow, 0).text()) fromAddressAtCurrentInboxRow = str(self.ui.tableWidgetInbox.item( currentInboxRow, 1).data(Qt.UserRole).toPyObject()) @@ -2653,30 +2649,12 @@ class MyForm(QtGui.QMainWindow): print 'original sent to a chan. Setting the to address in the reply to the chan address.' self.ui.lineEditTo.setText(str(toAddressAtCurrentInboxRow)) - - - listOfLabelsInComboBoxSendFrom = [str(self.ui.comboBoxSendFrom.itemText(i)) for i in range(self.ui.comboBoxSendFrom.count())] listOfAddressesInComboBoxSendFrom = [str(self.ui.comboBoxSendFrom.itemData(i).toPyObject()) for i in range(self.ui.comboBoxSendFrom.count())] - """ - isPresent_Label = False - for item in listOfLabelsInComboBoxSendFrom: - if toAddressAtCurrentInboxRow_label == item: - isPresent_Label = True - break; - """ - #if isPresent_Label: - if toAddressAtCurrentInboxRow_label in listOfLabelsInComboBoxSendFrom: - currentIndex = listOfLabelsInComboBoxSendFrom.index(toAddressAtCurrentInboxRow_label) + if toAddressAtCurrentInboxRow in listOfAddressesInComboBoxSendFrom: + currentIndex = listOfAddressesInComboBoxSendFrom.index(toAddressAtCurrentInboxRow) self.ui.comboBoxSendFrom.setCurrentIndex(currentIndex) - else: - try: - currentIndex = listOfAddressesInComboBoxSendFrom.index(toAddressAtCurrentInboxRow) - self.ui.comboBoxSendFrom.setCurrentIndex(currentIndex) - except: - # The toAddressAtCurrentInboxRow isn't in our combo box which can happen if - # we are replying to a broadcast address or if the address is disabled. - self.ui.comboBoxSendFrom.setCurrentIndex(0) + self.ui.comboBoxSendFrom.setCurrentIndex(0) self.ui.textEditMessage.setText('\n\n------------------------------------------------------\n' + unicode(messageAtCurrentInboxRow, 'utf-8)')) if self.ui.tableWidgetInbox.item(currentInboxRow, 2).text()[0:3] in ['Re:', 'RE:']: -- 2.45.1