| 317 | } |
| 318 | |
| 319 | void TransactionView::exportClicked() |
| 320 | { |
| 321 | if (!model || !model->getOptionsModel()) { |
| 322 | return; |
| 323 | } |
| 324 | |
| 325 | // CSV is currently the only supported format |
| 326 | QString filename = GUIUtil::getSaveFileName(this, |
| 327 | tr("Export Transaction History"), QString(), |
| 328 | /*: Expanded name of the CSV file format. |
| 329 | See: https://en.wikipedia.org/wiki/Comma-separated_values. */ |
| 330 | tr("Comma separated file") + QLatin1String(" (*.csv)"), nullptr); |
| 331 | |
| 332 | if (filename.isNull()) |
| 333 | return; |
| 334 | |
| 335 | CSVModelWriter writer(filename); |
| 336 | |
| 337 | // name, column, role |
| 338 | writer.setModel(transactionProxyModel); |
| 339 | writer.addColumn(tr("Confirmed"), 0, TransactionTableModel::ConfirmedRole); |
| 340 | writer.addColumn(tr("Date"), 0, TransactionTableModel::DateRole); |
| 341 | writer.addColumn(tr("Type"), TransactionTableModel::Type, Qt::EditRole); |
| 342 | writer.addColumn(tr("Label"), 0, TransactionTableModel::LabelRole); |
| 343 | writer.addColumn(tr("Address"), 0, TransactionTableModel::AddressRole); |
| 344 | writer.addColumn(BitcoinUnits::getAmountColumnTitle(model->getOptionsModel()->getDisplayUnit()), 0, TransactionTableModel::FormattedAmountRole); |
| 345 | writer.addColumn(tr("ID"), 0, TransactionTableModel::TxHashRole); |
| 346 | |
| 347 | if(!writer.write()) { |
| 348 | Q_EMIT message(tr("Exporting Failed"), tr("There was an error trying to save the transaction history to %1.").arg(filename), |
| 349 | CClientUIInterface::MSG_ERROR); |
| 350 | } |
| 351 | else { |
| 352 | Q_EMIT message(tr("Exporting Successful"), tr("The transaction history was successfully saved to %1.").arg(filename), |
| 353 | CClientUIInterface::MSG_INFORMATION); |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | void TransactionView::contextualMenu(const QPoint &point) |
| 358 | { |
nothing calls this directly
no test coverage detected