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

Quantitative and relative display

parent 01965574
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>400</width>
<height>489</height>
<height>486</height>
</rect>
</property>
<property name="windowTitle">
......@@ -69,13 +69,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_get_trusts">
<property name="text">
<string>Get trusts nodes</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
......@@ -103,7 +96,14 @@
</widget>
</item>
<item>
<widget class="QComboBox" name="combo_wallets"/>
<widget class="QComboBox" name="combo_wallets">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
......@@ -199,7 +199,7 @@
<item>
<widget class="QLabel" name="label_total">
<property name="text">
<string>Total money transfered : 0 </string>
<string/>
</property>
</widget>
</item>
......
......@@ -86,7 +86,6 @@ class StepPageCommunities(Step):
account = self.config_dialog.account
self.config_dialog.community = account.communities.add_community(
default_node)
#TODO: Get existing Wallet from ucoin node
account.wallets.add_wallet(account.keyid,
self.config_dialog.community)
self.config_dialog.refresh()
......
......@@ -60,7 +60,6 @@ class StepPageAddNodes(Step):
def __init__(self, config_dialog):
super().__init__(config_dialog)
#TODO: Check page validity
def is_valid(self):
return True
......@@ -88,7 +87,6 @@ class StepPageSetWallets(Step):
def __init__(self, config_dialog):
super().__init__(config_dialog)
#TODO: Check page validity
def is_valid(self):
return True
......@@ -221,7 +219,6 @@ class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog):
QMessageBox.critical(self, "Pubkey publishing error",
result)
#TODO: Push wht only if changed
for wallet in self.account.wallets:
if self.wallet_edit[wallet.name]:
result = wallet.push_wht(self.account.gpg)
......
......@@ -52,7 +52,6 @@ class StepPageKey(Step):
def __init__(self, config_dialog):
super().__init__(config_dialog)
#TODO: Check page validity
def is_valid(self):
return self.config_dialog.keyid != ''
......@@ -70,7 +69,6 @@ class StepPageNode(Step):
def __init__(self, config_dialog):
super().__init__(config_dialog)
#TODO: Check page validity
def is_valid(self):
address = self.config_dialog.edit_address.text()
port = self.config_dialog.spinbox_port.value()
......
......@@ -42,16 +42,22 @@ class TransferMoneyDialog(QDialog, Ui_TransferMoneyDialog):
for select in selection:
coins = self.list_coins_sent.model().remove_coins(select, 1)
self.list_wallet.model().add_coins(coins)
self.label_total.setText("Total : %d" %
self.list_coins_sent.model().total())
self.refresh_total()
def add_coins_to_transfer(self):
selection = self.list_wallet.selectedIndexes()
for select in selection:
coins = self.list_wallet.model().remove_coins(select, 1)
self.list_coins_sent.model().add_coins(coins)
self.label_total.setText("Total : %d"
% self.list_coins_sent.model().total())
self.refresh_total()
def refresh_total(self):
dividend = self.wallet.get_amendment(None)['dividend']
total = self.list_coins_sent.model().total()
relative_total = total / int(dividend)
self.label_total.setText("Total : \n \
%d %s \n \
%.2f UD" % (total, self.wallet.currency, relative_total))
def accept(self):
sent_coins = self.list_coins_sent.model().to_list()
......@@ -64,7 +70,6 @@ class TransferMoneyDialog(QDialog, Ui_TransferMoneyDialog):
self.combo_contact.currentIndex()]
message = self.edit_message.text()
# TODO: All nodes trusted by recipient
error = self.wallet.transfer_coins(recipient, sent_coins, message)
if error:
QErrorMessage(self).showMessage("Cannot transfer coins " + error)
......
......@@ -38,7 +38,7 @@ class Coin(object):
def value(self, wallet):
amendment = wallet.get_amendment(self.am_number)
if 'CoinAlgo' in amendment:
coin_algo_name = self.amendment['CoinAlgo']
coin_algo_name = amendment['CoinAlgo']
else:
coin_algo_name = 'Base2Draft'
......
......@@ -11,6 +11,7 @@ import json
import time
import hashlib
import importlib
from decimal import Decimal
from cutecoin.models.coin import Coin
from cutecoin.models.coin import algorithms
from cutecoin.models.node import Node
......@@ -60,7 +61,12 @@ class Wallet(object):
def __eq__(self, other):
return (self.keyid == other.keyid)
#TODO: Relative and quantitative value
def relative_value(self):
value = self.value()
amendment = self.get_amendment(None)
relative_value = value / float(amendment['dividend'])
return relative_value
def value(self):
value = 0
for coin in self.coins:
......@@ -295,7 +301,8 @@ Hosters:
else:
amendment_req = ucoin.hdc.amendments.Promoted(am_number)
new_am = self.request(amendment_req)
self.amendments_cache[am_number] = new_am
number = int(new_am['number'])
self.amendments_cache[number] = new_am
return new_am
def fingerprint(self, gpg):
......@@ -308,8 +315,10 @@ Hosters:
return ""
def get_text(self):
return self.name + " : " + \
str(self.value()) + " " + self.currency
return "%s : \n \
%d %s \n \
%.2f UD" % (self.name, self.value(), self.currency,
self.relative_value())
def jsonify_coins_list(self):
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