MCPcopy Create free account
hub / github.com/ElementsProject/elements / exportClicked

Method exportClicked

src/qt/transactionview.cpp:352–390  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

350}
351
352void TransactionView::exportClicked()
353{
354 if (!model || !model->getOptionsModel()) {
355 return;
356 }
357
358 // CSV is currently the only supported format
359 QString filename = GUIUtil::getSaveFileName(this,
360 tr("Export Transaction History"), QString(),
361 /*: Expanded name of the CSV file format.
362 See: https://en.wikipedia.org/wiki/Comma-separated_values. */
363 tr("Comma separated file") + QLatin1String(" (*.csv)"), nullptr);
364
365 if (filename.isNull())
366 return;
367
368 CSVModelWriter writer(filename);
369
370 // name, column, role
371 writer.setModel(transactionProxyModel);
372 writer.addColumn(tr("Confirmed"), 0, TransactionTableModel::ConfirmedRole);
373 if (model->wallet().haveWatchOnly())
374 writer.addColumn(tr("Watch-only"), TransactionTableModel::Watchonly);
375 writer.addColumn(tr("Date"), 0, TransactionTableModel::DateRole);
376 writer.addColumn(tr("Type"), TransactionTableModel::Type, Qt::EditRole);
377 writer.addColumn(tr("Label"), 0, TransactionTableModel::LabelRole);
378 writer.addColumn(tr("Address"), 0, TransactionTableModel::AddressRole);
379 writer.addColumn(BitcoinUnits::getAmountColumnTitle(model->getOptionsModel()->getDisplayUnit()), 0, TransactionTableModel::FormattedAmountRole);
380 writer.addColumn(tr("ID"), 0, TransactionTableModel::TxHashRole);
381
382 if(!writer.write()) {
383 Q_EMIT message(tr("Exporting Failed"), tr("There was an error trying to save the transaction history to %1.").arg(filename),
384 CClientUIInterface::MSG_ERROR);
385 }
386 else {
387 Q_EMIT message(tr("Exporting Successful"), tr("The transaction history was successfully saved to %1.").arg(filename),
388 CClientUIInterface::MSG_INFORMATION);
389 }
390}
391
392void TransactionView::contextualMenu(const QPoint &point)
393{

Callers

nothing calls this directly

Calls 9

getSaveFileNameFunction · 0.85
addColumnMethod · 0.80
haveWatchOnlyMethod · 0.80
getDisplayUnitMethod · 0.80
getOptionsModelMethod · 0.45
isNullMethod · 0.45
setModelMethod · 0.45
walletMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected