| 342 | } |
| 343 | |
| 344 | void TransactionView::exportClicked() |
| 345 | { |
| 346 | if (!model || !model->getOptionsModel()) { |
| 347 | return; |
| 348 | } |
| 349 | |
| 350 | // CSV is currently the only supported format |
| 351 | QString filename = GUIUtil::getSaveFileName(this, |
| 352 | tr("Export Transaction History"), QString(), |
| 353 | tr("Comma separated file (*.csv)"), nullptr); |
| 354 | |
| 355 | if (filename.isNull()) |
| 356 | return; |
| 357 | |
| 358 | CSVModelWriter writer(filename); |
| 359 | |
| 360 | // name, column, role |
| 361 | writer.setModel(transactionProxyModel); |
| 362 | writer.addColumn(tr("Confirmed"), 0, TransactionTableModel::ConfirmedRole); |
| 363 | if (model->wallet().haveWatchOnly()) |
| 364 | writer.addColumn(tr("Watch-only"), TransactionTableModel::Watchonly); |
| 365 | writer.addColumn(tr("Date"), 0, TransactionTableModel::DateRole); |
| 366 | writer.addColumn(tr("Type"), TransactionTableModel::Type, Qt::EditRole); |
| 367 | writer.addColumn(tr("Label"), 0, TransactionTableModel::LabelRole); |
| 368 | writer.addColumn(tr("Address"), 0, TransactionTableModel::AddressRole); |
| 369 | writer.addColumn(BitcoinUnits::getAmountColumnTitle(model->getOptionsModel()->getDisplayUnit()), 0, TransactionTableModel::FormattedAmountRole); |
| 370 | writer.addColumn(tr("ID"), 0, TransactionTableModel::TxHashRole); |
| 371 | |
| 372 | if(!writer.write()) { |
| 373 | Q_EMIT message(tr("Exporting Failed"), tr("There was an error trying to save the transaction history to %1.").arg(filename), |
| 374 | CClientUIInterface::MSG_ERROR); |
| 375 | } |
| 376 | else { |
| 377 | Q_EMIT message(tr("Exporting Successful"), tr("The transaction history was successfully saved to %1.").arg(filename), |
| 378 | CClientUIInterface::MSG_INFORMATION); |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | void TransactionView::contextualMenu(const QPoint &point) |
| 383 | { |
nothing calls this directly
no test coverage detected