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.setSortingEnabled(False)
|
||||||
tableWidget.horizontalHeader().setSortIndicator(3, Qt.DescendingOrder)
|
tableWidget.horizontalHeader().setSortIndicator(3, Qt.DescendingOrder)
|
||||||
tableWidget.keyPressEvent = self.tableWidgetInboxKeyPressEvent
|
tableWidget.keyPressEvent = self.tableWidgetSentKeyPressEvent
|
||||||
|
|
||||||
# Load messages from database file
|
# Load messages from database file
|
||||||
def loadMessagelist(self, tableWidget, account, folder="inbox", where="", what=""):
|
def loadMessagelist(self, tableWidget, account, folder="inbox", where="", what=""):
|
||||||
|
@ -1497,6 +1497,12 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
self.on_action_InboxTrash()
|
self.on_action_InboxTrash()
|
||||||
return QtGui.QTableWidget.keyPressEvent(self.getCurrentMessagelist(), event)
|
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'
|
# menu button 'manage keys'
|
||||||
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:
|
||||||
|
@ -3161,11 +3167,18 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
return
|
return
|
||||||
unread = False
|
unread = False
|
||||||
currentRow = 0
|
currentRow = 0
|
||||||
|
folder = self.getCurrentFolder()
|
||||||
|
shifted = QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ShiftModifier
|
||||||
while tableWidget.selectedIndexes():
|
while tableWidget.selectedIndexes():
|
||||||
currentRow = tableWidget.selectedIndexes()[0].row()
|
currentRow = tableWidget.selectedIndexes()[0].row()
|
||||||
inventoryHashToTrash = str(tableWidget.item(
|
inventoryHashToTrash = str(tableWidget.item(
|
||||||
currentRow, 3).data(Qt.UserRole).toPyObject())
|
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():
|
if tableWidget.item(currentRow, 0).font().bold():
|
||||||
unread = True
|
unread = True
|
||||||
self.getCurrentMessageTextedit().setText("")
|
self.getCurrentMessageTextedit().setText("")
|
||||||
|
@ -3241,11 +3254,16 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
tableWidget = self.getCurrentMessagelist()
|
tableWidget = self.getCurrentMessagelist()
|
||||||
if not tableWidget:
|
if not tableWidget:
|
||||||
return
|
return
|
||||||
|
folder = self.getCurrentFolder()
|
||||||
|
shifted = (QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ShiftModifier) > 0
|
||||||
while tableWidget.selectedIndexes() != []:
|
while tableWidget.selectedIndexes() != []:
|
||||||
currentRow = tableWidget.selectedIndexes()[0].row()
|
currentRow = tableWidget.selectedIndexes()[0].row()
|
||||||
ackdataToTrash = str(tableWidget.item(
|
ackdataToTrash = str(tableWidget.item(
|
||||||
currentRow, 3).data(Qt.UserRole).toPyObject())
|
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():
|
if tableWidget.item(currentRow, 0).font().bold():
|
||||||
unread = True
|
unread = True
|
||||||
self.getCurrentMessageTextedit().setPlainText("")
|
self.getCurrentMessageTextedit().setPlainText("")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user