34 #include <qcompilerdetection.h>
35 #include <QAbstractTableModel>
39 #include <QIncompatibleFlag>
40 #include <QMetaObject>
41 #include <QModelIndex>
44 #include <QStringList>
58 explicit QxtCsvModel(QIODevice *file, QObject *parent =
nullptr,
bool withHeader =
false, QChar separator =
',');
59 explicit QxtCsvModel(
const QString &filename, QObject *parent =
nullptr,
bool withHeader =
false,
60 QChar separator =
',');
63 virtual
int rowCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE;
64 virtual
int columnCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE;
65 virtual QVariant
data(const QModelIndex& index,
int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
66 virtual
bool setData(const QModelIndex& index, const QVariant&
data,
int role = Qt::EditRole) Q_DECL_OVERRIDE;
67 virtual QVariant
headerData(
int section, Qt::Orientation orientation,
68 int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
69 virtual
bool setHeaderData(
int section, Qt::Orientation orientation, const QVariant& value,
70 int role = Qt::DisplayRole) Q_DECL_OVERRIDE;
73 QString
text(
int row,
int column) const;
74 void setText(
int row,
int column, const QString& value);
80 bool insertRow(
int row, const QModelIndex& parent = QModelIndex());
81 virtual
bool insertRows(
int row,
int count, const QModelIndex& parent = QModelIndex()) Q_DECL_OVERRIDE;
83 bool removeRow(
int row, const QModelIndex& parent = QModelIndex());
84 virtual
bool removeRows(
int row,
int count, const QModelIndex& parent = QModelIndex()) Q_DECL_OVERRIDE;
86 bool insertColumn(
int col, const QModelIndex& parent = QModelIndex());
87 virtual
bool insertColumns(
int col,
int count, const QModelIndex& parent = QModelIndex()) Q_DECL_OVERRIDE;
89 bool removeColumn(
int col, const QModelIndex& parent = QModelIndex());
90 virtual
bool removeColumns(
int col,
int count, const QModelIndex& parent = QModelIndex()) Q_DECL_OVERRIDE;
92 void setSource(QIODevice *file,
bool withHeader = false, QChar separator = ',', QTextCodec* codec =
nullptr);
93 void setSource(const QString &filename,
bool withHeader = false, QChar separator = ',',
94 QTextCodec* codec =
nullptr);
96 void toCSV(QIODevice *file,
bool withHeader = false, QChar separator = ',', QTextCodec* codec =
nullptr) const;
97 void toCSV(const QString &filename,
bool withHeader = false, QChar separator = ',',
98 QTextCodec* codec =
nullptr) const;
114 virtual Qt::ItemFlags
flags(
const QModelIndex& index)
const Q_DECL_OVERRIDE;
120 Q_DECLARE_OPERATORS_FOR_FLAGS(
QxtCsvModel::QuoteMode)
The QxtCsvModel class provides a QAbstractTableModel for CSV Files.
virtual bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex()) Q_DECL_OVERRIDE
\reimp
void setText(int row, int column, const QString &value)
Sets the content of the cell at row row and column column to value.
bool insertColumn(int col, const QModelIndex &parent=QModelIndex())
\reimp
void setHeaderText(int column, const QString &value)
Sets the content of the header for column column to value.
QString headerText(int column) const
Fetches the content of the cell at row row and column column.
bool removeColumn(int col, const QModelIndex &parent=QModelIndex())
\reimp
virtual bool insertColumns(int col, int count, const QModelIndex &parent=QModelIndex()) Q_DECL_OVERRIDE
\reimp
virtual bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::DisplayRole) Q_DECL_OVERRIDE
\reimp
void setSource(QIODevice *file, bool withHeader=false, QChar separator=',', QTextCodec *codec=nullptr)
Reads in a CSV file from the provided file using codec.
bool removeRow(int row, const QModelIndex &parent=QModelIndex())
\reimp
QuoteMode quoteMode() const
Returns the current quoting mode.
virtual Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE
\reimp
virtual ~QxtCsvModel() Q_DECL_EQ_DEFAULT
bool insertRow(int row, const QModelIndex &parent=QModelIndex())
\reimp
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const Q_DECL_OVERRIDE
\reimp
void setQuoteMode(QuoteMode mode)
Sets the current quoting mode.
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const Q_DECL_OVERRIDE
\reimp
virtual bool removeColumns(int col, int count, const QModelIndex &parent=QModelIndex()) Q_DECL_OVERRIDE
\reimp
virtual bool setData(const QModelIndex &index, const QVariant &data, int role=Qt::EditRole) Q_DECL_OVERRIDE
\reimp
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const Q_DECL_OVERRIDE
\reimp
QString text(int row, int column) const
Fetches the content of the cell at row row and column column.
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const Q_DECL_OVERRIDE
\reimp
void toCSV(QIODevice *file, bool withHeader=false, QChar separator=',', QTextCodec *codec=nullptr) const
Outputs the content of the model as a CSV file to the device dest using codec.
QxtCsvModel(QObject *parent=nullptr)
Creates an empty QxtCsvModel with parent parent.
virtual bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) Q_DECL_OVERRIDE
\reimp
#define QXT_DECLARE_PRIVATE(PUB)