aboutsummaryrefslogtreecommitdiff
path: root/src/qt/transactionview.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2011-07-07 14:27:16 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2011-07-07 14:27:16 +0200
commitfbaee7a8533b23d846ee16837320f709c4e83d47 (patch)
treef867d31077177c79d27a2c475fb19b566c5010bf /src/qt/transactionview.cpp
parentd52a0f3bca2c8df8360308b062185d803e34f0d9 (diff)
Export functionality for transaction list
Diffstat (limited to 'src/qt/transactionview.cpp')
-rw-r--r--src/qt/transactionview.cpp40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp
index a3407e85de..037dfbb3ed 100644
--- a/src/qt/transactionview.cpp
+++ b/src/qt/transactionview.cpp
@@ -1,11 +1,10 @@
#include "transactionview.h"
-// Temp includes for filtering prototype
-// Move to TransactionFilterRow class
#include "transactionfilterproxy.h"
#include "transactionrecord.h"
#include "transactiontablemodel.h"
#include "guiutil.h"
+#include "csvmodelwriter.h"
#include <QScrollBar>
#include <QComboBox>
@@ -15,6 +14,9 @@
#include <QLineEdit>
#include <QTableView>
#include <QHeaderView>
+#include <QPushButton>
+#include <QFileDialog>
+#include <QMessageBox>
#include <QDebug>
@@ -76,6 +78,7 @@ TransactionView::TransactionView(QWidget *parent) :
QVBoxLayout *vlayout = new QVBoxLayout(this);
vlayout->setContentsMargins(0,0,0,0);
vlayout->setSpacing(0);
+ //vlayout->addLayout(hlayout2);
QTableView *view = new QTableView(this);
vlayout->addLayout(hlayout);
@@ -196,3 +199,36 @@ void TransactionView::changedAmount(const QString &amount)
transactionProxyModel->setMinAmount(0);
}
}
+
+void TransactionView::exportClicked()
+{
+ // CSV is currently the only supported format
+ QString filename = QFileDialog::getSaveFileName(
+ this,
+ tr("Export Transaction Data"),
+ QDir::currentPath(),
+ tr("Comma separated file (*.csv)"));
+ if(!filename.endsWith(".csv"))
+ {
+ filename += ".csv";
+ }
+
+ CSVModelWriter writer(filename);
+
+ // name, column, role
+ writer.setModel(transactionProxyModel);
+ writer.addColumn("Confirmed", 0, TransactionTableModel::ConfirmedRole);
+ writer.addColumn("Date", 0, TransactionTableModel::DateRole);
+ writer.addColumn("Type", TransactionTableModel::Type, Qt::EditRole);
+ writer.addColumn("Label", 0, TransactionTableModel::LabelRole);
+ writer.addColumn("Address", 0, TransactionTableModel::AddressRole);
+ writer.addColumn("Amount", 0, TransactionTableModel::FormattedAmountRole);
+ writer.addColumn("ID", 0, TransactionTableModel::TxIDRole);
+
+ if(!writer.write())
+ {
+ QMessageBox::critical(this, tr("Error exporting"), tr("Could not write to file %1.").arg(filename),
+ QMessageBox::Abort, QMessageBox::Abort);
+ }
+}
+