Skip to content
Snippets Groups Projects
Commit 10a31e15 authored by inso's avatar inso
Browse files

Added a selector for viewing units type

parent 19d6c003
No related branches found
No related tags found
No related merge requests found
...@@ -102,6 +102,10 @@ class Account(object): ...@@ -102,6 +102,10 @@ class Account(object):
self.communities.append(community) self.communities.append(community)
return community return community
def set_display_referential(self, index):
for w in self.wallets:
w.set_display_referential(index)
def set_walletpool_size(self, size, password): def set_walletpool_size(self, size, password):
logging.debug("Defining wallet pool size") logging.debug("Defining wallet pool size")
if len(self.wallets) < size: if len(self.wallets) < size:
......
...@@ -146,6 +146,12 @@ class Wallet(object): ...@@ -146,6 +146,12 @@ class Wallet(object):
self.pubkey = pubkey self.pubkey = pubkey
self.name = name self.name = name
self.caches = {} self.caches = {}
self.referentials = [self.value,
self.relative_value,
self.value_from_zero,
self.relative_from_zero
]
self.referential = self.referentials[0]
@classmethod @classmethod
def create(cls, walletid, salt, password, name): def create(cls, walletid, salt, password, name):
...@@ -189,6 +195,9 @@ class Wallet(object): ...@@ -189,6 +195,9 @@ class Wallet(object):
key = SigningKey("{0}{1}".format(salt, self.walletid), password) key = SigningKey("{0}{1}".format(salt, self.walletid), password)
return (key.pubkey == self.pubkey) return (key.pubkey == self.pubkey)
def show_value(self, community):
return self.referential(community)
def relative_value(self, community): def relative_value(self, community):
value = self.value(community) value = self.value(community)
ud = community.dividend() ud = community.dividend()
...@@ -201,6 +210,21 @@ class Wallet(object): ...@@ -201,6 +210,21 @@ class Wallet(object):
value += s.amount value += s.amount
return value return value
def relative_from_zero(self, community):
value = self.value(community)
ud = community.dividend()
relative_value = value / float(ud)
return relative_value
def value_from_zero(self, community):
value = 0
for s in self.sources(community):
value += s.amount
return value
def set_display_referential(self, index):
self.referential = self.referentials[index]
def tx_inputs(self, amount, community): def tx_inputs(self, amount, community):
value = 0 value = 0
inputs = [] inputs = []
......
...@@ -4,7 +4,8 @@ Created on 1 févr. 2014 ...@@ -4,7 +4,8 @@ Created on 1 févr. 2014
@author: inso @author: inso
''' '''
from cutecoin.gen_resources.mainwindow_uic import Ui_MainWindow from cutecoin.gen_resources.mainwindow_uic import Ui_MainWindow
from PyQt5.QtWidgets import QMainWindow, QAction, QFileDialog, QProgressBar, QMessageBox, QLabel from PyQt5.QtWidgets import QMainWindow, QAction, QFileDialog, QProgressBar, \
QMessageBox, QLabel, QComboBox
from PyQt5.QtCore import QSignalMapper, QModelIndex, QObject, QThread, pyqtSlot, pyqtSignal from PyQt5.QtCore import QSignalMapper, QModelIndex, QObject, QThread, pyqtSlot, pyqtSignal
from PyQt5.QtGui import QIcon from PyQt5.QtGui import QIcon
from .process_cfg_account import ProcessConfigureAccount from .process_cfg_account import ProcessConfigureAccount
...@@ -68,8 +69,15 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -68,8 +69,15 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.statusbar.addWidget(self.busybar) self.statusbar.addWidget(self.busybar)
self.busybar.hide() self.busybar.hide()
self.combo_referential = QComboBox(self)
self.combo_referential.setEnabled(False)
self.combo_referential.currentIndexChanged.connect(self.referential_changed)
self.combo_referential.addItems(("Units", "UD",
"Units to zero", "UD to zero"))
self.status_label = QLabel("", self.statusbar) self.status_label = QLabel("", self.statusbar)
self.statusbar.addPermanentWidget(self.status_label) self.statusbar.addPermanentWidget(self.status_label)
self.statusbar.addPermanentWidget(self.combo_referential)
self.loader_thread = QThread() self.loader_thread = QThread()
self.loader = Loader(self.app) self.loader = Loader(self.app)
...@@ -97,6 +105,11 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -97,6 +105,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
error, error,
QMessageBox.Ok) QMessageBox.Ok)
@pyqtSlot(int)
def referential_changed(self, index):
if self.app.current_account:
self.app.current_account.set_display_referential(index)
def action_change_account(self, account_name): def action_change_account(self, account_name):
self.busybar.show() self.busybar.show()
self.status_label.setText("Loading account {0}".format(account_name)) self.status_label.setText("Loading account {0}".format(account_name))
...@@ -171,10 +184,12 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -171,10 +184,12 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.menu_actions.setEnabled(False) self.menu_actions.setEnabled(False)
self.action_configure_parameters.setEnabled(False) self.action_configure_parameters.setEnabled(False)
self.action_set_as_default.setEnabled(False) self.action_set_as_default.setEnabled(False)
self.combo_referential.setEnabled(False)
else: else:
self.action_set_as_default.setEnabled(self.app.current_account.name self.action_set_as_default.setEnabled(self.app.current_account.name
!= self.app.default_account) != self.app.default_account)
self.password_asker = PasswordAskerDialog(self.app.current_account) self.password_asker = PasswordAskerDialog(self.app.current_account)
self.combo_referential.setEnabled(True)
self.menu_contacts.setEnabled(True) self.menu_contacts.setEnabled(True)
self.action_configure_parameters.setEnabled(True) self.action_configure_parameters.setEnabled(True)
self.menu_actions.setEnabled(True) self.menu_actions.setEnabled(True)
......
...@@ -38,7 +38,6 @@ class TxFilterProxyModel(QSortFilterProxyModel): ...@@ -38,7 +38,6 @@ class TxFilterProxyModel(QSortFilterProxyModel):
""" """
Sort table by given column number. Sort table by given column number.
""" """
logging.debug(self.sortOrder())
left_data = self.sourceModel().data(left, Qt.DisplayRole) left_data = self.sourceModel().data(left, Qt.DisplayRole)
right_data = self.sourceModel().data(right, Qt.DisplayRole) right_data = self.sourceModel().data(right, Qt.DisplayRole)
return (left_data < right_data) return (left_data < right_data)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment