Show subscription unread count

Subscriptions were not showing unread count. This commit implements it.
This commit is contained in:
mailchuck 2015-10-18 21:11:10 +02:00
parent dad14b0cb8
commit 8b527f81ee
No known key found for this signature in database
GPG Key ID: B6311FA753FBF089

View File

@ -420,13 +420,30 @@ class MyForm(QtGui.QMainWindow):
treeWidget.clear() treeWidget.clear()
treeWidget.setSortingEnabled(False) treeWidget.setSortingEnabled(False)
treeWidget.header().setSortIndicator(0, Qt.AscendingOrder) treeWidget.header().setSortIndicator(0, Qt.AscendingOrder)
db = {}
queryreturn = sqlQuery('''SELECT fromaddress, folder, count(msgid) as cnt
FROM inbox, subscriptions
WHERE read = 0 AND subscriptions.address = inbox.fromaddress
GROUP BY inbox.fromaddress, folder''')
for row in queryreturn:
fromaddress, folder, cnt = row
if fromaddress not in db:
db[fromaddress] = {}
db[fromaddress][folder] = cnt
queryreturn = sqlQuery('SELECT label, address, enabled FROM subscriptions') queryreturn = sqlQuery('SELECT label, address, enabled FROM subscriptions')
for row in queryreturn: for row in queryreturn:
label, address, enabled = row label, address, enabled = row
newItem = Ui_SubscriptionWidget(treeWidget, 0, address, 0, label, enabled) newItem = Ui_SubscriptionWidget(treeWidget, 0, address, 0, label, enabled)
unread = 0
for folder in folders: for folder in folders:
newSubItem = Ui_FolderWidget(newItem, 0, address, folder, 0) try:
newSubItem = Ui_FolderWidget(newItem, 0, address, folder, db[address][folder])
unread += db[address][folder]
except KeyError:
newSubItem = Ui_FolderWidget(newItem, 0, address, folder, 0)
newItem.setUnreadCount(unread)
treeWidget.setSortingEnabled(True) treeWidget.setSortingEnabled(True)
def rerenderTabTreeMessages(self): def rerenderTabTreeMessages(self):