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
parent cfea0bbdd1
commit bdf2b28b0b
Signed by untrusted user who does not match committer: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87

View File

@ -1808,10 +1808,13 @@ class MyForm(settingsmixin.SMainWindow):
return self.unreadCount return self.unreadCount
def updateSentItemStatusByToAddress(self, toAddress, textToDisplay): def updateSentItemStatusByToAddress(self, toAddress, textToDisplay):
sent = self.getAccountMessagelist(toAddress) for sent in [self.ui.tableWidgetInbox, self.ui.tableWidgetInboxSubscriptions, self.ui.tableWidgetInboxChans]:
treeWidget = self.getAccountTreeWidget(toAddress) treeWidget = self.widgetConvert(sent)
if self.getCurrentFolder(treeWidget) != "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()): for i in range(sent.rowCount()):
rowAddress = str(sent.item( rowAddress = str(sent.item(
i, 0).data(Qt.UserRole).toPyObject()) i, 0).data(Qt.UserRole).toPyObject())
@ -1828,36 +1831,30 @@ 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):
for i in range(self.ui.tableWidgetInbox.rowCount()): for sent in [self.ui.tableWidgetInbox, self.ui.tableWidgetInboxSubscriptions, self.ui.tableWidgetInboxChans]:
toAddress = str(self.ui.tableWidgetInbox.item( 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()) i, 0).data(Qt.UserRole).toPyObject())
tableAckdata = self.ui.tableWidgetInbox.item( tableAckdata = sent.item(
i, 3).data(Qt.UserRole).toPyObject() i, 3).data(Qt.UserRole).toPyObject()
status, addressVersionNumber, streamNumber, ripe = decodeAddress( status, addressVersionNumber, streamNumber, ripe = decodeAddress(
toAddress) toAddress)
if ackdata == tableAckdata: if ackdata == tableAckdata:
self.ui.tableWidgetInbox.item(i, 3).setToolTip(textToDisplay) sent.item(i, 3).setToolTip(textToDisplay)
try: try:
newlinePosition = textToDisplay.indexOf('\n') 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. 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 newlinePosition = 0
if newlinePosition > 1: if newlinePosition > 1:
self.ui.tableWidgetInbox.item(i, 3).setText( sent.item(i, 3).setText(
textToDisplay[:newlinePosition]) textToDisplay[:newlinePosition])
else: 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 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 ([ for inbox in ([
self.ui.tableWidgetInbox, self.ui.tableWidgetInbox,
self.ui.tableWidgetInboxSubscriptions, self.ui.tableWidgetInboxSubscriptions,
@ -1866,7 +1863,7 @@ class MyForm(settingsmixin.SMainWindow):
if msgid == str(inbox.item(i, 3).data(Qt.UserRole).toPyObject()): if msgid == str(inbox.item(i, 3).data(Qt.UserRole).toPyObject()):
self.statusBar().showMessage(_translate( self.statusBar().showMessage(_translate(
"MainWindow", "Message trashed")) "MainWindow", "Message trashed"))
treeWidget = widgetConvert(inbox) treeWidget = self.widgetConvert(inbox)
self.propagateUnreadCount(self.getCurrentAccount(treeWidget), self.getCurrentFolder(treeWidget), treeWidget, 0) self.propagateUnreadCount(self.getCurrentAccount(treeWidget), self.getCurrentFolder(treeWidget), treeWidget, 0)
inbox.removeRow(i) inbox.removeRow(i)
break break
@ -2327,10 +2324,14 @@ class MyForm(settingsmixin.SMainWindow):
message = shared.fixPotentiallyInvalidUTF8Data(message) message = shared.fixPotentiallyInvalidUTF8Data(message)
acct = accountClass(fromAddress) acct = accountClass(fromAddress)
acct.parseMessage(toAddress, fromAddress, subject, message) acct.parseMessage(toAddress, fromAddress, subject, message)
sent = self.getAccountMessagelist(acct) for sent in [self.ui.tableWidgetInbox, self.ui.tableWidgetInboxSubscriptions, self.ui.tableWidgetInboxChans]:
treeWidget = self.getAccountTreeWidget(acct) treeWidget = self.widgetConvert(sent)
if self.getCurrentFolder(treeWidget) != "sent" or self.getCurrentAccount(treeWidget) != fromAddress: if self.getCurrentFolder(treeWidget) != "sent":
return 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.setSortingEnabled(False)
sent.insertRow(0) sent.insertRow(0)
@ -3422,6 +3423,22 @@ class MyForm(settingsmixin.SMainWindow):
sqlExecute( sqlExecute(
'''UPDATE whitelist SET enabled=0 WHERE address=?''', str(addressAtCurrentRow)) '''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): def getCurrentTreeWidget(self):
currentIndex = self.ui.tabWidget.currentIndex(); currentIndex = self.ui.tabWidget.currentIndex();
treeWidgetList = [ treeWidgetList = [