diff --git a/res/ui/currency_tab.ui b/res/ui/currency_tab.ui index f0381cc05f53774ffb63b1fd3c51f041942e0245..04a102931088059edd6af03e488a454786d270fa 100644 --- a/res/ui/currency_tab.ui +++ b/res/ui/currency_tab.ui @@ -189,10 +189,27 @@ </hint> </hints> </connection> + <connection> + <sender>table_history</sender> + <signal>customContextMenuRequested(QPoint)</signal> + <receiver>CurrencyTabWidget</receiver> + <slot>history_context_menu(QPoint)</slot> + <hints> + <hint type="sourcelabel"> + <x>199</x> + <y>180</y> + </hint> + <hint type="destinationlabel"> + <x>199</x> + <y>149</y> + </hint> + </hints> + </connection> </connections> <slots> <slot>refresh_wallet_content(QModelIndex)</slot> <slot>wallet_context_menu(QPoint)</slot> <slot>dates_changed(QDateTime)</slot> + <slot>history_context_menu(QPoint)</slot> </slots> </ui> diff --git a/src/cutecoin/gui/currency_tab.py b/src/cutecoin/gui/currency_tab.py index 56b7feece34ad73bbad44404800e95010be00e92..d26eb081deefc14c478a2ba7803a11733872fe16 100644 --- a/src/cutecoin/gui/currency_tab.py +++ b/src/cutecoin/gui/currency_tab.py @@ -178,7 +178,7 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget): def wallet_context_menu(self, point): index = self.list_wallets.indexAt(point) model = self.list_wallets.model() - if index.row() < model.rowCount(None): + if index.row() < model.rowCount(QModelIndex()): wallet = model.wallets[index.row()] menu = QMenu(model.data(index, Qt.DisplayRole), self) @@ -198,17 +198,19 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget): def history_context_menu(self, point): index = self.table_history.indexAt(point) model = self.table_history.model() - if index.row() < model.rowCount(None): - wallet = model.wallets[index.row()] - menu = QMenu(model.data(index, Qt.DisplayRole), self) + if index.row() < model.rowCount(QModelIndex()): + if index.column() == model.sourceModel().columns.index('UID/Public key'): + source_index = model.mapToSource(index) + person = model.sourceModel().data(source_index, Qt.DisplayRole) + menu = QMenu(model.data(index, Qt.DisplayRole), self) - copy_pubkey = QAction("Copy pubkey to clipboard", self) - copy_pubkey.triggered.connect(self.copy_pubkey_to_clipboard) - copy_pubkey.setData(wallet) + copy_pubkey = QAction("Copy pubkey to clipboard", self) + copy_pubkey.triggered.connect(self.copy_pubkey_to_clipboard) + copy_pubkey.setData(person) menu.addAction(copy_pubkey) # Show the context menu. - menu.exec_(self.list_wallets.mapToGlobal(point)) + menu.exec_(self.table_history.mapToGlobal(point)) def rename_wallet(self): index = self.sender().data() @@ -221,6 +223,8 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget): clipboard.setText(data.pubkey) elif data.__class__ is Person: clipboard.setText(data.pubkey) + elif data.__class__ is str: + clipboard.setText(data) def wallet_changed(self): self.app.save(self.app.current_account) diff --git a/src/cutecoin/models/txhistory.py b/src/cutecoin/models/txhistory.py index fb98e82eebb5851a02d135659f9c8be7dfaa20f8..23454beff53824396d3cee5df60f9688ff472cc2 100644 --- a/src/cutecoin/models/txhistory.py +++ b/src/cutecoin/models/txhistory.py @@ -42,6 +42,19 @@ class TxFilterProxyModel(QSortFilterProxyModel): right_data = self.sourceModel().data(right, Qt.DisplayRole) return (left_data < right_data) + def data(self, index, role): + source_index = self.mapToSource(index) + source_data = self.sourceModel().data(source_index, role) + if role == Qt.DisplayRole: + if source_index.column() == self.sourceModel().columns.index('UID/Public key'): + if source_data.__class__ == Person: + tx_person = source_data.name + else: + tx_person = "pub:{0}".format(source_data[:5]) + source_data = tx_person + return source_data + return source_data + class HistoryTableModel(QAbstractTableModel): @@ -82,9 +95,11 @@ class HistoryTableModel(QAbstractTableModel): comment = tx[1].comment pubkey = tx[1].issuers[0] try: - sender = Person.lookup(pubkey, self.community).name + #sender = Person.lookup(pubkey, self.community).name + sender = Person.lookup(pubkey, self.community) except PersonNotFoundError: - sender = "pub:{0}".format(pubkey[:5]) + #sender = "pub:{0}".format(pubkey[:5]) + sender = pubkey date_ts = self.community.get_block(tx[0]).time date = QDateTime.fromTime_t(date_ts) @@ -107,9 +122,11 @@ class HistoryTableModel(QAbstractTableModel): comment = tx[1].comment pubkey = outputs[0].pubkey try: - receiver = Person.lookup(pubkey, self.community).name + #receiver = Person.lookup(pubkey, self.community).name + receiver = Person.lookup(pubkey, self.community) except PersonNotFoundError: - receiver = "pub:{0}".format(pubkey[:5]) + #receiver = "pub:{0}".format(pubkey[:5]) + receiver = pubkey date_ts = self.community.get_block(tx[0]).time date = QDateTime.fromTime_t(date_ts)