diff --git a/src/cutecoin/core/account.py b/src/cutecoin/core/account.py index 60204357150815b4e1d6662e2552341431a30175..fdbd26648bdd4b69192168b7c10a337df6c63c7c 100644 --- a/src/cutecoin/core/account.py +++ b/src/cutecoin/core/account.py @@ -99,20 +99,24 @@ class Account(object): wid = w.walletid + 1 return wid - def sources(self): - #TODO: Change the way things are displayed - # Listing sources from all communities is stupid + def sources(self, community): + sources = [] + for w in self.wallets: + for s in w.sources(community): + sources.append(s) + return sources + + def transactions_received(self, community): received = [] - for c in self.communities: - for w in self.wallets: - for s in w.sources(c): - received.append(s) + for w in self.wallets: + for t in w.transactions_received(community): + received.append(t) return received - def transactions_sent(self): + def transactions_sent(self, community): sent = [] for w in self.wallets: - for t in w.transactions_sent(): + for t in w.transactions_sent(community): sent.append(t) return sent diff --git a/src/cutecoin/core/wallet.py b/src/cutecoin/core/wallet.py index 605200b4db8acf3a1e85aa3eb00a4fc36e3ec51b..0254e61bc5ca0b41adfc2c3a08ab5f1789a81b82 100644 --- a/src/cutecoin/core/wallet.py +++ b/src/cutecoin/core/wallet.py @@ -132,7 +132,11 @@ class Wallet(object): return tx #TODO: Build a cache of latest transactions - def transactions_sent(self): + def transactions_sent(self, community): + return [] + + #TODO: Build a cache of latest transactions + def transactions_received(self, community): return [] def get_text(self, community): diff --git a/src/cutecoin/gui/currency_tab.py b/src/cutecoin/gui/currency_tab.py index fd5dc37be11f42d3e7d5c45dc226e554cb0a339c..04716b1d2ab0a68e1c8aac76e5bff91d663450b5 100644 --- a/src/cutecoin/gui/currency_tab.py +++ b/src/cutecoin/gui/currency_tab.py @@ -12,6 +12,7 @@ from cutecoin.gui.community_tab import CommunityTabWidget from cutecoin.models.sent import SentListModel from cutecoin.models.received import ReceivedListModel from cutecoin.models.wallets import WalletsListModel +from ..models.wallet import WalletListModel class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget): @@ -37,11 +38,9 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget): self.refresh_wallets() self.list_transactions_sent.setModel( - SentListModel( - self.app.current_account)) + SentListModel(self.app.current_account, self.community)) self.list_transactions_received.setModel( - ReceivedListModel( - self.app.current_account)) + ReceivedListModel(self.app.current_account, self.community)) tab_community = CommunityTabWidget(self.app.current_account, self.community) self.tabs_account.addTab(tab_community, "Community") @@ -52,4 +51,6 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget): self.refresh_wallet_content(QModelIndex()) def refresh_wallet_content(self, index): - pass + current_wallet = self.app.current_account.wallets[index.row()] + wallet_list_model = WalletListModel(current_wallet, self.community) + self.list_wallet_content.setModel(wallet_list_model) diff --git a/src/cutecoin/models/received.py b/src/cutecoin/models/received.py index cb009b0232005dce8571cbaffe6c57260fb1d488..bb57984d90d5c9ff150c879079c430238878949b 100644 --- a/src/cutecoin/models/received.py +++ b/src/cutecoin/models/received.py @@ -14,20 +14,22 @@ class ReceivedListModel(QAbstractListModel): A Qt abstract item model to display communities in a tree ''' - def __init__(self, account, parent=None): + def __init__(self, account, community, parent=None): ''' Constructor ''' super(ReceivedListModel, self).__init__(parent) - self.sources = account.sources() + self.account = account + self.community = community def rowCount(self, parent): - return len(self.sources) + return len(self.account.transactions_received(self.community)) def data(self, index, role): if role == Qt.DisplayRole: row = index.row() - value = "{0}".format(self.sources[row].amount) + transactions = self.account.transactions_received(self.community) + value = transactions[row].get_receiver_text() return value def flags(self, index): diff --git a/src/cutecoin/models/sent.py b/src/cutecoin/models/sent.py index 3228554931c83cf79e36e9347c041c9268a161f7..0bbbfeea5f3c00075f2d26d5f26f38168c626335 100644 --- a/src/cutecoin/models/sent.py +++ b/src/cutecoin/models/sent.py @@ -14,21 +14,23 @@ class SentListModel(QAbstractListModel): A Qt abstract item model to display communities in a tree ''' - def __init__(self, account, parent=None): + def __init__(self, account, community, parent=None): ''' Constructor ''' super(SentListModel, self).__init__(parent) - self.transactions = account.transactions_sent() + self.account = account + self.community = community def rowCount(self, parent): - return len(self.transactions) + return len(self.account.transactions_sent(self.community)) def data(self, index, role): if role == Qt.DisplayRole: row = index.row() - value = self.transactions[row].get_sender_text() + transactions = self.account.transactions_sent(self.community) + value = transactions[row].get_sender_text() return value def flags(self, index): diff --git a/src/cutecoin/models/wallet.py b/src/cutecoin/models/wallet.py index f311a26444be8f18b4c80feb5c52a6500bd756db..df17811b29b808d607d4d18a5aa7ef24d0570c11 100644 --- a/src/cutecoin/models/wallet.py +++ b/src/cutecoin/models/wallet.py @@ -13,21 +13,20 @@ class WalletListModel(QAbstractListModel): A Qt abstract item model to display communities in a tree ''' - def __init__(self, wallet, parent=None): + def __init__(self, wallet, community, parent=None): ''' Constructor ''' super(WalletListModel, self).__init__(parent) - self.coins = list(wallet.coins) - self.wallet = wallet + self.sources = wallet.sources(community) def rowCount(self, parent): - return len(self.coins) + return len(self.sources) def data(self, index, role): if role == Qt.DisplayRole: row = index.row() - value = str(self.coins[row].value(self.wallet)) + value = "{0}".format(self.sources[row].amount) return value def flags(self, index):