We now have a current svn snapshot of libqxt in our contrib dir, and
[quassel.git] / src / contrib / libqxt-2007-10-24 / src / core / qxtcsvmodel.h
1 /****************************************************************************
2 **
3 ** Copyright (C) Qxt Foundation. Some rights reserved.
4 **
5 ** This file is part of the QxtCore module of the Qt eXTension library
6 **
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
9 ** IBM.
10 **
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.
15 **
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.
20 **
21 ** <http://libqxt.sourceforge.net>  <foundation@libqxt.org>
22 **
23 ****************************************************************************/
24 #ifndef QXTCSVMODEL_H
25 #define QXTCSVMODEL_H
26
27 #include <QAbstractTableModel>
28 #include <QVariant>
29 #include <QIODevice>
30 #include <QChar>
31 #include <QString>
32 #include <QStringList>
33 #include <QModelIndex>
34 #include <qxtpimpl.h>
35 #include <qxtglobal.h>
36
37 class QxtCsvModelPrivate;
38 class QXT_CORE_EXPORT QxtCsvModel : public QAbstractTableModel
39 {
40     Q_OBJECT
41 public:
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 = ',');
45     ~QxtCsvModel();
46
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);
53
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());
62
63     void setSource(QIODevice *file, bool withHeader = false, QChar separator = ',');
64     void setSource(const QString filename, bool withHeader = false, QChar separator = ',');
65
66     void toCSV(QIODevice *file, bool withHeader = false, QChar separator = ',');
67     void toCSV(const QString filename, bool withHeader = false, QChar separator = ',');
68
69     Qt::ItemFlags flags(const QModelIndex& index) const;
70
71 private:
72     QXT_DECLARE_PRIVATE(QxtCsvModel);
73 };
74
75 #endif