@@ -43,18 +43,21 @@ ReceiveCoinsDialog::ReceiveCoinsDialog(const PlatformStyle *platformStyle, QWidg
4343 }
4444
4545 // context menu actions
46+ QAction *copyURIAction = new QAction (tr (" Copy URI" ), this );
4647 QAction *copyLabelAction = new QAction (tr (" Copy label" ), this );
4748 QAction *copyMessageAction = new QAction (tr (" Copy message" ), this );
4849 QAction *copyAmountAction = new QAction (tr (" Copy amount" ), this );
4950
5051 // context menu
5152 contextMenu = new QMenu ();
53+ contextMenu->addAction (copyURIAction);
5254 contextMenu->addAction (copyLabelAction);
5355 contextMenu->addAction (copyMessageAction);
5456 contextMenu->addAction (copyAmountAction);
5557
5658 // context menu signals
5759 connect (ui->recentRequestsView , SIGNAL (customContextMenuRequested (QPoint)), this , SLOT (showMenu (QPoint)));
60+ connect (copyURIAction, SIGNAL (triggered ()), this , SLOT (copyURI ()));
5861 connect (copyLabelAction, SIGNAL (triggered ()), this , SLOT (copyLabel ()));
5962 connect (copyMessageAction, SIGNAL (triggered ()), this , SLOT (copyMessage ()));
6063 connect (copyAmountAction, SIGNAL (triggered ()), this , SLOT (copyAmount ()));
@@ -227,30 +230,50 @@ void ReceiveCoinsDialog::keyPressEvent(QKeyEvent *event)
227230 this ->QDialog ::keyPressEvent (event);
228231}
229232
230- // copy column of selected row to clipboard
231- void ReceiveCoinsDialog::copyColumnToClipboard (int column)
233+ QModelIndex ReceiveCoinsDialog::selectedRow ()
232234{
233235 if (!model || !model->getRecentRequestsTableModel () || !ui->recentRequestsView ->selectionModel ())
234- return ;
236+ return QModelIndex () ;
235237 QModelIndexList selection = ui->recentRequestsView ->selectionModel ()->selectedRows ();
236238 if (selection.empty ())
237- return ;
239+ return QModelIndex () ;
238240 // correct for selection mode ContiguousSelection
239241 QModelIndex firstIndex = selection.at (0 );
242+ return firstIndex;
243+ }
244+
245+ // copy column of selected row to clipboard
246+ void ReceiveCoinsDialog::copyColumnToClipboard (int column)
247+ {
248+ QModelIndex firstIndex = selectedRow ();
249+ if (!firstIndex.isValid ()) {
250+ return ;
251+ }
240252 GUIUtil::setClipboard (model->getRecentRequestsTableModel ()->data (firstIndex.child (firstIndex.row (), column), Qt::EditRole).toString ());
241253}
242254
243255// context menu
244256void ReceiveCoinsDialog::showMenu (const QPoint &point)
245257{
246- if (!model || !model->getRecentRequestsTableModel () || !ui->recentRequestsView ->selectionModel ())
247- return ;
248- QModelIndexList selection = ui->recentRequestsView ->selectionModel ()->selectedRows ();
249- if (selection.empty ())
258+ if (!selectedRow ().isValid ()) {
250259 return ;
260+ }
251261 contextMenu->exec (QCursor::pos ());
252262}
253263
264+ // context menu action: copy URI
265+ void ReceiveCoinsDialog::copyURI ()
266+ {
267+ QModelIndex sel = selectedRow ();
268+ if (!sel.isValid ()) {
269+ return ;
270+ }
271+
272+ const RecentRequestsTableModel * const submodel = model->getRecentRequestsTableModel ();
273+ const QString uri = GUIUtil::formatBitcoinURI (submodel->entry (sel.row ()).recipient );
274+ GUIUtil::setClipboard (uri);
275+ }
276+
254277// context menu action: copy label
255278void ReceiveCoinsDialog::copyLabel ()
256279{
0 commit comments