electrum

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

commit 9b50d1e7bc8776557ce7c6ea9f250a7a7c6f46cc
parent da5c18b2f99a9a93506f30e22ab943e91c831b55
Author: Neil Booth <kyuupichan@gmail.com>
Date:   Sun,  6 Sep 2015 21:14:36 +0900

Fix history headers on plugin load / unload

Diffstat:
Mgui/qt/history_widget.py | 11++++++++---
Mgui/qt/util.py | 19++++++++++++-------
Mplugins/exchange_rate.py | 2++
3 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/gui/qt/history_widget.py b/gui/qt/history_widget.py @@ -28,13 +28,18 @@ from electrum.plugins import run_hook class HistoryWidget(MyTreeWidget): def __init__(self, parent=None): - headers = ['', '', _('Date'), _('Description') , _('Amount'), _('Balance')] - run_hook('history_tab_headers', headers) - MyTreeWidget.__init__(self, parent, self.create_menu, headers, 3) + MyTreeWidget.__init__(self, parent, self.create_menu, [], 3) + self.refresh_headers() self.setColumnHidden(1, True) self.config = self.parent.config self.setSortingEnabled(False) + def refresh_headers(self): + headers = ['', '', _('Date'), _('Description') , _('Amount'), + _('Balance')] + run_hook('history_tab_headers', headers) + self.update_headers(headers) + def get_icon(self, conf, timestamp): time_str = _("unknown") if conf > 0: diff --git a/gui/qt/util.py b/gui/qt/util.py @@ -303,9 +303,7 @@ class MyTreeWidget(QTreeWidget): editable_columns=None): QTreeWidget.__init__(self, parent) self.parent = parent - self.setColumnCount(len(headers)) - self.setHeaderLabels(headers) - self.header().setStretchLastSection(False) + self.stretch_column = stretch_column self.setContextMenuPolicy(Qt.CustomContextMenu) self.itemActivated.connect(self.on_activated) self.customContextMenuRequested.connect(create_menu) @@ -322,12 +320,19 @@ class MyTreeWidget(QTreeWidget): QAbstractItemView.EditKeyPressed) self.setItemDelegate(EditableItemDelegate(self)) self.itemChanged.connect(self.item_changed) - - # stretch - for i in range(len(headers)): - self.header().setResizeMode(i, QHeaderView.Stretch if i == stretch_column else QHeaderView.ResizeToContents) + self.update_headers(headers) self.setSortingEnabled(True) + def update_headers(self, headers): + self.setColumnCount(len(headers)) + self.setHeaderLabels(headers) + self.header().setStretchLastSection(False) + for col in range(len(headers)): + if col == self.stretch_column: + self.header().setResizeMode(col, QHeaderView.Stretch) + else: + self.header().setResizeMode(col, QHeaderView.ResizeToContents) + def on_activated(self, item): if not item: return diff --git a/plugins/exchange_rate.py b/plugins/exchange_rate.py @@ -268,6 +268,7 @@ class Plugin(BasePlugin, ThreadJob): 'last_edited': {}} self.connect_fields(window, window.amount_e, send_e, window.fee_e) self.connect_fields(window, window.receive_amount_e, receive_e, None) + window.history_list.refresh_headers() window.update_status() def connect_fields(self, window, btc_e, fiat_e, fee_e): @@ -313,6 +314,7 @@ class Plugin(BasePlugin, ThreadJob): for window, data in self.windows.items(): for edit in data['edits']: edit.hide() + window.history_list.refresh_headers() window.update_status() def on_fx_history(self):