Changeset View
Changeset View
Standalone View
Standalone View
src/qt/transactionview.cpp
Show First 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | #endif | ||||
transactionView = view; | transactionView = view; | ||||
// Actions | // Actions | ||||
abandonAction = new QAction(tr("Abandon transaction"), this); | abandonAction = new QAction(tr("Abandon transaction"), this); | ||||
QAction *copyAddressAction = new QAction(tr("Copy address"), this); | QAction *copyAddressAction = new QAction(tr("Copy address"), this); | ||||
QAction *copyLabelAction = new QAction(tr("Copy label"), this); | QAction *copyLabelAction = new QAction(tr("Copy label"), this); | ||||
QAction *copyAmountAction = new QAction(tr("Copy amount"), this); | QAction *copyAmountAction = new QAction(tr("Copy amount"), this); | ||||
QAction *copyTxIDAction = new QAction(tr("Copy transaction ID"), this); | QAction *copyTxHashAction = new QAction(tr("Copy transaction ID"), this); | ||||
QAction *copyTxHexAction = new QAction(tr("Copy raw transaction"), this); | QAction *copyTxHexAction = new QAction(tr("Copy raw transaction"), this); | ||||
QAction *copyTxPlainText = | QAction *copyTxPlainText = | ||||
new QAction(tr("Copy full transaction details"), this); | new QAction(tr("Copy full transaction details"), this); | ||||
QAction *editLabelAction = new QAction(tr("Edit label"), this); | QAction *editLabelAction = new QAction(tr("Edit label"), this); | ||||
QAction *showDetailsAction = | QAction *showDetailsAction = | ||||
new QAction(tr("Show transaction details"), this); | new QAction(tr("Show transaction details"), this); | ||||
contextMenu = new QMenu(this); | contextMenu = new QMenu(this); | ||||
contextMenu->addAction(copyAddressAction); | contextMenu->addAction(copyAddressAction); | ||||
contextMenu->addAction(copyLabelAction); | contextMenu->addAction(copyLabelAction); | ||||
contextMenu->addAction(copyAmountAction); | contextMenu->addAction(copyAmountAction); | ||||
contextMenu->addAction(copyTxIDAction); | contextMenu->addAction(copyTxHashAction); | ||||
contextMenu->addAction(copyTxHexAction); | contextMenu->addAction(copyTxHexAction); | ||||
contextMenu->addAction(copyTxPlainText); | contextMenu->addAction(copyTxPlainText); | ||||
contextMenu->addAction(showDetailsAction); | contextMenu->addAction(showDetailsAction); | ||||
contextMenu->addSeparator(); | contextMenu->addSeparator(); | ||||
contextMenu->addAction(abandonAction); | contextMenu->addAction(abandonAction); | ||||
contextMenu->addAction(editLabelAction); | contextMenu->addAction(editLabelAction); | ||||
mapperThirdPartyTxUrls = new QSignalMapper(this); | mapperThirdPartyTxUrls = new QSignalMapper(this); | ||||
Show All 15 Lines | connect(view, SIGNAL(doubleClicked(QModelIndex)), this, | ||||
SIGNAL(doubleClicked(QModelIndex))); | SIGNAL(doubleClicked(QModelIndex))); | ||||
connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, | connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, | ||||
SLOT(contextualMenu(QPoint))); | SLOT(contextualMenu(QPoint))); | ||||
connect(abandonAction, SIGNAL(triggered()), this, SLOT(abandonTx())); | connect(abandonAction, SIGNAL(triggered()), this, SLOT(abandonTx())); | ||||
connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(copyAddress())); | connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(copyAddress())); | ||||
connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel())); | connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel())); | ||||
connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount())); | connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount())); | ||||
connect(copyTxIDAction, SIGNAL(triggered()), this, SLOT(copyTxID())); | connect(copyTxHashAction, SIGNAL(triggered()), this, SLOT(copyTxHash())); | ||||
connect(copyTxHexAction, SIGNAL(triggered()), this, SLOT(copyTxHex())); | connect(copyTxHexAction, SIGNAL(triggered()), this, SLOT(copyTxHex())); | ||||
connect(copyTxPlainText, SIGNAL(triggered()), this, | connect(copyTxPlainText, SIGNAL(triggered()), this, | ||||
SLOT(copyTxPlainText())); | SLOT(copyTxPlainText())); | ||||
connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel())); | connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel())); | ||||
connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails())); | connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails())); | ||||
} | } | ||||
void TransactionView::setModel(WalletModel *_model) { | void TransactionView::setModel(WalletModel *_model) { | ||||
▲ Show 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | if (model && model->haveWatchOnly()) | ||||
writer.addColumn(tr("Watch-only"), TransactionTableModel::Watchonly); | writer.addColumn(tr("Watch-only"), TransactionTableModel::Watchonly); | ||||
writer.addColumn(tr("Date"), 0, TransactionTableModel::DateRole); | writer.addColumn(tr("Date"), 0, TransactionTableModel::DateRole); | ||||
writer.addColumn(tr("Type"), TransactionTableModel::Type, Qt::EditRole); | writer.addColumn(tr("Type"), TransactionTableModel::Type, Qt::EditRole); | ||||
writer.addColumn(tr("Label"), 0, TransactionTableModel::LabelRole); | writer.addColumn(tr("Label"), 0, TransactionTableModel::LabelRole); | ||||
writer.addColumn(tr("Address"), 0, TransactionTableModel::AddressRole); | writer.addColumn(tr("Address"), 0, TransactionTableModel::AddressRole); | ||||
writer.addColumn(BitcoinUnits::getAmountColumnTitle( | writer.addColumn(BitcoinUnits::getAmountColumnTitle( | ||||
model->getOptionsModel()->getDisplayUnit()), | model->getOptionsModel()->getDisplayUnit()), | ||||
0, TransactionTableModel::FormattedAmountRole); | 0, TransactionTableModel::FormattedAmountRole); | ||||
writer.addColumn(tr("ID"), 0, TransactionTableModel::TxIDRole); | writer.addColumn(tr("ID"), 0, TransactionTableModel::TxHashRole); | ||||
if (!writer.write()) { | if (!writer.write()) { | ||||
Q_EMIT message(tr("Exporting Failed"), | Q_EMIT message(tr("Exporting Failed"), | ||||
tr("There was an error trying to save the transaction " | tr("There was an error trying to save the transaction " | ||||
"history to %1.") | "history to %1.") | ||||
.arg(filename), | .arg(filename), | ||||
CClientUIInterface::MSG_ERROR); | CClientUIInterface::MSG_ERROR); | ||||
} else { | } else { | ||||
Q_EMIT message( | Q_EMIT message( | ||||
tr("Exporting Successful"), | tr("Exporting Successful"), | ||||
tr("The transaction history was successfully saved to %1.") | tr("The transaction history was successfully saved to %1.") | ||||
.arg(filename), | .arg(filename), | ||||
CClientUIInterface::MSG_INFORMATION); | CClientUIInterface::MSG_INFORMATION); | ||||
} | } | ||||
} | } | ||||
void TransactionView::contextualMenu(const QPoint &point) { | void TransactionView::contextualMenu(const QPoint &point) { | ||||
QModelIndex index = transactionView->indexAt(point); | QModelIndex index = transactionView->indexAt(point); | ||||
QModelIndexList selection = | QModelIndexList selection = | ||||
transactionView->selectionModel()->selectedRows(0); | transactionView->selectionModel()->selectedRows(0); | ||||
if (selection.empty()) return; | if (selection.empty()) return; | ||||
// check if transaction can be abandoned, disable context menu action in | // check if transaction can be abandoned, disable context menu action in | ||||
// case it doesn't | // case it doesn't | ||||
uint256 hash; | txhash_t hash; | ||||
hash.SetHex(selection.at(0) | hash.SetHex(selection.at(0) | ||||
.data(TransactionTableModel::TxHashRole) | .data(TransactionTableModel::TxHashRole) | ||||
.toString() | .toString() | ||||
.toStdString()); | .toStdString()); | ||||
abandonAction->setEnabled(model->transactionCanBeAbandoned(hash)); | abandonAction->setEnabled(model->transactionCanBeAbandoned(hash)); | ||||
if (index.isValid()) { | if (index.isValid()) { | ||||
contextMenu->exec(QCursor::pos()); | contextMenu->exec(QCursor::pos()); | ||||
} | } | ||||
} | } | ||||
void TransactionView::abandonTx() { | void TransactionView::abandonTx() { | ||||
if (!transactionView || !transactionView->selectionModel()) return; | if (!transactionView || !transactionView->selectionModel()) return; | ||||
QModelIndexList selection = | QModelIndexList selection = | ||||
transactionView->selectionModel()->selectedRows(0); | transactionView->selectionModel()->selectedRows(0); | ||||
// get the hash from the TxHashRole (QVariant / QString) | // get the hash from the TxHashRole (QVariant / QString) | ||||
uint256 hash; | txhash_t hash; | ||||
QString hashQStr = | QString hashQStr = | ||||
selection.at(0).data(TransactionTableModel::TxHashRole).toString(); | selection.at(0).data(TransactionTableModel::TxHashRole).toString(); | ||||
hash.SetHex(hashQStr.toStdString()); | hash.SetHex(hashQStr.toStdString()); | ||||
// Abandon the wallet transaction over the walletModel | // Abandon the wallet transaction over the walletModel | ||||
model->abandonTransaction(hash); | model->abandonTransaction(hash); | ||||
// Update the table | // Update the table | ||||
Show All 11 Lines | GUIUtil::copyEntryData(transactionView, 0, | ||||
TransactionTableModel::LabelRole); | TransactionTableModel::LabelRole); | ||||
} | } | ||||
void TransactionView::copyAmount() { | void TransactionView::copyAmount() { | ||||
GUIUtil::copyEntryData(transactionView, 0, | GUIUtil::copyEntryData(transactionView, 0, | ||||
TransactionTableModel::FormattedAmountRole); | TransactionTableModel::FormattedAmountRole); | ||||
} | } | ||||
void TransactionView::copyTxID() { | void TransactionView::copyTxHash() { | ||||
GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::TxIDRole); | GUIUtil::copyEntryData(transactionView, 0, | ||||
TransactionTableModel::TxHashRole); | |||||
} | } | ||||
void TransactionView::copyTxHex() { | void TransactionView::copyTxHex() { | ||||
GUIUtil::copyEntryData(transactionView, 0, | GUIUtil::copyEntryData(transactionView, 0, | ||||
TransactionTableModel::TxHexRole); | TransactionTableModel::TxHexRole); | ||||
} | } | ||||
void TransactionView::copyTxPlainText() { | void TransactionView::copyTxPlainText() { | ||||
▲ Show 20 Lines • Show All 145 Lines • Show Last 20 Lines |