1 /****************************************************************************
3 ** Copyright (C) Qxt Foundation. Some rights reserved.
5 ** This file is part of the QxtCore module of the Qt eXTension library
7 ** This library is free software; you can redistribute it and/or modify it
8 ** under the terms of th Common Public License, version 1.0, as published by
11 ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY
12 ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
13 ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR
14 ** FITNESS FOR A PARTICULAR PURPOSE.
16 ** You should have received a copy of the CPL along with this file.
17 ** See the LICENSE file and the cpl1.0.txt file included with the source
18 ** distribution for more information. If you did not receive a copy of the
19 ** license, contact the Qxt Foundation.
21 ** <http://libqxt.sourceforge.net> <foundation@libqxt.org>
23 ****************************************************************************/
27 #include <QAbstractTableModel>
32 #include <QStringList>
33 #include <QModelIndex>
35 #include <qxtglobal.h>
37 class QxtCsvModelPrivate;
38 class QXT_CORE_EXPORT QxtCsvModel : public QAbstractTableModel
42 QxtCsvModel(QObject *parent = 0);
43 QxtCsvModel(QIODevice *file, QObject *parent = 0, bool withHeader = false, QChar separator = ',');
44 QxtCsvModel(const QString filename, QObject *parent = 0, bool withHeader = false, QChar separator = ',');
47 int rowCount(const QModelIndex& parent = QModelIndex()) const;
48 int columnCount(const QModelIndex& parent = QModelIndex()) const;
49 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
50 bool setData(const QModelIndex& index, const QVariant& data, int role = Qt::EditRole);
51 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
52 void setHeaderData(const QStringList data);
54 bool insertRow(int row, const QModelIndex& parent = QModelIndex());
55 bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex());
56 bool removeRow(int row, const QModelIndex& parent = QModelIndex());
57 bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex());
58 bool insertColumn(int col, const QModelIndex& parent = QModelIndex());
59 bool insertColumns(int col, int count, const QModelIndex& parent = QModelIndex());
60 bool removeColumn(int col, const QModelIndex& parent = QModelIndex());
61 bool removeColumns(int col, int count, const QModelIndex& parent = QModelIndex());
63 void setSource(QIODevice *file, bool withHeader = false, QChar separator = ',');
64 void setSource(const QString filename, bool withHeader = false, QChar separator = ',');
66 void toCSV(QIODevice *file, bool withHeader = false, QChar separator = ',');
67 void toCSV(const QString filename, bool withHeader = false, QChar separator = ',');
69 Qt::ItemFlags flags(const QModelIndex& index) const;
72 QXT_DECLARE_PRIVATE(QxtCsvModel);