Add BROADCAST type

also improve sorting
This commit is contained in:
mailchuck 2015-11-27 02:10:27 +01:00
parent 3fbd3f9cb4
commit 64ee159ae3
Signed by untrusted user who does not match committer: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87
2 changed files with 15 additions and 12 deletions

View File

@ -42,11 +42,11 @@ def accountClass(address):
if not shared.config.has_section(address): if not shared.config.has_section(address):
if address == str_broadcast_subscribers: if address == str_broadcast_subscribers:
subscription = BroadcastAccount(address) subscription = BroadcastAccount(address)
if subscription.type != 'broadcast': if subscription.type != AccountMixin.BROADCAST:
return None return None
else: else:
subscription = SubscriptionAccount(address) subscription = SubscriptionAccount(address)
if subscription.type != 'subscription': if subscription.type != AccountMixin.SUBSCRIPTION:
return None return None
return subscription return subscription
try: try:
@ -67,15 +67,17 @@ class AccountColor(AccountMixin):
self.isEnabled = True self.isEnabled = True
self.address = address self.address = address
if type is None: if type is None:
if shared.safeConfigGetBoolean(self.address, 'mailinglist'): if address is None:
self.type = "mailinglist" self.type = AccountMixin.ALL
elif shared.safeConfigGetBoolean(self.address, 'mailinglist'):
self.type = AccountMixin.MAILINGLIST
elif shared.safeConfigGetBoolean(self.address, 'chan'): elif shared.safeConfigGetBoolean(self.address, 'chan'):
self.type = "chan" self.type = AccountMixin.CHAN
elif sqlQuery( elif sqlQuery(
'''select label from subscriptions where address=?''', self.address): '''select label from subscriptions where address=?''', self.address):
self.type = 'subscription' self.type = AccountMixin.SUBSCRIPTION
else: else:
self.type = "normal" self.type = AccountMixin.NORMAL
else: else:
self.type = type self.type = type
@ -86,16 +88,16 @@ class BMAccount(object):
self.type = 'normal' self.type = 'normal'
if shared.config.has_section(address): if shared.config.has_section(address):
if shared.safeConfigGetBoolean(self.address, 'chan'): if shared.safeConfigGetBoolean(self.address, 'chan'):
self.type = "chan" self.type = AccountMixin.CHAN
elif shared.safeConfigGetBoolean(self.address, 'mailinglist'): elif shared.safeConfigGetBoolean(self.address, 'mailinglist'):
self.type = "mailinglist" self.type = AccountMixin.MAILINGLIST
elif self.address == str_broadcast_subscribers: elif self.address == str_broadcast_subscribers:
self.type = 'broadcast' self.type = AccountMixin.BROADCAST
else: else:
queryreturn = sqlQuery( queryreturn = sqlQuery(
'''select label from subscriptions where address=?''', self.address) '''select label from subscriptions where address=?''', self.address)
if queryreturn: if queryreturn:
self.type = 'subscription' self.type = AccountMixin.SUBSCRIPTION
def getLabel(self, address = None): def getLabel(self, address = None):
if address is None: if address is None:

View File

@ -11,6 +11,7 @@ class AccountMixin (object):
CHAN = 2 CHAN = 2
MAILINGLIST = 3 MAILINGLIST = 3
SUBSCRIPTION = 4 SUBSCRIPTION = 4
BROADCAST = 5
def accountColor (self): def accountColor (self):
if not self.isEnabled: if not self.isEnabled:
@ -206,7 +207,7 @@ class Ui_AddressWidget(QtGui.QTreeWidgetItem, AccountMixin, SettingsMixin):
def _getSortRank(self): def _getSortRank(self):
ret = self.type ret = self.type
if not self.isEnabled: if not self.isEnabled:
ret += 5 ret += 100
return ret return ret
# label (or address) alphabetically, disabled at the end # label (or address) alphabetically, disabled at the end