From 64ee159ae35ce3b86999e8764c40553c8564310d Mon Sep 17 00:00:00 2001 From: mailchuck Date: Fri, 27 Nov 2015 02:10:27 +0100 Subject: [PATCH] Add BROADCAST type also improve sorting --- src/bitmessageqt/account.py | 24 +++++++++++++----------- src/bitmessageqt/foldertree.py | 3 ++- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/bitmessageqt/account.py b/src/bitmessageqt/account.py index 83ce76c9..f881cc8c 100644 --- a/src/bitmessageqt/account.py +++ b/src/bitmessageqt/account.py @@ -42,11 +42,11 @@ def accountClass(address): if not shared.config.has_section(address): if address == str_broadcast_subscribers: subscription = BroadcastAccount(address) - if subscription.type != 'broadcast': + if subscription.type != AccountMixin.BROADCAST: return None else: subscription = SubscriptionAccount(address) - if subscription.type != 'subscription': + if subscription.type != AccountMixin.SUBSCRIPTION: return None return subscription try: @@ -67,15 +67,17 @@ class AccountColor(AccountMixin): self.isEnabled = True self.address = address if type is None: - if shared.safeConfigGetBoolean(self.address, 'mailinglist'): - self.type = "mailinglist" + if address is None: + self.type = AccountMixin.ALL + elif shared.safeConfigGetBoolean(self.address, 'mailinglist'): + self.type = AccountMixin.MAILINGLIST elif shared.safeConfigGetBoolean(self.address, 'chan'): - self.type = "chan" + self.type = AccountMixin.CHAN elif sqlQuery( '''select label from subscriptions where address=?''', self.address): - self.type = 'subscription' + self.type = AccountMixin.SUBSCRIPTION else: - self.type = "normal" + self.type = AccountMixin.NORMAL else: self.type = type @@ -86,16 +88,16 @@ class BMAccount(object): self.type = 'normal' if shared.config.has_section(address): if shared.safeConfigGetBoolean(self.address, 'chan'): - self.type = "chan" + self.type = AccountMixin.CHAN elif shared.safeConfigGetBoolean(self.address, 'mailinglist'): - self.type = "mailinglist" + self.type = AccountMixin.MAILINGLIST elif self.address == str_broadcast_subscribers: - self.type = 'broadcast' + self.type = AccountMixin.BROADCAST else: queryreturn = sqlQuery( '''select label from subscriptions where address=?''', self.address) if queryreturn: - self.type = 'subscription' + self.type = AccountMixin.SUBSCRIPTION def getLabel(self, address = None): if address is None: diff --git a/src/bitmessageqt/foldertree.py b/src/bitmessageqt/foldertree.py index 03477218..971cda61 100644 --- a/src/bitmessageqt/foldertree.py +++ b/src/bitmessageqt/foldertree.py @@ -11,6 +11,7 @@ class AccountMixin (object): CHAN = 2 MAILINGLIST = 3 SUBSCRIPTION = 4 + BROADCAST = 5 def accountColor (self): if not self.isEnabled: @@ -206,7 +207,7 @@ class Ui_AddressWidget(QtGui.QTreeWidgetItem, AccountMixin, SettingsMixin): def _getSortRank(self): ret = self.type if not self.isEnabled: - ret += 5 + ret += 100 return ret # label (or address) alphabetically, disabled at the end