Reused AccountMixin.accountString() in other methods of MyForm
and simplified manipulations with addressbook selection.
This commit is contained in:
parent
9a58af4de5
commit
34ceb98d34
|
@ -3108,8 +3108,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
self.ui.lineEditTo.setText(str(acct.fromAddress))
|
self.ui.lineEditTo.setText(str(acct.fromAddress))
|
||||||
else:
|
else:
|
||||||
self.ui.lineEditTo.setText(
|
self.ui.lineEditTo.setText(
|
||||||
tableWidget.item(currentInboxRow, column_from).label +
|
tableWidget.item(currentInboxRow, column_from).accountString()
|
||||||
" <" + str(acct.fromAddress) + ">"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# If the previous message was to a chan then we should send our
|
# If the previous message was to a chan then we should send our
|
||||||
|
@ -3124,8 +3123,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
self.ui.lineEditTo.setText(str(toAddressAtCurrentInboxRow))
|
self.ui.lineEditTo.setText(str(toAddressAtCurrentInboxRow))
|
||||||
else:
|
else:
|
||||||
self.ui.lineEditTo.setText(
|
self.ui.lineEditTo.setText(
|
||||||
tableWidget.item(currentInboxRow, column_to).label +
|
tableWidget.item(currentInboxRow, column_to).accountString()
|
||||||
" <" + str(acct.toAddress) + ">"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
self.setSendFromComboBox(toAddressAtCurrentInboxRow)
|
self.setSendFromComboBox(toAddressAtCurrentInboxRow)
|
||||||
|
@ -3359,73 +3357,58 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
while self.ui.tableWidgetAddressBook.selectedIndexes() != []:
|
while self.ui.tableWidgetAddressBook.selectedIndexes() != []:
|
||||||
currentRow = self.ui.tableWidgetAddressBook.selectedIndexes()[
|
currentRow = self.ui.tableWidgetAddressBook.selectedIndexes()[
|
||||||
0].row()
|
0].row()
|
||||||
labelAtCurrentRow = self.ui.tableWidgetAddressBook.item(
|
item = self.ui.tableWidgetAddressBook.item(currentRow, 0)
|
||||||
currentRow, 0).text().toUtf8()
|
sqlExecute(
|
||||||
addressAtCurrentRow = self.ui.tableWidgetAddressBook.item(
|
'DELETE FROM addressbook WHERE label=? AND address=?',
|
||||||
currentRow, 1).text()
|
item.label, item.address)
|
||||||
sqlExecute('''DELETE FROM addressbook WHERE label=? AND address=?''',
|
|
||||||
str(labelAtCurrentRow), str(addressAtCurrentRow))
|
|
||||||
self.ui.tableWidgetAddressBook.removeRow(currentRow)
|
self.ui.tableWidgetAddressBook.removeRow(currentRow)
|
||||||
self.rerenderMessagelistFromLabels()
|
self.rerenderMessagelistFromLabels()
|
||||||
self.rerenderMessagelistToLabels()
|
self.rerenderMessagelistToLabels()
|
||||||
|
|
||||||
def on_action_AddressBookClipboard(self):
|
def on_action_AddressBookClipboard(self):
|
||||||
fullStringOfAddresses = ''
|
addresses_string = ''
|
||||||
listOfSelectedRows = {}
|
for item in self.getAddressbookSelectedItems():
|
||||||
for i in range(len(self.ui.tableWidgetAddressBook.selectedIndexes())):
|
if addresses_string == '':
|
||||||
listOfSelectedRows[
|
addresses_string = item.address
|
||||||
self.ui.tableWidgetAddressBook.selectedIndexes()[i].row()] = 0
|
|
||||||
for currentRow in listOfSelectedRows:
|
|
||||||
addressAtCurrentRow = self.ui.tableWidgetAddressBook.item(
|
|
||||||
currentRow, 1).text()
|
|
||||||
if fullStringOfAddresses == '':
|
|
||||||
fullStringOfAddresses = addressAtCurrentRow
|
|
||||||
else:
|
else:
|
||||||
fullStringOfAddresses += ', ' + str(addressAtCurrentRow)
|
addresses_string += ', ' + item.address
|
||||||
clipboard = QtGui.QApplication.clipboard()
|
clipboard = QtGui.QApplication.clipboard()
|
||||||
clipboard.setText(fullStringOfAddresses)
|
clipboard.setText(addresses_string)
|
||||||
|
|
||||||
def on_action_AddressBookSend(self):
|
def on_action_AddressBookSend(self):
|
||||||
listOfSelectedRows = {}
|
selected_items = self.getAddressbookSelectedItems()
|
||||||
for i in range(len(self.ui.tableWidgetAddressBook.selectedIndexes())):
|
|
||||||
listOfSelectedRows[
|
if not selected_items: # FIXME: impossible
|
||||||
self.ui.tableWidgetAddressBook.selectedIndexes()[i].row()] = 0
|
return self.updateStatusBar(_translate(
|
||||||
for currentRow in listOfSelectedRows:
|
|
||||||
addressAtCurrentRow = self.ui.tableWidgetAddressBook.item(
|
|
||||||
currentRow, 0).address
|
|
||||||
labelAtCurrentRow = self.ui.tableWidgetAddressBook.item(
|
|
||||||
currentRow, 0).label
|
|
||||||
stringToAdd = labelAtCurrentRow + " <" + addressAtCurrentRow + ">"
|
|
||||||
if self.ui.lineEditTo.text() == '':
|
|
||||||
self.ui.lineEditTo.setText(stringToAdd)
|
|
||||||
else:
|
|
||||||
self.ui.lineEditTo.setText(unicode(
|
|
||||||
self.ui.lineEditTo.text().toUtf8(), encoding="UTF-8") + '; ' + stringToAdd)
|
|
||||||
if listOfSelectedRows == {}:
|
|
||||||
self.updateStatusBar(_translate(
|
|
||||||
"MainWindow", "No addresses selected."))
|
"MainWindow", "No addresses selected."))
|
||||||
else:
|
|
||||||
self.statusbar.clearMessage()
|
addresses_string = unicode(
|
||||||
self.ui.tabWidget.setCurrentIndex(
|
self.ui.lineEditTo.text().toUtf8(), 'utf-8')
|
||||||
self.ui.tabWidget.indexOf(self.ui.send)
|
for item in selected_items:
|
||||||
)
|
address_string = item.accountString()
|
||||||
|
if not addresses_string:
|
||||||
|
addresses_string = address_string
|
||||||
|
else:
|
||||||
|
addresses_string += '; ' + address_string
|
||||||
|
|
||||||
|
self.ui.lineEditTo.setText(addresses_string)
|
||||||
|
self.statusbar.clearMessage()
|
||||||
|
self.ui.tabWidget.setCurrentIndex(
|
||||||
|
self.ui.tabWidget.indexOf(self.ui.send)
|
||||||
|
)
|
||||||
|
|
||||||
def on_action_AddressBookSubscribe(self):
|
def on_action_AddressBookSubscribe(self):
|
||||||
listOfSelectedRows = {}
|
for item in self.getAddressbookSelectedItems():
|
||||||
for i in range(len(self.ui.tableWidgetAddressBook.selectedIndexes())):
|
# Then subscribe to it...
|
||||||
listOfSelectedRows[self.ui.tableWidgetAddressBook.selectedIndexes()[i].row()] = 0
|
# provided it's not already in the address book
|
||||||
for currentRow in listOfSelectedRows:
|
if shared.isAddressInMySubscriptionsList(item.address):
|
||||||
addressAtCurrentRow = str(self.ui.tableWidgetAddressBook.item(currentRow,1).text())
|
|
||||||
# Then subscribe to it... provided it's not already in the address book
|
|
||||||
if shared.isAddressInMySubscriptionsList(addressAtCurrentRow):
|
|
||||||
self.updateStatusBar(_translate(
|
self.updateStatusBar(_translate(
|
||||||
"MainWindow",
|
"MainWindow",
|
||||||
"Error: You cannot add the same address to your"
|
"Error: You cannot add the same address to your"
|
||||||
" subscriptions twice. Perhaps rename the existing"
|
" subscriptions twice. Perhaps rename the existing"
|
||||||
" one if you want."))
|
" one if you want."))
|
||||||
continue
|
continue
|
||||||
labelAtCurrentRow = self.ui.tableWidgetAddressBook.item(currentRow,0).text().toUtf8()
|
self.addSubscription(item.address, item.label)
|
||||||
self.addSubscription(addressAtCurrentRow, labelAtCurrentRow)
|
|
||||||
self.ui.tabWidget.setCurrentIndex(
|
self.ui.tabWidget.setCurrentIndex(
|
||||||
self.ui.tabWidget.indexOf(self.ui.subscriptions)
|
self.ui.tabWidget.indexOf(self.ui.subscriptions)
|
||||||
)
|
)
|
||||||
|
@ -3696,6 +3679,13 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
currentItem = treeWidget.currentItem()
|
currentItem = treeWidget.currentItem()
|
||||||
currentItem.setForeground(0, brush)
|
currentItem.setForeground(0, brush)
|
||||||
|
|
||||||
|
def getAddressbookSelectedItems(self):
|
||||||
|
return [
|
||||||
|
self.ui.tableWidgetAddressBook.item(i.row(), 0)
|
||||||
|
for i in self.ui.tableWidgetAddressBook.selectedIndexes()
|
||||||
|
if i.column() == 0
|
||||||
|
]
|
||||||
|
|
||||||
def on_action_YourIdentitiesNew(self):
|
def on_action_YourIdentitiesNew(self):
|
||||||
self.click_NewAddressDialog()
|
self.click_NewAddressDialog()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user