Use delete key to trash Inbox or Sent messages #81

Merged
Atheros1 merged 2 commits from master into master 2013-03-27 22:15:01 +01:00

View File

@ -3886,7 +3886,7 @@ class MyForm(QtGui.QMainWindow):
reloadMyAddressHashes() reloadMyAddressHashes()
self.reloadBroadcastSendersForWhichImWatching() self.reloadBroadcastSendersForWhichImWatching()
self.ui.tableWidgetSent.keyPressEvent = self.tableWidgetSentKeyPressEvent
#Load inbox from messages database file #Load inbox from messages database file
sqlSubmitQueue.put('''SELECT msgid, toaddress, fromaddress, subject, received, message FROM inbox where folder='inbox' ORDER BY received''') sqlSubmitQueue.put('''SELECT msgid, toaddress, fromaddress, subject, received, message FROM inbox where folder='inbox' ORDER BY received''')
sqlSubmitQueue.put('') sqlSubmitQueue.put('')
@ -3941,6 +3941,7 @@ class MyForm(QtGui.QMainWindow):
self.ui.tableWidgetInbox.setItem(0,3,newItem) self.ui.tableWidgetInbox.setItem(0,3,newItem)
#self.ui.textEditInboxMessage.setText(self.ui.tableWidgetInbox.item(0,2).data(Qt.UserRole).toPyObject()) #self.ui.textEditInboxMessage.setText(self.ui.tableWidgetInbox.item(0,2).data(Qt.UserRole).toPyObject())
self.ui.tableWidgetInbox.keyPressEvent = self.tableWidgetInboxKeyPressEvent
#Load Sent items from database #Load Sent items from database
sqlSubmitQueue.put('''SELECT toaddress, fromaddress, subject, message, status, ackdata, lastactiontime FROM sent where folder = 'sent' ORDER BY lastactiontime''') sqlSubmitQueue.put('''SELECT toaddress, fromaddress, subject, message, status, ackdata, lastactiontime FROM sent where folder = 'sent' ORDER BY lastactiontime''')
sqlSubmitQueue.put('') sqlSubmitQueue.put('')
@ -4103,6 +4104,16 @@ class MyForm(QtGui.QMainWindow):
QtCore.QObject.connect(self.singleAPISignalHandlerThread, QtCore.SIGNAL("passAddressGeneratorObjectThrough(PyQt_PyObject)"), self.connectObjectToAddressGeneratorSignals) QtCore.QObject.connect(self.singleAPISignalHandlerThread, QtCore.SIGNAL("passAddressGeneratorObjectThrough(PyQt_PyObject)"), self.connectObjectToAddressGeneratorSignals)
QtCore.QObject.connect(self.singleAPISignalHandlerThread, QtCore.SIGNAL("displayNewSentMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.displayNewSentMessage) QtCore.QObject.connect(self.singleAPISignalHandlerThread, QtCore.SIGNAL("displayNewSentMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.displayNewSentMessage)
def tableWidgetInboxKeyPressEvent(self,event):
if event.key() == QtCore.Qt.Key_Delete:
self.on_action_InboxTrash()
return QtGui.QTableWidget.keyPressEvent(self.ui.tableWidgetInbox, event)
def tableWidgetSentKeyPressEvent(self,event):
if event.key() == QtCore.Qt.Key_Delete:
self.on_action_SentTrash()
return QtGui.QTableWidget.keyPressEvent(self.ui.tableWidgetSent, event)
def click_actionManageKeys(self): def click_actionManageKeys(self):
if 'darwin' in sys.platform or 'linux' in sys.platform: if 'darwin' in sys.platform or 'linux' in sys.platform:
if appdata == '': if appdata == '':
@ -5010,31 +5021,33 @@ class MyForm(QtGui.QMainWindow):
#Send item on the Inbox tab to trash #Send item on the Inbox tab to trash
def on_action_InboxTrash(self): def on_action_InboxTrash(self):
currentRow = self.ui.tableWidgetInbox.currentRow() currentRow = self.ui.tableWidgetInbox.currentRow()
inventoryHashToTrash = str(self.ui.tableWidgetInbox.item(currentRow,3).data(Qt.UserRole).toPyObject()) if currentRow >= 0:
t = (inventoryHashToTrash,) inventoryHashToTrash = str(self.ui.tableWidgetInbox.item(currentRow,3).data(Qt.UserRole).toPyObject())
sqlLock.acquire() t = (inventoryHashToTrash,)
#sqlSubmitQueue.put('''delete from inbox where msgid=?''') sqlLock.acquire()
sqlSubmitQueue.put('''UPDATE inbox SET folder='trash' WHERE msgid=?''') #sqlSubmitQueue.put('''delete from inbox where msgid=?''')
sqlSubmitQueue.put(t) sqlSubmitQueue.put('''UPDATE inbox SET folder='trash' WHERE msgid=?''')
sqlReturnQueue.get() sqlSubmitQueue.put(t)
sqlLock.release() sqlReturnQueue.get()
self.ui.textEditInboxMessage.setText("") sqlLock.release()
self.ui.tableWidgetInbox.removeRow(currentRow) self.ui.textEditInboxMessage.setText("")
self.statusBar().showMessage('Moved item to trash. There is no user interface to view your trash, but it is still on disk if you are desperate to get it back.') self.ui.tableWidgetInbox.removeRow(currentRow)
self.statusBar().showMessage('Moved item to trash. There is no user interface to view your trash, but it is still on disk if you are desperate to get it back.')
#Send item on the Sent tab to trash #Send item on the Sent tab to trash
def on_action_SentTrash(self): def on_action_SentTrash(self):
currentRow = self.ui.tableWidgetSent.currentRow() currentRow = self.ui.tableWidgetSent.currentRow()
ackdataToTrash = str(self.ui.tableWidgetSent.item(currentRow,3).data(Qt.UserRole).toPyObject()) if currentRow >= 0:
t = (ackdataToTrash,) ackdataToTrash = str(self.ui.tableWidgetSent.item(currentRow,3).data(Qt.UserRole).toPyObject())
sqlLock.acquire() t = (ackdataToTrash,)
sqlSubmitQueue.put('''UPDATE sent SET folder='trash' WHERE ackdata=?''') sqlLock.acquire()
sqlSubmitQueue.put(t) sqlSubmitQueue.put('''UPDATE sent SET folder='trash' WHERE ackdata=?''')
sqlReturnQueue.get() sqlSubmitQueue.put(t)
sqlLock.release() sqlReturnQueue.get()
self.ui.textEditSentMessage.setText("") sqlLock.release()
self.ui.tableWidgetSent.removeRow(currentRow) self.ui.textEditSentMessage.setText("")
self.statusBar().showMessage('Moved item to trash. There is no user interface to view your trash, but it is still on disk if you are desperate to get it back.') self.ui.tableWidgetSent.removeRow(currentRow)
self.statusBar().showMessage('Moved item to trash. There is no user interface to view your trash, but it is still on disk if you are desperate to get it back.')
def on_action_SentClipboard(self): def on_action_SentClipboard(self):
currentRow = self.ui.tableWidgetSent.currentRow() currentRow = self.ui.tableWidgetSent.currentRow()
addressAtCurrentRow = str(self.ui.tableWidgetSent.item(currentRow,0).data(Qt.UserRole).toPyObject()) addressAtCurrentRow = str(self.ui.tableWidgetSent.item(currentRow,0).data(Qt.UserRole).toPyObject())