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

Context menu for history table added

parent 0193eba6
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......@@ -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)
......
......@@ -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)
......
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