dont freeze UI when mass-moving to trash
This commit is contained in:
parent
0c0e0e527b
commit
841b4f59c7
|
@ -2789,19 +2789,29 @@ 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):
|
||||||
while self.ui.tableWidgetInbox.selectedIndexes() != []:
|
inventoryHashesToTrash = []
|
||||||
currentRow = self.ui.tableWidgetInbox.selectedIndexes()[0].row()
|
unsorted_ranges = self.ui.tableWidgetInbox.selectedRanges()
|
||||||
|
ranges = sorted(unsorted_ranges, key=lambda r: r.topRow())
|
||||||
|
for r in ranges:
|
||||||
|
for i in range(r.bottomRow()-r.topRow()+1):
|
||||||
inventoryHashToTrash = str(self.ui.tableWidgetInbox.item(
|
inventoryHashToTrash = str(self.ui.tableWidgetInbox.item(
|
||||||
currentRow, 3).data(Qt.UserRole).toPyObject())
|
r.topRow()+i, 3).data(Qt.UserRole).toPyObject())
|
||||||
sqlExecute('''UPDATE inbox SET folder='trash' WHERE msgid=?''', inventoryHashToTrash)
|
inventoryHashesToTrash.append(inventoryHashToTrash)
|
||||||
|
#sqlite requires the exact number of ?s to prevent injection
|
||||||
|
sqlExecute('''UPDATE inbox SET folder='trash' WHERE msgid IN (%s)''' % (
|
||||||
|
"?," * len(inventoryHashesToTrash))[:-1], *inventoryHashesToTrash)
|
||||||
|
|
||||||
self.ui.textEditInboxMessage.setText("")
|
self.ui.textEditInboxMessage.setText("")
|
||||||
self.ui.tableWidgetInbox.removeRow(currentRow)
|
|
||||||
self.statusBar().showMessage(_translate(
|
self.statusBar().showMessage(_translate(
|
||||||
"MainWindow", "Moved items 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."))
|
"MainWindow", "Moved items 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."))
|
||||||
if currentRow == 0:
|
#remove ranges from model/view going from bottom to top
|
||||||
self.ui.tableWidgetInbox.selectRow(currentRow)
|
for r in ranges[::-1]:
|
||||||
else:
|
self.ui.tableWidgetInbox.model().removeRows(r.topRow(),
|
||||||
self.ui.tableWidgetInbox.selectRow(currentRow - 1)
|
r.bottomRow()-r.topRow()+1)
|
||||||
|
lastRow = r.topRow()
|
||||||
|
self.ui.tableWidgetInbox.selectRow(0 if lastRow == 0 else lastRow-1)
|
||||||
|
self.changedInboxUnread()
|
||||||
|
|
||||||
|
|
||||||
def on_action_InboxSaveMessageAs(self):
|
def on_action_InboxSaveMessageAs(self):
|
||||||
currentInboxRow = self.ui.tableWidgetInbox.currentRow()
|
currentInboxRow = self.ui.tableWidgetInbox.currentRow()
|
||||||
|
|
Reference in New Issue
Block a user