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