fix bug in responsibility of message list on Qt GUI

This commit is contained in:
Kashiko Koibumi 2024-05-31 18:03:39 +09:00
parent 8c85539731
commit a504384c94
No known key found for this signature in database
GPG Key ID: 8F06E069E37C40C4

View File

@ -92,6 +92,13 @@ def openKeysFile():
os.startfile(keysfile) # pylint: disable=no-member os.startfile(keysfile) # pylint: disable=no-member
def as_msgid(id_data):
if six.PY3:
return escape_decode(id_data)[0][2:-1]
else: # assume six.PY2
return id_data
class MyForm(settingsmixin.SMainWindow): class MyForm(settingsmixin.SMainWindow):
# the maximum frequency of message sounds in seconds # the maximum frequency of message sounds in seconds
@ -994,7 +1001,7 @@ class MyForm(settingsmixin.SMainWindow):
# related = related.findItems(msgid, QtCore.Qt.MatchExactly), # related = related.findItems(msgid, QtCore.Qt.MatchExactly),
# returns an empty list # returns an empty list
for rrow in range(related.rowCount()): for rrow in range(related.rowCount()):
if related.item(rrow, 3).data() == msgid: if as_msgid(related.item(rrow, 3).data()) == msgid:
break break
for col in range(widget.columnCount()): for col in range(widget.columnCount()):
@ -1914,7 +1921,7 @@ class MyForm(settingsmixin.SMainWindow):
# toAddress = sent.item(i, 0).data(QtCore.Qt.UserRole) # toAddress = sent.item(i, 0).data(QtCore.Qt.UserRole)
# decodeAddress(toAddress) # decodeAddress(toAddress)
if sent.item(i, 3).data() == ackdata: if as_msgid(sent.item(i, 3).data()) == ackdata:
sent.item(i, 3).setToolTip(textToDisplay) sent.item(i, 3).setToolTip(textToDisplay)
try: try:
newlinePosition = textToDisplay.find('\n') newlinePosition = textToDisplay.find('\n')
@ -1937,7 +1944,7 @@ class MyForm(settingsmixin.SMainWindow):
): ):
i = None i = None
for i in range(inbox.rowCount()): for i in range(inbox.rowCount()):
if msgid == inbox.item(i, 3).data(): if msgid == as_msgid(inbox.item(i, 3).data()):
break break
else: else:
continue continue
@ -2686,7 +2693,7 @@ class MyForm(settingsmixin.SMainWindow):
msgids = [] msgids = []
for i in range(0, idCount): for i in range(0, idCount):
msgids.append(sqlite3.Binary(tableWidget.item(i, 3).data())) msgids.append(sqlite3.Binary(as_msgid(tableWidget.item(i, 3).data())))
for col in xrange(tableWidget.columnCount()): for col in xrange(tableWidget.columnCount()):
tableWidget.item(i, col).setUnread(False) tableWidget.item(i, col).setUnread(False)
@ -2975,8 +2982,8 @@ class MyForm(settingsmixin.SMainWindow):
# modified = 0 # modified = 0
for row in tableWidget.selectedIndexes(): for row in tableWidget.selectedIndexes():
currentRow = row.row() currentRow = row.row()
msgid = sqlite3.Binary(tableWidget.item(currentRow, 3).data()) msgid = as_msgid(tableWidget.item(currentRow, 3).data())
msgids.add(msgid) msgids.add(sqlite3.Binary(msgid))
# if not tableWidget.item(currentRow, 0).unread: # if not tableWidget.item(currentRow, 0).unread:
# modified += 1 # modified += 1
self.updateUnreadStatus(tableWidget, currentRow, msgid, False) self.updateUnreadStatus(tableWidget, currentRow, msgid, False)
@ -3066,7 +3073,7 @@ class MyForm(settingsmixin.SMainWindow):
acct = accountClass(toAddressAtCurrentInboxRow) acct = accountClass(toAddressAtCurrentInboxRow)
fromAddressAtCurrentInboxRow = tableWidget.item( fromAddressAtCurrentInboxRow = tableWidget.item(
currentInboxRow, column_from).address currentInboxRow, column_from).address
msgid = tableWidget.item(currentInboxRow, 3).data() msgid = as_msgid(tableWidget.item(currentInboxRow, 3).data())
queryreturn = sqlQuery( queryreturn = sqlQuery(
"SELECT message FROM inbox WHERE msgid=?", sqlite3.Binary(msgid) "SELECT message FROM inbox WHERE msgid=?", sqlite3.Binary(msgid)
) or sqlQuery("SELECT message FROM sent WHERE ackdata=?", sqlite3.Binary(msgid)) ) or sqlQuery("SELECT message FROM sent WHERE ackdata=?", sqlite3.Binary(msgid))
@ -3225,15 +3232,15 @@ class MyForm(settingsmixin.SMainWindow):
messageLists = (messageLists,) messageLists = (messageLists,)
for messageList in messageLists: for messageList in messageLists:
if row is not None: if row is not None:
inventoryHash = messageList.item(row, 3).data() inventoryHash = as_msgid(messageList.item(row, 3).data())
messageList.removeRow(row) messageList.removeRow(row)
elif inventoryHash is not None: elif inventoryHash is not None:
for i in range(messageList.rowCount() - 1, -1, -1): for i in range(messageList.rowCount() - 1, -1, -1):
if messageList.item(i, 3).data() == inventoryHash: if as_msgid(messageList.item(i, 3).data()) == inventoryHash:
messageList.removeRow(i) messageList.removeRow(i)
elif ackData is not None: elif ackData is not None:
for i in range(messageList.rowCount() - 1, -1, -1): for i in range(messageList.rowCount() - 1, -1, -1):
if messageList.item(i, 3).data() == ackData: if as_msgid(messageList.item(i, 3).data()) == ackData:
messageList.removeRow(i) messageList.removeRow(i)
# Send item on the Inbox tab to trash # Send item on the Inbox tab to trash
@ -3253,7 +3260,7 @@ class MyForm(settingsmixin.SMainWindow):
)[::-1]: )[::-1]:
for i in range(r.bottomRow() - r.topRow() + 1): for i in range(r.bottomRow() - r.topRow() + 1):
inventoryHashesToTrash.add( inventoryHashesToTrash.add(
sqlite3.Binary(tableWidget.item(r.topRow() + i, 3).data())) sqlite3.Binary(as_msgid(tableWidget.item(r.topRow() + i, 3).data())))
currentRow = r.topRow() currentRow = r.topRow()
self.getCurrentMessageTextedit().setText("") self.getCurrentMessageTextedit().setText("")
tableWidget.model().removeRows( tableWidget.model().removeRows(
@ -3286,7 +3293,7 @@ class MyForm(settingsmixin.SMainWindow):
)[::-1]: )[::-1]:
for i in range(r.bottomRow() - r.topRow() + 1): for i in range(r.bottomRow() - r.topRow() + 1):
inventoryHashesToTrash.add( inventoryHashesToTrash.add(
sqlite3.Binary(tableWidget.item(r.topRow() + i, 3).data())) sqlite3.Binary(as_msgid(tableWidget.item(r.topRow() + i, 3).data())))
currentRow = r.topRow() currentRow = r.topRow()
self.getCurrentMessageTextedit().setText("") self.getCurrentMessageTextedit().setText("")
tableWidget.model().removeRows( tableWidget.model().removeRows(
@ -3317,7 +3324,7 @@ class MyForm(settingsmixin.SMainWindow):
subjectAtCurrentInboxRow = '' subjectAtCurrentInboxRow = ''
# Retrieve the message data out of the SQL database # Retrieve the message data out of the SQL database
msgid = tableWidget.item(currentInboxRow, 3).data() msgid = as_msgid(tableWidget.item(currentInboxRow, 3).data())
queryreturn = sqlQuery( queryreturn = sqlQuery(
'SELECT message FROM inbox WHERE msgid=?', sqlite3.Binary(msgid)) 'SELECT message FROM inbox WHERE msgid=?', sqlite3.Binary(msgid))
if len(queryreturn) < 1: if len(queryreturn) < 1:
@ -3354,7 +3361,7 @@ class MyForm(settingsmixin.SMainWindow):
QtCore.Qt.ShiftModifier) QtCore.Qt.ShiftModifier)
while tableWidget.selectedIndexes() != []: while tableWidget.selectedIndexes() != []:
currentRow = tableWidget.selectedIndexes()[0].row() currentRow = tableWidget.selectedIndexes()[0].row()
ackdataToTrash = tableWidget.item(currentRow, 3).data() ackdataToTrash = as_msgid(tableWidget.item(currentRow, 3).data())
rowcount = sqlExecute( rowcount = sqlExecute(
"DELETE FROM sent" if folder == "trash" or shifted else "DELETE FROM sent" if folder == "trash" or shifted else
"UPDATE sent SET folder='trash'" "UPDATE sent SET folder='trash'"
@ -3637,11 +3644,7 @@ class MyForm(settingsmixin.SMainWindow):
if messagelist: if messagelist:
currentRow = messagelist.currentRow() currentRow = messagelist.currentRow()
if currentRow >= 0: if currentRow >= 0:
msgid_str = messagelist.item(currentRow, 3).data() return as_msgid(messagelist.item(currentRow, 3).data())
if six.PY3:
return escape_decode(msgid_str)[0][2:-1]
else: # assume six.PY2
return msgid_str
def getCurrentMessageTextedit(self): def getCurrentMessageTextedit(self):
currentIndex = self.ui.tabWidget.currentIndex() currentIndex = self.ui.tabWidget.currentIndex()
@ -4086,7 +4089,7 @@ class MyForm(settingsmixin.SMainWindow):
# Check to see if this item is toodifficult and display an additional # Check to see if this item is toodifficult and display an additional
# menu option (Force Send) if it is. # menu option (Force Send) if it is.
if currentRow >= 0: if currentRow >= 0:
ackData = self.ui.tableWidgetInbox.item(currentRow, 3).data() ackData = as_msgid(self.ui.tableWidgetInbox.item(currentRow, 3).data())
queryreturn = sqlQuery('''SELECT status FROM sent where ackdata=?''', sqlite3.Binary(ackData)) queryreturn = sqlQuery('''SELECT status FROM sent where ackdata=?''', sqlite3.Binary(ackData))
if len(queryreturn) < 1: if len(queryreturn) < 1:
queryreturn = sqlQuery('''SELECT status FROM sent where ackdata=CAST(? AS TEXT)''', ackData) queryreturn = sqlQuery('''SELECT status FROM sent where ackdata=CAST(? AS TEXT)''', ackData)