Skip to content

Commit

Permalink
QT: Add 'copy full transaction details' option
Browse files Browse the repository at this point in the history
Adds feature from issue bitcoin#7484

modifies the ctrl-c binding to copy full transaction details in transaction view.

Added translation
  • Loading branch information
Eric Shaw committed Mar 8, 2016
1 parent e5121eb commit b51ed40
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
28 changes: 28 additions & 0 deletions src/qt/transactiontablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,34 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
return QString::fromStdString(rec->hash.ToString());
case TxHexRole:
return priv->getTxHex(rec);
case TxPlainTextRole:
{
QString details;
QDateTime date = QDateTime::fromTime_t(static_cast<uint>(rec->time));
QString txLabel = walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(rec->address));

details.append(date.toString("M/d/yy HH:mm"));
details.append(" ");
details.append(formatTxStatus(rec));
details.append(". ");
if(!formatTxType(rec).isEmpty()) {
details.append(formatTxType(rec));
details.append(" ");
}
if(!rec->address.empty()) {
if(txLabel.isEmpty())
details.append(tr("(no label)") + " ");
else {
details.append("(");
details.append(txLabel);
details.append(") ");
}
details.append(QString::fromStdString(rec->address));
details.append(" ");
}
details.append(formatTxAmount(rec, false, BitcoinUnits::separatorNever));
return details;
}
case ConfirmedRole:
return rec->status.countsForBalance;
case FormattedAmountRole:
Expand Down
2 changes: 2 additions & 0 deletions src/qt/transactiontablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class TransactionTableModel : public QAbstractTableModel
TxHashRole,
/** Transaction data, hex-encoded */
TxHexRole,
/** Whole transaction as plain text */
TxPlainTextRole,
/** Is transaction confirmed? */
ConfirmedRole,
/** Formatted amount, without brackets when unconfirmed */
Expand Down
16 changes: 10 additions & 6 deletions src/qt/transactionview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
QAction *copyAmountAction = new QAction(tr("Copy amount"), this);
QAction *copyTxIDAction = new QAction(tr("Copy transaction ID"), this);
QAction *copyTxHexAction = new QAction(tr("Copy raw transaction"), this);
QAction *copyTxPlainText = new QAction(tr("Copy full transaction details"), this);
QAction *editLabelAction = new QAction(tr("Edit label"), this);
QAction *showDetailsAction = new QAction(tr("Show transaction details"), this);

Expand All @@ -151,6 +152,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
contextMenu->addAction(copyAmountAction);
contextMenu->addAction(copyTxIDAction);
contextMenu->addAction(copyTxHexAction);
contextMenu->addAction(copyTxPlainText);
contextMenu->addAction(editLabelAction);
contextMenu->addAction(showDetailsAction);

Expand All @@ -173,6 +175,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount()));
connect(copyTxIDAction, SIGNAL(triggered()), this, SLOT(copyTxID()));
connect(copyTxHexAction, SIGNAL(triggered()), this, SLOT(copyTxHex()));
connect(copyTxPlainText, SIGNAL(triggered()), this, SLOT(copyTxPlainText()));
connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel()));
connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails()));
}
Expand Down Expand Up @@ -388,6 +391,11 @@ void TransactionView::copyTxHex()
GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::TxHexRole);
}

void TransactionView::copyTxPlainText()
{
GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::TxPlainTextRole);
}

void TransactionView::editLabel()
{
if(!transactionView->selectionModel() ||!model)
Expand Down Expand Up @@ -526,12 +534,8 @@ bool TransactionView::eventFilter(QObject *obj, QEvent *event)
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
if (ke->key() == Qt::Key_C && ke->modifiers().testFlag(Qt::ControlModifier))
{
QModelIndex i = this->transactionView->currentIndex();
if (i.isValid() && i.column() == TransactionTableModel::Amount)
{
GUIUtil::setClipboard(i.data(TransactionTableModel::FormattedAmountRole).toString());
return true;
}
GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::TxPlainTextRole);
return true;
}
}
return QWidget::eventFilter(obj, event);
Expand Down
1 change: 1 addition & 0 deletions src/qt/transactionview.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ private Q_SLOTS:
void copyAmount();
void copyTxID();
void copyTxHex();
void copyTxPlainText();
void openThirdPartyTxUrl(QString url);
void updateWatchOnlyColumn(bool fHaveWatchOnly);

Expand Down

0 comments on commit b51ed40

Please sign in to comment.