From 798434ed4cba4cf8545f021502e2324da0cc0fb8 Mon Sep 17 00:00:00 2001 From: Inso <insomniak.fr@gmail.com> Date: Fri, 30 Jan 2015 07:59:48 +0100 Subject: [PATCH] Feature for a bank account view : done --- src/cutecoin/core/account.py | 5 +++++ src/cutecoin/gui/currency_tab.py | 6 ++++++ src/cutecoin/gui/mainwindow.py | 2 +- src/cutecoin/models/txhistory.py | 4 ++-- src/cutecoin/models/wallet.py | 4 ++-- src/cutecoin/models/wallets.py | 7 ++++++- 6 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/cutecoin/core/account.py b/src/cutecoin/core/account.py index 5d27613c..314428cd 100644 --- a/src/cutecoin/core/account.py +++ b/src/cutecoin/core/account.py @@ -106,6 +106,7 @@ class Account(object): def set_display_referential(self, index): self.referential = index + @property def units_to_ref(self): def units(units, community): return units @@ -131,6 +132,10 @@ class Account(object): referentials = [units, relative, units_to_zero, relative_to_zero] return referentials[self.referential] + def ref_name(self, currency): + referentials = ['{0}', 'UD {0}', '{0} -> 0', 'UD {0} -> 0'] + return referentials[self.referential].format(currency) + def set_walletpool_size(self, size, password): logging.debug("Defining wallet pool size") if len(self.wallets) < size: diff --git a/src/cutecoin/gui/currency_tab.py b/src/cutecoin/gui/currency_tab.py index 0a1e1516..99b304c6 100644 --- a/src/cutecoin/gui/currency_tab.py +++ b/src/cutecoin/gui/currency_tab.py @@ -228,3 +228,9 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget): QModelIndex(), QModelIndex(), []) + + if self.list_wallets.model(): + self.list_wallets.model().dataChanged.emit( + QModelIndex(), + QModelIndex(), + []) diff --git a/src/cutecoin/gui/mainwindow.py b/src/cutecoin/gui/mainwindow.py index c667e433..1e2bba81 100644 --- a/src/cutecoin/gui/mainwindow.py +++ b/src/cutecoin/gui/mainwindow.py @@ -123,7 +123,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): dialog.accepted.connect(self.refresh_wallets) dialog.exec_() currency_tab = self.currencies_tabwidget.currentWidget() - currency_tab.list_transactions_sent.model().dataChanged.emit( + currency_tab.table_history.model().dataChanged.emit( QModelIndex(), QModelIndex(), ()) diff --git a/src/cutecoin/models/txhistory.py b/src/cutecoin/models/txhistory.py index e040966f..41a38287 100644 --- a/src/cutecoin/models/txhistory.py +++ b/src/cutecoin/models/txhistory.py @@ -89,7 +89,7 @@ class HistoryTableModel(QAbstractTableModel): date_ts = self.community.get_block(tx[0]).mediantime date = QDateTime.fromTime_t(date_ts) - amount_ref = self.account.units_to_ref()(amount, self.community) + amount_ref = self.account.units_to_ref(amount, self.community) return (date.date(), sender, "", "{0}".format(amount_ref), comment) @@ -111,7 +111,7 @@ class HistoryTableModel(QAbstractTableModel): date_ts = self.community.get_block(tx[0]).mediantime date = QDateTime.fromTime_t(date_ts) - amount_ref = self.account.units_to_ref()(-amount, self.community) + amount_ref = self.account.units_to_ref(-amount, self.community) return (date.date(), receiver, "{0}".format(amount_ref), "", comment) diff --git a/src/cutecoin/models/wallet.py b/src/cutecoin/models/wallet.py index df17811b..8c67ae6a 100644 --- a/src/cutecoin/models/wallet.py +++ b/src/cutecoin/models/wallet.py @@ -26,8 +26,8 @@ class WalletListModel(QAbstractListModel): def data(self, index, role): if role == Qt.DisplayRole: row = index.row() - value = "{0}".format(self.sources[row].amount) - return value + amount = self.sources[row].amount + return amount def flags(self, index): return Qt.ItemIsSelectable | Qt.ItemIsEnabled diff --git a/src/cutecoin/models/wallets.py b/src/cutecoin/models/wallets.py index 745d62f9..10b462f0 100644 --- a/src/cutecoin/models/wallets.py +++ b/src/cutecoin/models/wallets.py @@ -19,6 +19,7 @@ class WalletsListModel(QAbstractListModel): Constructor ''' super(WalletsListModel, self).__init__(parent) + self.account = account self.wallets = account.wallets self.community = community @@ -29,7 +30,11 @@ class WalletsListModel(QAbstractListModel): row = index.row() w = self.wallets[row] if role == Qt.DisplayRole: - return w.get_text(self.community) + amount = w.value(self.community) + ref_amount = self.account.units_to_ref(amount, self.community) + ref_name = self.account.ref_name(self.community.currency) + return """{0} +{1} {2}""".format(w.name, ref_amount, ref_name) elif role == Qt.EditRole: return self.wallets[row].name -- GitLab