Raven Core  3.0.0
P2P Digital Currency
csvmodelwriter.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2014 The Bitcoin Core developers
2 // Copyright (c) 2017-2019 The Raven Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef RAVEN_QT_CSVMODELWRITER_H
7 #define RAVEN_QT_CSVMODELWRITER_H
8 
9 #include <QList>
10 #include <QObject>
11 
12 QT_BEGIN_NAMESPACE
13 class QAbstractItemModel;
14 QT_END_NAMESPACE
15 
19 class CSVModelWriter : public QObject
20 {
21  Q_OBJECT
22 
23 public:
24  explicit CSVModelWriter(const QString &filename, QObject *parent = 0);
25 
26  void setModel(const QAbstractItemModel *model);
27  void addColumn(const QString &title, int column, int role=Qt::EditRole);
28 
32  bool write();
33 
34 private:
35  QString filename;
36  const QAbstractItemModel *model;
37 
38  struct Column
39  {
40  QString title;
41  int column;
42  int role;
43  };
44  QList<Column> columns;
45 };
46 
47 #endif // RAVEN_QT_CSVMODELWRITER_H
void addColumn(const QString &title, int column, int role=Qt::EditRole)
QList< Column > columns
Export a Qt table model to a CSV file.
const QAbstractItemModel * model
CSVModelWriter(const QString &filename, QObject *parent=0)
void setModel(const QAbstractItemModel *model)
bool write()
Perform export of the model to CSV.