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

@ -11,7 +11,7 @@ from decimal import Decimal
from electrum.bitcoin import COIN
from electrum.plugins import BasePlugin, hook
from electrum.i18n import _
from electrum.util import PrintError, ThreadJob, timestamp_to_datetime
from electrum.util import PrintError, ThreadJob
from electrum.util import format_satoshis
@ -296,11 +296,8 @@ class FxPlugin(BasePlugin, ThreadJob):
def config_exchange(self):
return self.config.get('use_exchange', 'BitcoinAverage')
def config_history(self):
return self.config.get('history_rates', 'unchecked') != 'unchecked'
def show_history(self):
return self.config_history() and self.exchange.history_ccys()
return self.ccy in self.exchange.history_ccys()
def set_currency(self, ccy):
self.ccy = ccy
@ -374,24 +371,3 @@ class FxPlugin(BasePlugin, ThreadJob):
rate = self.history_rate(d_t)
return self.value_str(satoshis, rate)
@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)

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)