Address tree sorting

Sorts addresses in the address tree
This commit is contained in:
mailchuck 2015-10-01 10:08:12 +02:00
parent db9276f349
commit 9c611178e1

View File

@ -168,6 +168,28 @@ def change_translation(locale):
qtranslator.load(translationpath) qtranslator.load(translationpath)
QtGui.QApplication.installTranslator(qtranslator) QtGui.QApplication.installTranslator(qtranslator)
def address_compare(x, y):
if x == "bitmessagesettings":
return -1
elif y == "bitmessagesettings":
return 1
if shared.config.getboolean(x, 'enabled') == shared.config.getboolean(y, 'enabled'):
if shared.config.get(x, 'label'):
x1 = shared.config.get(x, 'label')
else:
x1 = x
if shared.config.get(y, 'label'):
y1 = shared.config.get(y, 'label')
else:
y1 = y
if x1 > y1:
return 1
elif x1 < y1:
return -1
else:
return 0
else:
return (1 if shared.config.getboolean(x, 'enabled') else '-1')
class MyForm(QtGui.QMainWindow): class MyForm(QtGui.QMainWindow):
@ -553,7 +575,7 @@ class MyForm(QtGui.QMainWindow):
toaddress, folder, cnt = row toaddress, folder, cnt = row
cntUnreadMsg[toaddress + folder] = cnt cntUnreadMsg[toaddress + folder] = cnt
configSections = shared.config.sections() configSections = sorted(shared.config.sections(), cmp=address_compare)
for addressInKeysFile in configSections: for addressInKeysFile in configSections:
if addressInKeysFile != 'bitmessagesettings': if addressInKeysFile != 'bitmessagesettings':
isEnabled = shared.config.getboolean( isEnabled = shared.config.getboolean(