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,56 +1808,53 @@ 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
for i in range(sent.rowCount()): if treeWidget in [self.ui.treeWidgetSubscriptions, self.ui.treeWidgetChans] and self.getCurrentAccount(treeWidget) != toAddress:
rowAddress = str(sent.item( continue
i, 0).data(Qt.UserRole).toPyObject())
if toAddress == rowAddress: for i in range(sent.rowCount()):
sent.item(i, 3).setToolTip(textToDisplay) rowAddress = str(sent.item(
try: i, 0).data(Qt.UserRole).toPyObject())
newlinePosition = textToDisplay.indexOf('\n') if toAddress == rowAddress:
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. sent.item(i, 3).setToolTip(textToDisplay)
newlinePosition = 0 try:
if newlinePosition > 1: newlinePosition = textToDisplay.indexOf('\n')
sent.item(i, 3).setText( 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.
textToDisplay[:newlinePosition]) newlinePosition = 0
else: if newlinePosition > 1:
sent.item(i, 3).setText(textToDisplay) sent.item(i, 3).setText(
textToDisplay[:newlinePosition])
else:
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)
i, 0).data(Qt.UserRole).toPyObject()) if self.getCurrentFolder(treeWidget) != "sent":
tableAckdata = self.ui.tableWidgetInbox.item( continue
i, 3).data(Qt.UserRole).toPyObject() for i in range(sent.rowCount()):
status, addressVersionNumber, streamNumber, ripe = decodeAddress( toAddress = str(sent.item(
toAddress) i, 0).data(Qt.UserRole).toPyObject())
if ackdata == tableAckdata: tableAckdata = sent.item(
self.ui.tableWidgetInbox.item(i, 3).setToolTip(textToDisplay) i, 3).data(Qt.UserRole).toPyObject()
try: status, addressVersionNumber, streamNumber, ripe = decodeAddress(
newlinePosition = textToDisplay.indexOf('\n') toAddress)
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. if ackdata == tableAckdata:
newlinePosition = 0 sent.item(i, 3).setToolTip(textToDisplay)
if newlinePosition > 1: try:
self.ui.tableWidgetInbox.item(i, 3).setText( newlinePosition = textToDisplay.indexOf('\n')
textToDisplay[:newlinePosition]) 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.
else: newlinePosition = 0
self.ui.tableWidgetInbox.item(i, 3).setText(textToDisplay) if newlinePosition > 1:
sent.item(i, 3).setText(
textToDisplay[:newlinePosition])
else:
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,39 +2324,43 @@ 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)
newItem = QtGui.QTableWidgetItem(unicode(acct.toLabel, 'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(acct.toLabel, 'utf-8'))
newItem.setToolTip(unicode(acct.toLabel, 'utf-8')) newItem.setToolTip(unicode(acct.toLabel, 'utf-8'))
newItem.setData(Qt.UserRole, str(toAddress)) newItem.setData(Qt.UserRole, str(toAddress))
newItem.setIcon(avatarize(toAddress)) newItem.setIcon(avatarize(toAddress))
sent.setItem(0, 0, newItem) sent.setItem(0, 0, newItem)
newItem = QtGui.QTableWidgetItem(unicode(acct.fromLabel, 'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(acct.fromLabel, 'utf-8'))
newItem.setToolTip(unicode(acct.fromLabel, 'utf-8')) newItem.setToolTip(unicode(acct.fromLabel, 'utf-8'))
newItem.setData(Qt.UserRole, str(fromAddress)) newItem.setData(Qt.UserRole, str(fromAddress))
newItem.setIcon(avatarize(fromAddress)) newItem.setIcon(avatarize(fromAddress))
sent.setItem(0, 1, newItem) sent.setItem(0, 1, newItem)
newItem = QtGui.QTableWidgetItem(unicode(acct.subject, 'utf-8)')) newItem = QtGui.QTableWidgetItem(unicode(acct.subject, 'utf-8)'))
newItem.setToolTip(unicode(acct.subject, 'utf-8)')) newItem.setToolTip(unicode(acct.subject, 'utf-8)'))
newItem.setData(Qt.UserRole, str(subject)) newItem.setData(Qt.UserRole, str(subject))
#newItem.setData(Qt.UserRole, unicode(message, 'utf-8)')) # No longer hold the message in the table; we'll use a SQL query to display it as needed. #newItem.setData(Qt.UserRole, unicode(message, 'utf-8)')) # No longer hold the message in the table; we'll use a SQL query to display it as needed.
sent.setItem(0, 2, newItem) sent.setItem(0, 2, newItem)
# newItem = QtGui.QTableWidgetItem('Doing work necessary to send # newItem = QtGui.QTableWidgetItem('Doing work necessary to send
# broadcast...'+ # broadcast...'+
# l10n.formatTimestamp()) # l10n.formatTimestamp())
newItem = myTableWidgetItem(_translate("MainWindow", "Work is queued. %1").arg(l10n.formatTimestamp())) newItem = myTableWidgetItem(_translate("MainWindow", "Work is queued. %1").arg(l10n.formatTimestamp()))
newItem.setToolTip(_translate("MainWindow", "Work is queued. %1").arg(l10n.formatTimestamp())) newItem.setToolTip(_translate("MainWindow", "Work is queued. %1").arg(l10n.formatTimestamp()))
newItem.setData(Qt.UserRole, QByteArray(ackdata)) newItem.setData(Qt.UserRole, QByteArray(ackdata))
newItem.setData(33, int(time.time())) newItem.setData(33, int(time.time()))
sent.setItem(0, 3, newItem) sent.setItem(0, 3, newItem)
self.getAccountTextedit(acct).setPlainText(unicode(message, 'utf-8)')) self.getAccountTextedit(acct).setPlainText(unicode(message, 'utf-8)'))
sent.setSortingEnabled(True) sent.setSortingEnabled(True)
def displayNewInboxMessage(self, inventoryHash, toAddress, fromAddress, subject, message): def displayNewInboxMessage(self, inventoryHash, toAddress, fromAddress, subject, message):
subject = shared.fixPotentiallyInvalidUTF8Data(subject) subject = shared.fixPotentiallyInvalidUTF8Data(subject)
@ -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 = [