gui: don't show account names if there is only one account
authorThomasV <thomasv@gitorious>
Fri, 25 Apr 2014 09:56:17 +0000 (11:56 +0200)
committerThomasV <thomasv@gitorious>
Fri, 25 Apr 2014 09:56:17 +0000 (11:56 +0200)
gui/qt/main_window.py

index 4ce7372..a039f91 100644 (file)
@@ -1198,22 +1198,31 @@ class ElectrumWindow(QMainWindow):
         else:
             account_items = []
 
+        pending_accounts = self.wallet.get_pending_accounts()
+
         for k, account in account_items:
-            name = self.wallet.get_account_name(k)
-            c,u = self.wallet.get_account_balance(k)
-            account_item = QTreeWidgetItem( [ name, '', self.format_amount(c+u), ''] )
-            l.addTopLevelItem(account_item)
-            account_item.setExpanded(self.accounts_expanded.get(k, True))
-            account_item.setData(0, 32, k)
 
-            if not self.wallet.is_seeded(k):
-                icon = QIcon(":icons/key.png")
-                account_item.setIcon(0, icon)
+            if len(account_items) + len(pending_accounts) > 1:
+                name = self.wallet.get_account_name(k)
+                c,u = self.wallet.get_account_balance(k)
+                account_item = QTreeWidgetItem( [ name, '', self.format_amount(c+u), ''] )
+                l.addTopLevelItem(account_item)
+                account_item.setExpanded(self.accounts_expanded.get(k, True))
+                account_item.setData(0, 32, k)
+                if not self.wallet.is_seeded(k):
+                    icon = QIcon(":icons/key.png")
+                    account_item.setIcon(0, icon)
+            else:
+                account_item = None
 
             for is_change in ([0,1]):
                 name = _("Receiving") if not is_change else _("Change")
                 seq_item = QTreeWidgetItem( [ name, '', '', '', ''] )
-                account_item.addChild(seq_item)
+                if account_item:
+                    account_item.addChild(seq_item)
+                else:
+                    l.addTopLevelItem(seq_item)
+                    
                 used_item = QTreeWidgetItem( [ _("Used"), '', '', '', ''] )
                 used_flag = False
                 if not is_change: seq_item.setExpanded(True)
@@ -1246,7 +1255,7 @@ class ElectrumWindow(QMainWindow):
                         seq_item.addChild(item)
 
 
-        for k, addr in self.wallet.get_pending_accounts():
+        for k, addr in pending_accounts:
             name = self.wallet.labels.get(k,'')
             account_item = QTreeWidgetItem( [ name + "  [ "+_('pending account')+" ]", '', '', ''] )
             self.update_receive_item(item)
@@ -1451,7 +1460,7 @@ class ElectrumWindow(QMainWindow):
         name = str(e.text())
         if not name: return
 
-        self.wallet.create_pending_account('1of1', name, password)
+        self.wallet.create_pending_account(name, password)
         self.update_receive_tab()
         self.tabs.setCurrentIndex(2)