Add BROADCAST type

also improve sorting
This commit is contained in:
mailchuck 2015-11-27 02:10:27 +01:00 committed by Peter Surda
parent be02116af9
commit a3b13b70e2
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 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:

View File

@ -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