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

Wallet content now show available sources, while Transactions sent and...

Wallet content now show available sources, while Transactions sent and received will display latest transactions sent and received
parent e403f848
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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):
......
......@@ -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)
......@@ -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):
......
......@@ -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):
......
......@@ -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):
......
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