fix bug in responsibility of message list on Qt GUI
This commit is contained in:
parent
f9d236444f
commit
f8919a8f66
|
@ -91,6 +91,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
|
||||||
|
@ -1033,7 +1040,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()):
|
||||||
|
@ -1938,8 +1945,6 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
sent.item(i, 3).setText(textToDisplay)
|
sent.item(i, 3).setText(textToDisplay)
|
||||||
|
|
||||||
def updateSentItemStatusByAckdata(self, ackdata, textToDisplay):
|
def updateSentItemStatusByAckdata(self, ackdata, textToDisplay):
|
||||||
if type(ackdata) is str:
|
|
||||||
ackdata = QtCore.QByteArray(ackdata)
|
|
||||||
for sent in (
|
for sent in (
|
||||||
self.ui.tableWidgetInbox,
|
self.ui.tableWidgetInbox,
|
||||||
self.ui.tableWidgetInboxSubscriptions,
|
self.ui.tableWidgetInboxSubscriptions,
|
||||||
|
@ -1950,7 +1955,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
continue
|
continue
|
||||||
for i in range(sent.rowCount()):
|
for i in range(sent.rowCount()):
|
||||||
toAddress = sent.item(i, 0).data(QtCore.Qt.UserRole)
|
toAddress = sent.item(i, 0).data(QtCore.Qt.UserRole)
|
||||||
tableAckdata = sent.item(i, 3).data()
|
tableAckdata = as_msgid(sent.item(i, 3).data())
|
||||||
status, addressVersionNumber, streamNumber, ripe = decodeAddress(
|
status, addressVersionNumber, streamNumber, ripe = decodeAddress(
|
||||||
toAddress)
|
toAddress)
|
||||||
if ackdata == tableAckdata:
|
if ackdata == tableAckdata:
|
||||||
|
@ -1976,7 +1981,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
|
||||||
|
@ -2702,7 +2707,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)
|
||||||
|
|
||||||
|
@ -2986,8 +2991,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)
|
||||||
|
@ -3081,7 +3086,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))
|
||||||
|
@ -3235,15 +3240,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
|
||||||
|
@ -3263,7 +3268,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(
|
||||||
|
@ -3296,7 +3301,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(
|
||||||
|
@ -3327,7 +3332,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:
|
||||||
|
@ -3363,7 +3368,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
shifted = QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ShiftModifier
|
shifted = QtGui.QApplication.queryKeyboardModifiers() & 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'"
|
||||||
|
@ -3646,11 +3651,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()
|
||||||
|
@ -4093,7 +4094,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)
|
||||||
|
|
Reference in New Issue
Block a user