aboutsummaryrefslogtreecommitdiff
path: root/src/qt/transactionview.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2011-12-04 14:14:10 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2011-12-23 12:07:23 +0100
commitc58e7d4e013f21e38fb1501d896d32e8407a9c3c (patch)
tree8e24786b335c0316bb9929864407b9fa7303c98a /src/qt/transactionview.cpp
parentc4a4a4b886b3bd8933cf96c0d66d647a2b32a68b (diff)
Copy amount to clipboard (implements #657)
- Also, unify similar code related to copying transaction fields to clipboard
Diffstat (limited to 'src/qt/transactionview.cpp')
-rw-r--r--src/qt/transactionview.cpp31
1 files changed, 12 insertions, 19 deletions
diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp
index 0e1b22e01b..cba06298d4 100644
--- a/src/qt/transactionview.cpp
+++ b/src/qt/transactionview.cpp
@@ -10,6 +10,7 @@
#include "transactiondescdialog.h"
#include "editaddressdialog.h"
#include "optionsmodel.h"
+#include "guiutil.h"
#include <QScrollBar>
#include <QComboBox>
@@ -123,12 +124,14 @@ TransactionView::TransactionView(QWidget *parent) :
// Actions
QAction *copyAddressAction = new QAction(tr("Copy address"), this);
QAction *copyLabelAction = new QAction(tr("Copy label"), this);
+ QAction *copyAmountAction = new QAction(tr("Copy amount"), this);
QAction *editLabelAction = new QAction(tr("Edit label"), this);
QAction *showDetailsAction = new QAction(tr("Show details..."), this);
contextMenu = new QMenu();
contextMenu->addAction(copyAddressAction);
contextMenu->addAction(copyLabelAction);
+ contextMenu->addAction(copyAmountAction);
contextMenu->addAction(editLabelAction);
contextMenu->addAction(showDetailsAction);
@@ -139,14 +142,11 @@ TransactionView::TransactionView(QWidget *parent) :
connect(amountWidget, SIGNAL(textChanged(QString)), this, SLOT(changedAmount(QString)));
connect(view, SIGNAL(doubleClicked(QModelIndex)), this, SIGNAL(doubleClicked(QModelIndex)));
-
- connect(view,
- SIGNAL(customContextMenuRequested(QPoint)),
- this,
- SLOT(contextualMenu(QPoint)));
+ connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint)));
connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(copyAddress()));
connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel()));
+ connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount()));
connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel()));
connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails()));
}
@@ -302,24 +302,17 @@ void TransactionView::contextualMenu(const QPoint &point)
void TransactionView::copyAddress()
{
- if(!transactionView->selectionModel())
- return;
- QModelIndexList selection = transactionView->selectionModel()->selectedRows();
- if(!selection.isEmpty())
- {
- QApplication::clipboard()->setText(selection.at(0).data(TransactionTableModel::AddressRole).toString());
- }
+ GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::AddressRole);
}
void TransactionView::copyLabel()
{
- if(!transactionView->selectionModel())
- return;
- QModelIndexList selection = transactionView->selectionModel()->selectedRows();
- if(!selection.isEmpty())
- {
- QApplication::clipboard()->setText(selection.at(0).data(TransactionTableModel::LabelRole).toString());
- }
+ GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::LabelRole);
+}
+
+void TransactionView::copyAmount()
+{
+ GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::FormattedAmountRole);
}
void TransactionView::editLabel()