Browse Source

cleanup

master
Sander van Grieken 4 years ago
parent
commit
7b71323506
  1. 8
      electrum/gui/qml/qeconfig.py
  2. 10
      electrum/gui/qml/qenetwork.py
  3. 5
      electrum/gui/qml/qetransactionlistmodel.py
  4. 1
      electrum/gui/qml/qewallet.py

8
electrum/gui/qml/qeconfig.py

@ -3,6 +3,7 @@ from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject
from decimal import Decimal from decimal import Decimal
from electrum.logging import get_logger from electrum.logging import get_logger
from electrum.util import DECIMAL_POINT_DEFAULT
class QEConfig(QObject): class QEConfig(QObject):
def __init__(self, config, parent=None): def __init__(self, config, parent=None):
@ -78,7 +79,7 @@ class QEConfig(QObject):
# TODO delegate all this to config.py/util.py # TODO delegate all this to config.py/util.py
def decimal_point(self): def decimal_point(self):
return self.config.get('decimal_point') return self.config.get('decimal_point', DECIMAL_POINT_DEFAULT)
def max_precision(self): def max_precision(self):
return self.decimal_point() + 0 #self.extra_precision return self.decimal_point() + 0 #self.extra_precision
@ -89,13 +90,14 @@ class QEConfig(QObject):
try: try:
x = Decimal(unitAmount) x = Decimal(unitAmount)
except: except:
return None return 0
# scale it to max allowed precision, make it an int # scale it to max allowed precision, make it an int
max_prec_amount = int(pow(10, self.max_precision()) * x) max_prec_amount = int(pow(10, self.max_precision()) * x)
# if the max precision is simply what unit conversion allows, just return # if the max precision is simply what unit conversion allows, just return
if self.max_precision() == self.decimal_point(): if self.max_precision() == self.decimal_point():
return max_prec_amount return max_prec_amount
self._logger.debug('fallthrough')
# otherwise, scale it back to the expected unit # otherwise, scale it back to the expected unit
#amount = Decimal(max_prec_amount) / Decimal(pow(10, self.max_precision()-self.decimal_point())) #amount = Decimal(max_prec_amount) / Decimal(pow(10, self.max_precision()-self.decimal_point()))
#return int(amount) #Decimal(amount) if not self.is_int else int(amount) #return int(amount) #Decimal(amount) if not self.is_int else int(amount)
return 0

10
electrum/gui/qml/qenetwork.py

@ -23,7 +23,7 @@ class QENetwork(QObject):
defaultServerChanged = pyqtSignal() defaultServerChanged = pyqtSignal()
proxySet = pyqtSignal() proxySet = pyqtSignal()
proxyChanged = pyqtSignal() proxyChanged = pyqtSignal()
statusUpdated = pyqtSignal() statusChanged = pyqtSignal()
feeHistogramUpdated = pyqtSignal() feeHistogramUpdated = pyqtSignal()
dataChanged = pyqtSignal() # dummy to silence warnings dataChanged = pyqtSignal() # dummy to silence warnings
@ -52,12 +52,12 @@ class QENetwork(QObject):
self.proxySet.emit() self.proxySet.emit()
def on_status(self, event, *args): def on_status(self, event, *args):
self._logger.info('status updated') self._logger.debug('status updated: %s' % self.network.connection_status)
self._status = self.network.connection_status self._status = self.network.connection_status
self.statusUpdated.emit() self.statusChanged.emit()
def on_fee_histogram(self, event, *args): def on_fee_histogram(self, event, *args):
self._logger.warning('fee histogram updated') self._logger.debug('fee histogram updated')
self.feeHistogramUpdated.emit() self.feeHistogramUpdated.emit()
@pyqtProperty(int,notify=networkUpdated) @pyqtProperty(int,notify=networkUpdated)
@ -83,7 +83,7 @@ class QENetwork(QObject):
net_params = net_params._replace(server=server) net_params = net_params._replace(server=server)
self.network.run_from_another_thread(self.network.set_parameters(net_params)) self.network.run_from_another_thread(self.network.set_parameters(net_params))
@pyqtProperty('QString',notify=statusUpdated) @pyqtProperty('QString',notify=statusChanged)
def status(self): def status(self):
return self._status return self._status

5
electrum/gui/qml/qetransactionlistmodel.py

@ -13,8 +13,9 @@ class QETransactionListModel(QAbstractListModel):
_logger = get_logger(__name__) _logger = get_logger(__name__)
# define listmodel rolemap # define listmodel rolemap
_ROLE_NAMES=('txid','fee_sat','height','confirmations','timestamp','monotonic_timestamp','incoming','bc_value', _ROLE_NAMES=('txid','fee_sat','height','confirmations','timestamp','monotonic_timestamp',
'bc_balance','date','label','txpos_in_block','fee','inputs','outputs') 'incoming','bc_value','bc_balance','date','label','txpos_in_block','fee',
'inputs','outputs')
_ROLE_KEYS = range(Qt.UserRole + 1, Qt.UserRole + 1 + len(_ROLE_NAMES)) _ROLE_KEYS = range(Qt.UserRole + 1, Qt.UserRole + 1 + len(_ROLE_NAMES))
_ROLE_MAP = dict(zip(_ROLE_KEYS, [bytearray(x.encode()) for x in _ROLE_NAMES])) _ROLE_MAP = dict(zip(_ROLE_KEYS, [bytearray(x.encode()) for x in _ROLE_NAMES]))

1
electrum/gui/qml/qewallet.py

@ -172,7 +172,6 @@ class QEWallet(QObject):
key = self.create_bitcoin_request(amount, message, expiry, ignore_gap) key = self.create_bitcoin_request(amount, message, expiry, ignore_gap)
if not key: if not key:
return return
#self.address_list.update()
self._addressModel.init_model() self._addressModel.init_model()
except InvoiceError as e: except InvoiceError as e:
self.requestCreateError.emit('fatal',_('Error creating payment request') + ':\n' + str(e)) self.requestCreateError.emit('fatal',_('Error creating payment request') + ':\n' + str(e))

Loading…
Cancel
Save