Browse Source

Fix history headers on plugin load / unload

283
Neil Booth 9 years ago
parent
commit
9b50d1e7bc
  1. 11
      gui/qt/history_widget.py
  2. 19
      gui/qt/util.py
  3. 2
      plugins/exchange_rate.py

11
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:

19
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

2
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):

Loading…
Cancel
Save