Skip to content

Commit

Permalink
Namecoin: Sort subdomains in DNS dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyRand committed Dec 12, 2019
1 parent 36c96ef commit f67fa3a
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion electrum_nmc/electrum/gui/qt/configure_dns_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,28 @@ def __init__(self, value, parent):
self.accepted.connect(lambda: self.name_dialog.set_value(self.get_value()))

def add_domain(self, domain):
self.ui.comboDomain.addItem(domain)
domain_reverse = domain.split(".")[::-1]

combo = self.ui.comboDomain

for index in range(combo.count()):
domain_at_index = combo.itemText(index)

# Duplicate of existing domain.
if domain == domain_at_index:
return

# "Add Subdomain" item is always at the end.
if domain_at_index == _(self.__class__.TEXT_ADD_SUBDOMAIN):
combo.insertItem(index, domain)
return

domain_at_index_reverse = domain_at_index.split(".")[::-1]

# We've found the right place to insert it.
if domain_reverse < domain_at_index_reverse:
combo.insertItem(index, domain)
return

def domain_changed(self, index):
if self.ui.comboDomain.itemText(index) == _(self.__class__.TEXT_ADD_SUBDOMAIN):
Expand Down

0 comments on commit f67fa3a

Please sign in to comment.