diff --git a/res/ui/transactions_tab.ui b/res/ui/transactions_tab.ui index 5cd0f97af00db657bf62772918b8c02d236dad2c..a073b1ef5e96e0c5d0ce5ddf9201311368ae149e 100644 --- a/res/ui/transactions_tab.ui +++ b/res/ui/transactions_tab.ui @@ -83,8 +83,41 @@ </hint> </hints> </connection> + <connection> + <sender>date_from</sender> + <signal>dateChanged(QDate)</signal> + <receiver>transactionsTabWidget</receiver> + <slot>dates_changed()</slot> + <hints> + <hint type="sourcelabel"> + <x>102</x> + <y>28</y> + </hint> + <hint type="destinationlabel"> + <x>199</x> + <y>149</y> + </hint> + </hints> + </connection> + <connection> + <sender>date_to</sender> + <signal>dateChanged(QDate)</signal> + <receiver>transactionsTabWidget</receiver> + <slot>dates_changed()</slot> + <hints> + <hint type="sourcelabel"> + <x>297</x> + <y>28</y> + </hint> + <hint type="destinationlabel"> + <x>199</x> + <y>149</y> + </hint> + </hints> + </connection> </connections> <slots> <slot>history_context_menu()</slot> + <slot>dates_changed()</slot> </slots> </ui> diff --git a/src/cutecoin/core/transfer.py b/src/cutecoin/core/transfer.py index ddf144c10fccdd7f9b704cbc8c0c3676dc57dae6..b01a44267d65eac1dfdc34218632f3b8fb986740 100644 --- a/src/cutecoin/core/transfer.py +++ b/src/cutecoin/core/transfer.py @@ -46,6 +46,8 @@ class Transfer(object): assert('issuer' in metadata) assert('amount' in metadata) assert('comment' in metadata) + assert('issuer_uid' in metadata) + assert('receiver_uid' in metadata) self.txdoc = txdoc self.state = state diff --git a/src/cutecoin/core/wallet.py b/src/cutecoin/core/wallet.py index 835e8907eb64e8e43ca24d57b6a6d6f0eba84f4c..3e38f462353e263baee74f46d01cb7c0fe032e77 100644 --- a/src/cutecoin/core/wallet.py +++ b/src/cutecoin/core/wallet.py @@ -10,8 +10,9 @@ from ucoinpy.documents.block import Block from ucoinpy.documents.transaction import InputSource, OutputSource, Transaction from ucoinpy.key import SigningKey -from ..tools.exceptions import NotEnoughMoneyError, NoPeerAvailable +from ..tools.exceptions import NotEnoughMoneyError, NoPeerAvailable, PersonNotFoundError from .transfer import Transfer, Received +from .person import Person from PyQt5.QtCore import QObject, pyqtSignal @@ -64,11 +65,23 @@ class Cache(): receivers = [o.pubkey for o in tx.outputs if o.pubkey != tx.issuers[0]] + try: + issuer_uid = Person.lookup(tx.issuers[0], community).uid + except PersonNotFoundError: + issuer_uid = "" + + try: + receiver_uid = Person.lookup(receivers[0], community).uid + except PersonNotFoundError: + receiver_uid = "" + metadata = {'block': block_number, 'time': mediantime, 'comment': tx.comment, 'issuer': tx.issuers[0], - 'receiver': receivers[0]} + 'issuer_uid': issuer_uid, + 'receiver': receivers[0], + 'receiver_uid': receiver_uid} in_issuers = len([i for i in tx.issuers if i == self.wallet.pubkey]) > 0 @@ -356,6 +369,16 @@ class Wallet(QObject): key = SigningKey("{0}{1}".format(salt, self.walletid), password) logging.debug("Sender pubkey:{0}".format(key.pubkey)) + try: + issuer_uid = Person.lookup(key.pubkey, community).uid + except PersonNotFoundError: + issuer_uid = "" + + try: + receiver_uid = Person.lookup(recipient, community).uid + except PersonNotFoundError: + receiver_uid = "" + metadata = {'block': block_number, 'time': time, 'amount': amount, diff --git a/src/cutecoin/gui/transactions_tab.py b/src/cutecoin/gui/transactions_tab.py index f367d562dc4d3504d31d00da9f1ca456850d22c7..cdae8748dc9473b2373dfc47eeb39076ed795272 100644 --- a/src/cutecoin/gui/transactions_tab.py +++ b/src/cutecoin/gui/transactions_tab.py @@ -9,6 +9,7 @@ from ..core.wallet import Wallet from ..core.person import Person from .transfer import TransferMoneyDialog +import logging class TransactionsTabWidget(QWidget, Ui_transactionsTabWidget): """ @@ -125,3 +126,13 @@ QMessageBox.Ok | QMessageBox.Cancel) transfer = self.sender().data() transfer.drop() self.table_history.model().invalidate() + + def dates_changed(self): + logging.debug("Changed dates") + if self.table_history.model(): + ts_from = self.date_from.dateTime().toTime_t() + ts_to = self.date_to.dateTime().toTime_t() + + self.table_history.model().set_period(ts_from, ts_to) + + diff --git a/src/cutecoin/gui/wallets_tab.py b/src/cutecoin/gui/wallets_tab.py index 1274bb5fa99c5558f7e618fae2babb8e584a9bbb..44f4c1191df47e09a5e8acfd8f637f09c2ffa141 100644 --- a/src/cutecoin/gui/wallets_tab.py +++ b/src/cutecoin/gui/wallets_tab.py @@ -98,7 +98,8 @@ class WalletsTabWidget(QWidget, Ui_WalletsTab): <tr><td align="right"><b>{:}</b></td><td>{:}</td></tr> <tr><td align="right"><b>{:}</b></td><td>{:}</td></tr> </table> - """.format("Your money share : ", "{:.2f}%".format(amount/maximum*100), + """.format("Your money share : ", + "{:.2f}%".format(amount/maximum*100) if maximum != 0 else "0%", "Your part : ", "{:.2f} {:} in [{:.2f} - {:.2f}] {:}" .format(self.get_referential_value(amount), self.get_referential_name(), diff --git a/src/cutecoin/models/txhistory.py b/src/cutecoin/models/txhistory.py index 0ac70eb9cff21bc29d2edf6a5604a1025e0cc5f9..925f34ab9251a6e569b0c764a2d4bc22520e8b30 100644 --- a/src/cutecoin/models/txhistory.py +++ b/src/cutecoin/models/txhistory.py @@ -28,6 +28,7 @@ class TxFilterProxyModel(QSortFilterProxyModel): logging.debug("Filtering from {0} to {1}".format(ts_from, ts_to)) self.ts_from = ts_from self.ts_to = ts_to + self.modelReset.emit() def filterAcceptsRow(self, sourceRow, sourceParent): def in_period(date_ts): @@ -55,10 +56,6 @@ class TxFilterProxyModel(QSortFilterProxyModel): return self.sortOrder() == Qt.DescendingOrder elif right_data == "": return self.sortOrder() == Qt.AscendingOrder - if left_data.__class__ is Person: - left_data = left_data.uid - if right_data.__class__ is Person: - right_data = right_data.uid return (left_data < right_data) @@ -70,11 +67,6 @@ class TxFilterProxyModel(QSortFilterProxyModel): state_data = self.sourceModel().data(state_index, Qt.DisplayRole) if role == Qt.DisplayRole: if source_index.column() == self.sourceModel().column_types.index('uid'): - if source_data.__class__ == Person: - tx_person = source_data.uid - else: - tx_person = "pub:{0}".format(source_data[:5]) - source_data = tx_person return source_data if source_index.column() == self.sourceModel().column_types.index('date'): date = QDateTime.fromTime_t(source_data) @@ -176,11 +168,10 @@ class HistoryTableModel(QAbstractTableModel): comment = "" if transfer.txdoc: comment = transfer.txdoc.comment - pubkey = transfer.metadata['issuer'] - try: - sender = Person.lookup(pubkey, self.community) - except PersonNotFoundError: - sender = pubkey + if transfer.metadata['issuer_uid'] != "": + sender = transfer.metadata['issuer_uid'] + else: + sender = "pub:{0}".format(transfer.metadata['issuer'][:5]) date_ts = transfer.metadata['time'] @@ -192,12 +183,12 @@ class HistoryTableModel(QAbstractTableModel): comment = "" if transfer.txdoc: comment = transfer.txdoc.comment - pubkey = transfer.metadata['receiver'] - try: - receiver = Person.lookup(pubkey, self.community) - except PersonNotFoundError: - #receiver = "pub:{0}".format(pubkey[:5]) - receiver = pubkey + + if transfer.metadata['receiver_uid'] != "": + receiver = transfer.metadata['receiver_uid'] + else: + receiver = "pub:{0}".format(transfer.metadata['receiver'][:5]) + date_ts = transfer.metadata['time']