1
0

exchange_rates plugin: move methods to qt version

This commit is contained in:
ThomasV
2016-01-29 17:56:13 +01:00
parent 2c7b10a776
commit e3b37512ed
2 changed files with 32 additions and 26 deletions

View File

@@ -10,6 +10,7 @@ from decimal import Decimal
from functools import partial
from electrum.plugins import hook
from exchange_rate import FxPlugin
from electrum.util import timestamp_to_datetime
class Plugin(FxPlugin):
@@ -176,3 +177,32 @@ class Plugin(FxPlugin):
layout.addWidget(ok_button,3,1)
return d.exec_()
def config_history(self):
return self.config.get('history_rates', 'unchecked') != 'unchecked'
def show_history(self):
return self.config_history() and self.ccy in self.exchange.history_ccys()
@hook
def history_tab_headers(self, headers):
if self.show_history():
headers.extend(['%s '%self.ccy + _('Amount'), '%s '%self.ccy + _('Balance')])
@hook
def history_tab_update_begin(self):
self.history_used_spot = False
@hook
def history_tab_update(self, tx, entry):
if not self.show_history():
return
tx_hash, conf, value, timestamp, balance = tx
if conf <= 0:
date = datetime.today()
else:
date = timestamp_to_datetime(timestamp)
for amount in [value, balance]:
text = self.historical_value_str(amount, date)
entry.append(text)