Account listing and sorting
- account listing and sorting has now a common function to reuse - combobox send from is now sorted, Fixes #59
This commit is contained in:
parent
bc6db7f0e5
commit
245ed6d789
|
@ -467,9 +467,7 @@ class MyForm(QtGui.QMainWindow):
|
||||||
db = {}
|
db = {}
|
||||||
enabled = {}
|
enabled = {}
|
||||||
|
|
||||||
for toAddress in shared.config.sections():
|
for toAddress in getSortedAccounts():
|
||||||
if toAddress == 'bitmessagesettings':
|
|
||||||
continue
|
|
||||||
isEnabled = shared.config.getboolean(
|
isEnabled = shared.config.getboolean(
|
||||||
toAddress, 'enabled')
|
toAddress, 'enabled')
|
||||||
isChan = shared.safeConfigGetBoolean(
|
isChan = shared.safeConfigGetBoolean(
|
||||||
|
@ -553,9 +551,7 @@ class MyForm(QtGui.QMainWindow):
|
||||||
|
|
||||||
# Ask the user if we may delete their old version 1 addresses if they
|
# Ask the user if we may delete their old version 1 addresses if they
|
||||||
# have any.
|
# have any.
|
||||||
configSections = shared.config.sections()
|
for addressInKeysFile in getSortedAccounts():
|
||||||
for addressInKeysFile in configSections:
|
|
||||||
if addressInKeysFile != 'bitmessagesettings':
|
|
||||||
status, addressVersionNumber, streamNumber, hash = decodeAddress(
|
status, addressVersionNumber, streamNumber, hash = decodeAddress(
|
||||||
addressInKeysFile)
|
addressInKeysFile)
|
||||||
if addressVersionNumber == 1:
|
if addressVersionNumber == 1:
|
||||||
|
@ -2182,15 +2178,14 @@ class MyForm(QtGui.QMainWindow):
|
||||||
|
|
||||||
def rerenderComboBoxSendFrom(self):
|
def rerenderComboBoxSendFrom(self):
|
||||||
self.ui.comboBoxSendFrom.clear()
|
self.ui.comboBoxSendFrom.clear()
|
||||||
configSections = shared.config.sections()
|
for addressInKeysFile in getSortedAccounts():
|
||||||
for addressInKeysFile in configSections:
|
|
||||||
if addressInKeysFile != 'bitmessagesettings':
|
|
||||||
isEnabled = shared.config.getboolean(
|
isEnabled = shared.config.getboolean(
|
||||||
addressInKeysFile, 'enabled') # I realize that this is poor programming practice but I don't care. It's easier for others to read.
|
addressInKeysFile, 'enabled') # I realize that this is poor programming practice but I don't care. It's easier for others to read.
|
||||||
isMaillinglist = shared.safeConfigGetBoolean(addressInKeysFile, 'mailinglist')
|
isMaillinglist = shared.safeConfigGetBoolean(addressInKeysFile, 'mailinglist')
|
||||||
if isEnabled and not isMaillinglist:
|
if isEnabled and not isMaillinglist:
|
||||||
self.ui.comboBoxSendFrom.insertItem(0, avatarize(addressInKeysFile), unicode(shared.config.get(
|
self.ui.comboBoxSendFrom.addItem(avatarize(addressInKeysFile), unicode(shared.config.get(
|
||||||
addressInKeysFile, 'label'), 'utf-8'), addressInKeysFile)
|
addressInKeysFile, 'label'), 'utf-8'), addressInKeysFile)
|
||||||
|
# self.ui.comboBoxSendFrom.model().sort(1, Qt.AscendingOrder)
|
||||||
self.ui.comboBoxSendFrom.insertItem(0, '', '')
|
self.ui.comboBoxSendFrom.insertItem(0, '', '')
|
||||||
if(self.ui.comboBoxSendFrom.count() == 2):
|
if(self.ui.comboBoxSendFrom.count() == 2):
|
||||||
self.ui.comboBoxSendFrom.setCurrentIndex(1)
|
self.ui.comboBoxSendFrom.setCurrentIndex(1)
|
||||||
|
@ -2199,14 +2194,12 @@ class MyForm(QtGui.QMainWindow):
|
||||||
|
|
||||||
def rerenderComboBoxSendFromBroadcast(self):
|
def rerenderComboBoxSendFromBroadcast(self):
|
||||||
self.ui.comboBoxSendFromBroadcast.clear()
|
self.ui.comboBoxSendFromBroadcast.clear()
|
||||||
configSections = shared.config.sections()
|
for addressInKeysFile in getSortedAccounts():
|
||||||
for addressInKeysFile in configSections:
|
|
||||||
if addressInKeysFile != 'bitmessagesettings':
|
|
||||||
isEnabled = shared.config.getboolean(
|
isEnabled = shared.config.getboolean(
|
||||||
addressInKeysFile, 'enabled') # I realize that this is poor programming practice but I don't care. It's easier for others to read.
|
addressInKeysFile, 'enabled') # I realize that this is poor programming practice but I don't care. It's easier for others to read.
|
||||||
isMaillinglist = shared.safeConfigGetBoolean(addressInKeysFile, 'mailinglist')
|
isMaillinglist = shared.safeConfigGetBoolean(addressInKeysFile, 'mailinglist')
|
||||||
if isEnabled and isMaillinglist:
|
if isEnabled and isMaillinglist:
|
||||||
self.ui.comboBoxSendFromBroadcast.insertItem(0, avatarize(addressInKeysFile), unicode(shared.config.get(
|
self.ui.comboBoxSendFromBroadcast.addItem(avatarize(addressInKeysFile), unicode(shared.config.get(
|
||||||
addressInKeysFile, 'label'), 'utf-8'), addressInKeysFile)
|
addressInKeysFile, 'label'), 'utf-8'), addressInKeysFile)
|
||||||
self.ui.comboBoxSendFromBroadcast.insertItem(0, '', '')
|
self.ui.comboBoxSendFromBroadcast.insertItem(0, '', '')
|
||||||
if(self.ui.comboBoxSendFromBroadcast.count() == 2):
|
if(self.ui.comboBoxSendFromBroadcast.count() == 2):
|
||||||
|
@ -2711,10 +2704,7 @@ class MyForm(QtGui.QMainWindow):
|
||||||
|
|
||||||
def click_NewAddressDialog(self):
|
def click_NewAddressDialog(self):
|
||||||
addresses = []
|
addresses = []
|
||||||
configSections = shared.config.sections()
|
for addressInKeysFile in getSortedAccounts():
|
||||||
for addressInKeysFile in configSections:
|
|
||||||
if addressInKeysFile == 'bitmessagesettings':
|
|
||||||
continue
|
|
||||||
addresses.append(addressInKeysFile)
|
addresses.append(addressInKeysFile)
|
||||||
# self.dialog = Ui_NewAddressWizard(addresses)
|
# self.dialog = Ui_NewAddressWizard(addresses)
|
||||||
# self.dialog.exec_()
|
# self.dialog.exec_()
|
||||||
|
@ -4054,10 +4044,7 @@ class NewAddressDialog(QtGui.QDialog):
|
||||||
row = 1
|
row = 1
|
||||||
# Let's fill out the 'existing address' combo box with addresses from
|
# Let's fill out the 'existing address' combo box with addresses from
|
||||||
# the 'Your Identities' tab.
|
# the 'Your Identities' tab.
|
||||||
configSections = shared.config.sections()
|
for addressInKeysFile in getSortedAccounts():
|
||||||
for addressInKeysFile in configSections:
|
|
||||||
if addressInKeysFile == 'bitmessagesettings':
|
|
||||||
continue
|
|
||||||
self.ui.radioButtonExisting.click()
|
self.ui.radioButtonExisting.click()
|
||||||
self.ui.comboBoxExisting.addItem(
|
self.ui.comboBoxExisting.addItem(
|
||||||
addressInKeysFile)
|
addressInKeysFile)
|
||||||
|
|
|
@ -10,6 +10,13 @@ from pyelliptic.openssl import OpenSSL
|
||||||
from utils import str_broadcast_subscribers
|
from utils import str_broadcast_subscribers
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
def getSortedAccounts():
|
||||||
|
configSections = filter(lambda x: x != 'bitmessagesettings', shared.config.sections())
|
||||||
|
configSections.sort(cmp =
|
||||||
|
lambda x,y: cmp(unicode(shared.config.get(x, 'label'), 'utf-8').lower(), unicode(shared.config.get(y, 'label'), 'utf-8').lower())
|
||||||
|
)
|
||||||
|
return configSections
|
||||||
|
|
||||||
def accountClass(address):
|
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:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user