/* * 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 . */ #ifndef FLOWEE_QT_CSVMODELWRITER_H #define FLOWEE_QT_CSVMODELWRITER_H #include #include QT_BEGIN_NAMESPACE class QAbstractItemModel; QT_END_NAMESPACE /** Export a Qt table model to a CSV file. This is useful for analyzing or post-processing the data in a spreadsheet. */ class CSVModelWriter : public QObject { Q_OBJECT 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); /** Perform export of the model to CSV. @returns true on success, false otherwise */ bool write(); private: QString filename; const QAbstractItemModel *model; struct Column { QString title; int column; int role; }; QList columns; }; #endif