Use AddAddressDialog for "Add sender to your Addres Book" context menu
This commit is contained in:
parent
9e79386595
commit
81c80aa98f
|
@ -2138,25 +2138,31 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
self.statusBar().showMessage(_translate(
|
self.statusBar().showMessage(_translate(
|
||||||
"MainWindow", "Sending email gateway registration request"), 10000)
|
"MainWindow", "Sending email gateway registration request"), 10000)
|
||||||
|
|
||||||
def click_pushButtonAddAddressBook(self):
|
def click_pushButtonAddAddressBook(self, dialog=None):
|
||||||
self.AddAddressDialogInstance = AddAddressDialog(self)
|
if not dialog:
|
||||||
if self.AddAddressDialogInstance.exec_():
|
dialog = AddAddressDialog(self)
|
||||||
if self.AddAddressDialogInstance.ui.labelAddressCheck.text() == _translate("MainWindow", "Address is valid."):
|
if dialog.exec_():
|
||||||
|
if dialog.ui.labelAddressCheck.text() == \
|
||||||
|
_translate("MainWindow", "Address is valid."):
|
||||||
# First we must check to see if the address is already in the
|
# First we must check to see if the address is already in the
|
||||||
# address book. The user cannot add it again or else it will
|
# address book. The user cannot add it again or else it will
|
||||||
# cause problems when updating and deleting the entry.
|
# cause problems when updating and deleting the entry.
|
||||||
address = addBMIfNotPresent(str(
|
address = addBMIfNotPresent(
|
||||||
self.AddAddressDialogInstance.ui.lineEditAddress.text()))
|
str(dialog.ui.lineEditAddress.text()))
|
||||||
label = self.AddAddressDialogInstance.ui.newAddressLabel.text().toUtf8()
|
label = str(dialog.ui.newAddressLabel.text().toUtf8())
|
||||||
self.addEntryToAddressBook(address,label)
|
self.addEntryToAddressBook(address, label)
|
||||||
else:
|
else:
|
||||||
self.statusBar().showMessage(_translate(
|
self.statusBar().showMessage(_translate(
|
||||||
"MainWindow", "The address you entered was invalid. Ignoring it."), 10000)
|
"MainWindow",
|
||||||
|
"The address you entered was invalid. Ignoring it."
|
||||||
|
), 10000)
|
||||||
|
|
||||||
def addEntryToAddressBook(self,address,label):
|
def addEntryToAddressBook(self, address, label):
|
||||||
queryreturn = sqlQuery('''select * from addressbook where address=?''', address)
|
queryreturn = sqlQuery(
|
||||||
|
'''select * from addressbook where address=?''', address)
|
||||||
if queryreturn == []:
|
if queryreturn == []:
|
||||||
sqlExecute('''INSERT INTO addressbook VALUES (?,?)''', str(label), address)
|
sqlExecute('''INSERT INTO addressbook VALUES (?,?)''',
|
||||||
|
label, address)
|
||||||
self.rerenderMessagelistFromLabels()
|
self.rerenderMessagelistFromLabels()
|
||||||
self.rerenderMessagelistToLabels()
|
self.rerenderMessagelistToLabels()
|
||||||
self.rerenderAddressBook()
|
self.rerenderAddressBook()
|
||||||
|
@ -2935,19 +2941,10 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
# tableWidget.item(currentRow,1).data(Qt.UserRole).toPyObject()
|
# tableWidget.item(currentRow,1).data(Qt.UserRole).toPyObject()
|
||||||
addressAtCurrentInboxRow = tableWidget.item(
|
addressAtCurrentInboxRow = tableWidget.item(
|
||||||
currentInboxRow, 1).data(Qt.UserRole)
|
currentInboxRow, 1).data(Qt.UserRole)
|
||||||
# Let's make sure that it isn't already in the address book
|
self.ui.tabWidget.setCurrentIndex(1)
|
||||||
queryreturn = sqlQuery('''select * from addressbook where address=?''',
|
dialog = AddAddressDialog(self)
|
||||||
addressAtCurrentInboxRow)
|
dialog.ui.lineEditAddress.setText(addressAtCurrentInboxRow)
|
||||||
if queryreturn == []:
|
self.click_pushButtonAddAddressBook(dialog)
|
||||||
sqlExecute('''INSERT INTO addressbook VALUES (?,?)''',
|
|
||||||
'--New entry. Change label in Address Book.--',
|
|
||||||
addressAtCurrentInboxRow)
|
|
||||||
self.rerenderAddressBook()
|
|
||||||
self.statusBar().showMessage(_translate(
|
|
||||||
"MainWindow", "Entry added to the Address Book. Edit the label to your liking."), 10000)
|
|
||||||
else:
|
|
||||||
self.statusBar().showMessage(_translate(
|
|
||||||
"MainWindow", "Error: You cannot add the same address to your address book twice. Try renaming the existing one if you want."), 10000)
|
|
||||||
|
|
||||||
def on_action_InboxAddSenderToBlackList(self):
|
def on_action_InboxAddSenderToBlackList(self):
|
||||||
tableWidget = self.getCurrentMessagelist()
|
tableWidget = self.getCurrentMessagelist()
|
||||||
|
|
Reference in New Issue
Block a user