Delete key and shift modifier
Addresses #114 - delete from sent works when pressing delete key - delete from trash deletes rather than moves - delete with shift deletes rather than moves
This commit is contained in:
parent
cd9a7b5157
commit
dd15d1b6ed
|
@ -1065,7 +1065,7 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
|
||||
tableWidget.setSortingEnabled(False)
|
||||
tableWidget.horizontalHeader().setSortIndicator(3, Qt.DescendingOrder)
|
||||
tableWidget.keyPressEvent = self.tableWidgetInboxKeyPressEvent
|
||||
tableWidget.keyPressEvent = self.tableWidgetSentKeyPressEvent
|
||||
|
||||
# Load messages from database file
|
||||
def loadMessagelist(self, tableWidget, account, folder="inbox", where="", what=""):
|
||||
|
@ -1497,6 +1497,12 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
self.on_action_InboxTrash()
|
||||
return QtGui.QTableWidget.keyPressEvent(self.getCurrentMessagelist(), event)
|
||||
|
||||
# set delete key in inbox
|
||||
def tableWidgetSentKeyPressEvent(self, event):
|
||||
if event.key() == QtCore.Qt.Key_Delete:
|
||||
self.on_action_SentTrash()
|
||||
return QtGui.QTableWidget.keyPressEvent(self.getCurrentMessagelist(), event)
|
||||
|
||||
# menu button 'manage keys'
|
||||
def click_actionManageKeys(self):
|
||||
if 'darwin' in sys.platform or 'linux' in sys.platform:
|
||||
|
@ -3161,11 +3167,18 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
return
|
||||
unread = False
|
||||
currentRow = 0
|
||||
folder = self.getCurrentFolder()
|
||||
shifted = QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ShiftModifier
|
||||
while tableWidget.selectedIndexes():
|
||||
currentRow = tableWidget.selectedIndexes()[0].row()
|
||||
inventoryHashToTrash = str(tableWidget.item(
|
||||
currentRow, 3).data(Qt.UserRole).toPyObject())
|
||||
sqlExecute('''UPDATE inbox SET folder='trash' WHERE msgid=?''', inventoryHashToTrash)
|
||||
if folder == "trash" or shifted:
|
||||
logger.debug ("deleting")
|
||||
sqlExecute('''DELETE FROM inbox WHERE msgid=?''', inventoryHashToTrash)
|
||||
else:
|
||||
logger.debug ("moving to trash, because folder = \"%s\" and shifted = %r %x", folder, shifted)
|
||||
sqlExecute('''UPDATE inbox SET folder='trash' WHERE msgid=?''', inventoryHashToTrash)
|
||||
if tableWidget.item(currentRow, 0).font().bold():
|
||||
unread = True
|
||||
self.getCurrentMessageTextedit().setText("")
|
||||
|
@ -3241,11 +3254,16 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
tableWidget = self.getCurrentMessagelist()
|
||||
if not tableWidget:
|
||||
return
|
||||
folder = self.getCurrentFolder()
|
||||
shifted = (QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ShiftModifier) > 0
|
||||
while tableWidget.selectedIndexes() != []:
|
||||
currentRow = tableWidget.selectedIndexes()[0].row()
|
||||
ackdataToTrash = str(tableWidget.item(
|
||||
currentRow, 3).data(Qt.UserRole).toPyObject())
|
||||
sqlExecute('''UPDATE sent SET folder='trash' WHERE ackdata=?''', ackdataToTrash)
|
||||
if folder == "trash" or shifted:
|
||||
sqlExecute('''DELETE FROM sent WHERE ackdata=?''', ackdataToTrash)
|
||||
else:
|
||||
sqlExecute('''UPDATE sent SET folder='trash' WHERE ackdata=?''', ackdataToTrash)
|
||||
if tableWidget.item(currentRow, 0).font().bold():
|
||||
unread = True
|
||||
self.getCurrentMessageTextedit().setPlainText("")
|
||||
|
|
Loading…
Reference in New Issue
Block a user