From 8b527f81eecb5c24bfa762a27b6e2eac3bf2d634 Mon Sep 17 00:00:00 2001 From: mailchuck Date: Sun, 18 Oct 2015 21:11:10 +0200 Subject: [PATCH] Show subscription unread count Subscriptions were not showing unread count. This commit implements it. --- src/bitmessageqt/__init__.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 904225a7..07ed038a 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -420,13 +420,30 @@ class MyForm(QtGui.QMainWindow): treeWidget.clear() treeWidget.setSortingEnabled(False) 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') for row in queryreturn: label, address, enabled = row newItem = Ui_SubscriptionWidget(treeWidget, 0, address, 0, label, enabled) + unread = 0 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) def rerenderTabTreeMessages(self):