From 2ee881f40a8e4b86253cd1cd5ba62d54b344a835 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Wed, 28 Aug 2019 16:54:51 +0200 Subject: [PATCH] qt channels list: fields should not be editable --- electrum/gui/qt/address_list.py | 2 +- electrum/gui/qt/channels_list.py | 4 +++- electrum/gui/qt/util.py | 9 ++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/electrum/gui/qt/address_list.py b/electrum/gui/qt/address_list.py index 96436d86d..3fe77f7cf 100644 --- a/electrum/gui/qt/address_list.py +++ b/electrum/gui/qt/address_list.py @@ -146,7 +146,7 @@ class AddressList(MyTreeView): item.setTextAlignment(Qt.AlignVCenter) if i not in (self.Columns.TYPE, self.Columns.LABEL): item.setFont(QFont(MONOSPACE_FONT)) - item.setEditable(i in self.editable_columns) + self.set_editability(address_item) address_item[self.Columns.FIAT_BALANCE].setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) # setup column 0 if self.wallet.is_change(address): diff --git a/electrum/gui/qt/channels_list.py b/electrum/gui/qt/channels_list.py index 3217ec63e..e2c5a481b 100644 --- a/electrum/gui/qt/channels_list.py +++ b/electrum/gui/qt/channels_list.py @@ -40,7 +40,8 @@ class ChannelsList(MyTreeView): } def __init__(self, parent): - super().__init__(parent, self.create_menu, stretch_column=self.Columns.NODE_ID) + super().__init__(parent, self.create_menu, stretch_column=self.Columns.NODE_ID, + editable_columns=[]) self.setModel(QtGui.QStandardItemModel(self)) self.main_window = parent self.update_rows.connect(self.do_update_rows) @@ -126,6 +127,7 @@ class ChannelsList(MyTreeView): self.update_headers(self.headers) for chan in self.parent.wallet.lnworker.channels.values(): items = [QtGui.QStandardItem(x) for x in self.format_fields(chan)] + self.set_editability(items) items[self.Columns.NODE_ID].setData(chan.channel_id, ROLE_CHANNEL_ID) self.model().insertRow(0, items) diff --git a/electrum/gui/qt/util.py b/electrum/gui/qt/util.py index 7acb16ea0..f9577a7ea 100644 --- a/electrum/gui/qt/util.py +++ b/electrum/gui/qt/util.py @@ -458,7 +458,8 @@ class ElectrumItemDelegate(QStyledItemDelegate): class MyTreeView(QTreeView): - def __init__(self, parent: 'ElectrumWindow', create_menu, stretch_column=None, editable_columns=None): + def __init__(self, parent: 'ElectrumWindow', create_menu, *, + stretch_column=None, editable_columns=None): super().__init__(parent) self.parent = parent self.config = self.parent.config @@ -468,10 +469,12 @@ class MyTreeView(QTreeView): self.setUniformRowHeights(True) # Control which columns are editable - if editable_columns is None: + if editable_columns is not None: + editable_columns = set(editable_columns) + elif stretch_column is not None: editable_columns = {stretch_column} else: - editable_columns = set(editable_columns) + editable_columns = {} self.editable_columns = editable_columns self.setItemDelegate(ElectrumItemDelegate(self)) self.current_filter = ""