[depends] ZeroMQ 4.1.5
[bitcoinplatinum.git] / src / qt / csvmodelwriter.h
blobedea369ad1fa5c0999546fe74545b30fda4c765c
1 // Copyright (c) 2011-2014 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 #ifndef BITCOIN_QT_CSVMODELWRITER_H
6 #define BITCOIN_QT_CSVMODELWRITER_H
8 #include <QList>
9 #include <QObject>
11 QT_BEGIN_NAMESPACE
12 class QAbstractItemModel;
13 QT_END_NAMESPACE
15 /** Export a Qt table model to a CSV file. This is useful for analyzing or post-processing the data in
16 a spreadsheet.
18 class CSVModelWriter : public QObject
20 Q_OBJECT
22 public:
23 explicit CSVModelWriter(const QString &filename, QObject *parent = 0);
25 void setModel(const QAbstractItemModel *model);
26 void addColumn(const QString &title, int column, int role=Qt::EditRole);
28 /** Perform export of the model to CSV.
29 @returns true on success, false otherwise
31 bool write();
33 private:
34 QString filename;
35 const QAbstractItemModel *model;
37 struct Column
39 QString title;
40 int column;
41 int role;
43 QList<Column> columns;
46 #endif // BITCOIN_QT_CSVMODELWRITER_H