electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 43487910c7bd4868f3fd43054dd36a2dee5d0fc5
parent 905e271db9db322bc4edcf3b21408af32cc82c32
Author: SomberNight <somber.night@protonmail.com>
Date:   Sun,  3 Feb 2019 20:04:33 +0100

qt network dialog: use intenum for columns

Diffstat:
Melectrum/gui/qt/network_dialog.py | 14++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/electrum/gui/qt/network_dialog.py b/electrum/gui/qt/network_dialog.py @@ -24,6 +24,7 @@ # SOFTWARE. import socket +from enum import IntEnum from PyQt5.QtGui import * from PyQt5.QtCore import * @@ -132,6 +133,11 @@ class NodesListWidget(QTreeWidget): class ServerListWidget(QTreeWidget): + class Columns(IntEnum): + HOST = 0 + PORT = 1 + + SERVER_STR_ROLE = Qt.UserRole + 100 def __init__(self, parent): QTreeWidget.__init__(self) @@ -145,7 +151,7 @@ class ServerListWidget(QTreeWidget): if not item: return menu = QMenu() - server = item.data(1, Qt.UserRole) + server = item.data(self.Columns.HOST, self.SERVER_STR_ROLE) menu.addAction(_("Use as server"), lambda: self.set_server(server)) menu.exec_(self.viewport().mapToGlobal(position)) @@ -176,13 +182,13 @@ class ServerListWidget(QTreeWidget): if port: x = QTreeWidgetItem([_host, port]) server = serialize_server(_host, port, protocol) - x.setData(1, Qt.UserRole, server) + x.setData(self.Columns.HOST, self.SERVER_STR_ROLE, server) self.addTopLevelItem(x) h = self.header() h.setStretchLastSection(False) - h.setSectionResizeMode(0, QHeaderView.Stretch) - h.setSectionResizeMode(1, QHeaderView.ResizeToContents) + h.setSectionResizeMode(self.Columns.HOST, QHeaderView.Stretch) + h.setSectionResizeMode(self.Columns.PORT, QHeaderView.ResizeToContents) super().update()