Files
thehub/hub-qt/csvmodelwriter.h
T

61 lines
1.6 KiB
C++
Raw Permalink Normal View History

2017-11-09 19:34:51 +01:00
/*
* This file is part of the Flowee project
* Copyright (C) 2011-2013 The Bitcoin Core developers
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2013-11-04 16:20:43 +01:00
2018-01-16 10:47:52 +00:00
#ifndef FLOWEE_QT_CSVMODELWRITER_H
#define FLOWEE_QT_CSVMODELWRITER_H
2011-07-07 14:27:16 +02:00
#include <QList>
2013-04-13 00:13:08 -05:00
#include <QObject>
2011-07-07 14:27:16 +02:00
QT_BEGIN_NAMESPACE
class QAbstractItemModel;
QT_END_NAMESPACE
2011-11-13 13:19:52 +01:00
/** Export a Qt table model to a CSV file. This is useful for analyzing or post-processing the data in
a spreadsheet.
*/
2011-07-07 14:27:16 +02:00
class CSVModelWriter : public QObject
{
Q_OBJECT
2013-01-23 21:51:02 +01:00
2011-07-07 14:27:16 +02:00
public:
explicit CSVModelWriter(const QString &filename, QObject *parent = 0);
void setModel(const QAbstractItemModel *model);
void addColumn(const QString &title, int column, int role=Qt::EditRole);
2011-11-13 13:19:52 +01:00
/** Perform export of the model to CSV.
@returns true on success, false otherwise
*/
2011-07-07 14:27:16 +02:00
bool write();
private:
QString filename;
const QAbstractItemModel *model;
struct Column
{
QString title;
int column;
int role;
};
QList<Column> columns;
};
2018-01-16 10:47:52 +00:00
#endif