From a02ea142336e3dfdfdd4ab1578b55f90cd6027c4 Mon Sep 17 00:00:00 2001 From: mailchuck Date: Sat, 14 Nov 2015 01:14:10 +0100 Subject: [PATCH] Blacklist through context menu Fixes #101 --- src/bitmessageqt/__init__.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 67838836..2299c524 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -142,6 +142,10 @@ class MyForm(settingsmixin.SMainWindow): _translate( "MainWindow", "Add sender to your Address Book"), self.on_action_InboxAddSenderToAddressBook) + self.actionAddSenderToBlackList = self.ui.inboxContextMenuToolbar.addAction( + _translate( + "MainWindow", "Add sender to your Blacklist"), + self.on_action_InboxAddSenderToBlackList) self.actionTrashInboxMessage = self.ui.inboxContextMenuToolbar.addAction( _translate("MainWindow", "Move to Trash"), self.on_action_InboxTrash) @@ -3074,6 +3078,28 @@ class MyForm(settingsmixin.SMainWindow): 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.")) + def on_action_InboxAddSenderToBlackList(self): + tableWidget = self.getCurrentMessagelist() + if not tableWidget: + return + currentInboxRow = tableWidget.currentRow() + # tableWidget.item(currentRow,1).data(Qt.UserRole).toPyObject() + addressAtCurrentInboxRow = str(tableWidget.item( + currentInboxRow, 1).data(Qt.UserRole).toPyObject()) + # Let's make sure that it isn't already in the address book + queryreturn = sqlQuery('''select * from blacklist where address=?''', + addressAtCurrentInboxRow) + if queryreturn == []: + sqlExecute('''INSERT INTO blacklist VALUES (?,?, ?)''', + '--New entry. Change label in Blacklist.--', + addressAtCurrentInboxRow, True) + self.rerenderBlackWhiteList() + self.statusBar().showMessage(_translate( + "MainWindow", "Entry added to the blacklist. Edit the label to your liking.")) + else: + self.statusBar().showMessage(_translate( + "MainWindow", "Error: You cannot add the same address to your blacklist twice. Try renaming the existing one if you want.")) + # Send item on the Inbox tab to trash def on_action_InboxTrash(self): tableWidget = self.getCurrentMessagelist() @@ -3751,6 +3777,8 @@ class MyForm(settingsmixin.SMainWindow): self.popMenuInbox.addAction(self.actionReply) self.popMenuInbox.addAction(self.actionAddSenderToAddressBook) self.popMenuInbox.addSeparator() + self.popMenuInbox.addAction(self.actionAddSenderToBlackList) + self.popMenuInbox.addSeparator() self.popMenuInbox.addAction(self.actionSaveMessageAs) if currentFolder == "trash": self.popMenuInbox.addAction(self.actionUndeleteTrashedMessage)