Trash undelete

Fixes #55
This commit is contained in:
mailchuck 2015-11-01 10:56:37 +01:00
parent 9629abf102
commit b3877a9413
No known key found for this signature in database
GPG Key ID: B6311FA753FBF089

View File

@ -147,6 +147,9 @@ class MyForm(QtGui.QMainWindow):
self.actionTrashInboxMessage = self.ui.inboxContextMenuToolbar.addAction( self.actionTrashInboxMessage = self.ui.inboxContextMenuToolbar.addAction(
_translate("MainWindow", "Move to Trash"), _translate("MainWindow", "Move to Trash"),
self.on_action_InboxTrash) self.on_action_InboxTrash)
self.actionUndeleteTrashedMessage = self.ui.inboxContextMenuToolbar.addAction(
_translate("MainWindow", "Undelete"),
self.on_action_TrashUndelete)
self.actionForceHtml = self.ui.inboxContextMenuToolbar.addAction( self.actionForceHtml = self.ui.inboxContextMenuToolbar.addAction(
_translate( _translate(
"MainWindow", "View HTML code as formatted text"), "MainWindow", "View HTML code as formatted text"),
@ -179,16 +182,6 @@ class MyForm(QtGui.QMainWindow):
'customContextMenuRequested(const QPoint&)'), 'customContextMenuRequested(const QPoint&)'),
self.on_context_menuInbox) self.on_context_menuInbox)
self.popMenuInbox = QtGui.QMenu(self)
self.popMenuInbox.addAction(self.actionForceHtml)
self.popMenuInbox.addAction(self.actionMarkUnread)
self.popMenuInbox.addSeparator()
self.popMenuInbox.addAction(self.actionReply)
self.popMenuInbox.addAction(self.actionAddSenderToAddressBook)
self.popMenuInbox.addSeparator()
self.popMenuInbox.addAction(self.actionSaveMessageAs)
self.popMenuInbox.addAction(self.actionTrashInboxMessage)
def init_identities_popup_menu(self, connectSignal=True): def init_identities_popup_menu(self, connectSignal=True):
# Popup menu for the Your Identities tab # Popup menu for the Your Identities tab
self.ui.addressContextMenuToolbarYourIdentities = QtGui.QToolBar() self.ui.addressContextMenuToolbarYourIdentities = QtGui.QToolBar()
@ -3097,6 +3090,30 @@ class MyForm(QtGui.QMainWindow):
if unread: if unread:
self.propagateUnreadCount(self.getCurrentAccount(), self.getCurrentFolder(), self.getCurrentTreeWidget(), 0) self.propagateUnreadCount(self.getCurrentAccount(), self.getCurrentFolder(), self.getCurrentTreeWidget(), 0)
def on_action_TrashUndelete(self):
tableWidget = self.getCurrentMessagelist()
if not tableWidget:
return
unread = False
currentRow = 0
while tableWidget.selectedIndexes():
currentRow = tableWidget.selectedIndexes()[0].row()
inventoryHashToTrash = str(tableWidget.item(
currentRow, 3).data(Qt.UserRole).toPyObject())
sqlExecute('''UPDATE inbox SET folder='inbox' WHERE msgid=?''', inventoryHashToTrash)
if tableWidget.item(currentRow, 0).font().bold():
unread = True
self.getCurrentMessageTextedit().setText("")
tableWidget.removeRow(currentRow)
self.statusBar().showMessage(_translate(
"MainWindow", "Undeleted item."))
if currentRow == 0:
tableWidget.selectRow(currentRow)
else:
tableWidget.selectRow(currentRow - 1)
if unread:
self.propagateUnreadCount(self.getCurrentAccount(), None, self.getCurrentTreeWidget(), 0)
def on_action_InboxSaveMessageAs(self): def on_action_InboxSaveMessageAs(self):
tableWidget = self.getCurrentMessagelist() tableWidget = self.getCurrentMessagelist()
if not tableWidget: if not tableWidget:
@ -3676,6 +3693,18 @@ class MyForm(QtGui.QMainWindow):
if currentFolder == 'sent': if currentFolder == 'sent':
self.on_context_menuSent(point) self.on_context_menuSent(point)
else: else:
self.popMenuInbox = QtGui.QMenu(self)
self.popMenuInbox.addAction(self.actionForceHtml)
self.popMenuInbox.addAction(self.actionMarkUnread)
self.popMenuInbox.addSeparator()
self.popMenuInbox.addAction(self.actionReply)
self.popMenuInbox.addAction(self.actionAddSenderToAddressBook)
self.popMenuInbox.addSeparator()
self.popMenuInbox.addAction(self.actionSaveMessageAs)
if currentFolder == "trash":
self.popMenuInbox.addAction(self.actionUndeleteTrashedMessage)
else:
self.popMenuInbox.addAction(self.actionTrashInboxMessage)
self.popMenuInbox.exec_(tableWidget.mapToGlobal(point)) self.popMenuInbox.exec_(tableWidget.mapToGlobal(point))
def on_context_menuSent(self, point): def on_context_menuSent(self, point):