Newly sent messages and status update

- newly sent messages did not appear in all tabs
- message status change didn't work in all tabs
- addresses #90
- however, still new sent message sender/recipient do not have the
correct color
This commit is contained in:
mailchuck 2015-11-09 19:39:30 +01:00 committed by Peter Surda
parent 4aaf0048c6
commit 1a842730a2
1 changed files with 95 additions and 78 deletions

View File

@ -1808,10 +1808,13 @@ class MyForm(settingsmixin.SMainWindow):
return self.unreadCount
def updateSentItemStatusByToAddress(self, toAddress, textToDisplay):
sent = self.getAccountMessagelist(toAddress)
treeWidget = self.getAccountTreeWidget(toAddress)
for sent in [self.ui.tableWidgetInbox, self.ui.tableWidgetInboxSubscriptions, self.ui.tableWidgetInboxChans]:
treeWidget = self.widgetConvert(sent)
if self.getCurrentFolder(treeWidget) != "sent":
return
continue
if treeWidget in [self.ui.treeWidgetSubscriptions, self.ui.treeWidgetChans] and self.getCurrentAccount(treeWidget) != toAddress:
continue
for i in range(sent.rowCount()):
rowAddress = str(sent.item(
i, 0).data(Qt.UserRole).toPyObject())
@ -1828,36 +1831,30 @@ class MyForm(settingsmixin.SMainWindow):
sent.item(i, 3).setText(textToDisplay)
def updateSentItemStatusByAckdata(self, ackdata, textToDisplay):
for i in range(self.ui.tableWidgetInbox.rowCount()):
toAddress = str(self.ui.tableWidgetInbox.item(
for sent in [self.ui.tableWidgetInbox, self.ui.tableWidgetInboxSubscriptions, self.ui.tableWidgetInboxChans]:
treeWidget = self.widgetConvert(sent)
if self.getCurrentFolder(treeWidget) != "sent":
continue
for i in range(sent.rowCount()):
toAddress = str(sent.item(
i, 0).data(Qt.UserRole).toPyObject())
tableAckdata = self.ui.tableWidgetInbox.item(
tableAckdata = sent.item(
i, 3).data(Qt.UserRole).toPyObject()
status, addressVersionNumber, streamNumber, ripe = decodeAddress(
toAddress)
if ackdata == tableAckdata:
self.ui.tableWidgetInbox.item(i, 3).setToolTip(textToDisplay)
sent.item(i, 3).setToolTip(textToDisplay)
try:
newlinePosition = textToDisplay.indexOf('\n')
except: # If someone misses adding a "_translate" to a string before passing it to this function, this function won't receive a qstring which will cause an exception.
newlinePosition = 0
if newlinePosition > 1:
self.ui.tableWidgetInbox.item(i, 3).setText(
sent.item(i, 3).setText(
textToDisplay[:newlinePosition])
else:
self.ui.tableWidgetInbox.item(i, 3).setText(textToDisplay)
sent.item(i, 3).setText(textToDisplay)
def removeInboxRowByMsgid(self, msgid): # msgid and inventoryHash are the same thing
def widgetConvert (tableWidget):
if tableWidget == self.ui.tableWidgetInbox:
return self.ui.treeWidgetYourIdentities
elif tableWidget == self.ui.tableWidgetInboxSubscriptions:
return self.ui.treeWidgetSubscriptions
elif tableWidget == self.ui.tableWidgetInboxChans:
return self.ui.treeWidgetChans
else:
return None
for inbox in ([
self.ui.tableWidgetInbox,
self.ui.tableWidgetInboxSubscriptions,
@ -1866,7 +1863,7 @@ class MyForm(settingsmixin.SMainWindow):
if msgid == str(inbox.item(i, 3).data(Qt.UserRole).toPyObject()):
self.statusBar().showMessage(_translate(
"MainWindow", "Message trashed"))
treeWidget = widgetConvert(inbox)
treeWidget = self.widgetConvert(inbox)
self.propagateUnreadCount(self.getCurrentAccount(treeWidget), self.getCurrentFolder(treeWidget), treeWidget, 0)
inbox.removeRow(i)
break
@ -2327,10 +2324,14 @@ class MyForm(settingsmixin.SMainWindow):
message = shared.fixPotentiallyInvalidUTF8Data(message)
acct = accountClass(fromAddress)
acct.parseMessage(toAddress, fromAddress, subject, message)
sent = self.getAccountMessagelist(acct)
treeWidget = self.getAccountTreeWidget(acct)
if self.getCurrentFolder(treeWidget) != "sent" or self.getCurrentAccount(treeWidget) != fromAddress:
return
for sent in [self.ui.tableWidgetInbox, self.ui.tableWidgetInboxSubscriptions, self.ui.tableWidgetInboxChans]:
treeWidget = self.widgetConvert(sent)
if self.getCurrentFolder(treeWidget) != "sent":
continue
if treeWidget == self.ui.treeWidgetYourIdentities and self.getCurrentAccount(treeWidget) != fromAddress:
continue
elif treeWidget in [self.ui.treeWidgetSubscriptions, self.ui.treeWidgetChans] and self.getCurrentAccount(treeWidget) != toAddress:
continue
sent.setSortingEnabled(False)
sent.insertRow(0)
@ -3422,6 +3423,22 @@ class MyForm(settingsmixin.SMainWindow):
sqlExecute(
'''UPDATE whitelist SET enabled=0 WHERE address=?''', str(addressAtCurrentRow))
def widgetConvert (self, widget):
if widget == self.ui.tableWidgetInbox:
return self.ui.treeWidgetYourIdentities
elif widget == self.ui.tableWidgetInboxSubscriptions:
return self.ui.treeWidgetSubscriptions
elif widget == self.ui.tableWidgetInboxChans:
return self.ui.treeWidgetChans
elif widget == self.ui.treeWidgetYourIdentities:
return self.ui.tableWidgetInbox
elif widget == self.ui.treeWidgetSubscriptions:
return self.ui.tableWidgetInboxSubscriptions
elif twidget == self.ui.treeWidgetChans:
return self.ui.tableWidgetInboxChans
else:
return None
def getCurrentTreeWidget(self):
currentIndex = self.ui.tabWidget.currentIndex();
treeWidgetList = [