Qt Model Utilities
2.0.3
A set of utilities for the model/view framework of Qt
|
Serialiser to save and load models in csv (comma separated values) format. More...
Public Member Functions | |
CsvModelSerialiser (const QAbstractItemModel *model, QObject *parent) | |
CsvModelSerialiser (QAbstractItemModel *model, QObject *parent) | |
CsvModelSerialiser (QObject *parent=Q_NULLPTR) | |
const QString & | csvSeparator () const |
bool | firstColumnIsHeader () |
bool | firstRowIsHeader () |
bool | loadModel (const QByteArray &source) Q_DECL_OVERRIDE |
bool | loadModel (QIODevice *source) Q_DECL_OVERRIDE |
bool | loadModel (QString *source) Q_DECL_OVERRIDE |
virtual bool | loadModel (QTextStream &stream) |
bool | saveModel (QByteArray *destination) const Q_DECL_OVERRIDE |
bool | saveModel (QIODevice *destination) const Q_DECL_OVERRIDE |
bool | saveModel (QString *destination) const Q_DECL_OVERRIDE |
virtual bool | saveModel (QTextStream &stream) const |
void | setCsvSeparator (const QString &val) |
void | setFirstColumnIsHeader (bool val) |
void | setFirstRowIsHeader (bool val) |
![]() | |
AbstractSingleRoleSerialiser (const QAbstractItemModel *model, QObject *parent) | |
AbstractSingleRoleSerialiser (QAbstractItemModel *model, QObject *parent) | |
AbstractSingleRoleSerialiser (QObject *parent=Q_NULLPTR) | |
~AbstractSingleRoleSerialiser ()=0 | |
void | addRoleToSave (int role) Q_DECL_OVERRIDE |
void | clearRoleToSave () Q_DECL_OVERRIDE |
void | removeRoleToSave (int role) Q_DECL_OVERRIDE |
void | resetRoleToSave () Q_DECL_OVERRIDE |
int | roleToSave () const |
void | setRoleToSave (const QList< int > &val) Q_DECL_OVERRIDE |
void | setRoleToSave (int val) |
![]() | |
AbstractStringSerialiser (const QAbstractItemModel *model, QObject *parent) | |
AbstractStringSerialiser (QAbstractItemModel *model, QObject *parent) | |
AbstractStringSerialiser (QObject *parent=Q_NULLPTR) | |
virtual | ~AbstractStringSerialiser ()=0 |
Q_INVOKABLE bool | loadModel (const QString &source) |
![]() | |
AbstractModelSerialiser (const QAbstractItemModel *model, QObject *parent) | |
AbstractModelSerialiser (QAbstractItemModel *model, QObject *parent) | |
AbstractModelSerialiser (QObject *parent=Q_NULLPTR) | |
virtual | ~AbstractModelSerialiser ()=0 |
virtual const QAbstractItemModel * | constModel () const |
virtual QAbstractItemModel * | model () const |
virtual const QList< int > & | rolesToSave () const |
void | setModel (const QAbstractItemModel *val) |
void | setModel (QAbstractItemModel *val) |
Q_INVOKABLE QDataStream::Version | streamVersion () const |
The datastream version used to serialise binary data. More... | |
Protected Member Functions | |
CsvModelSerialiser (CsvModelSerialiserPrivate &d, QObject *parent) | |
![]() | |
AbstractSingleRoleSerialiser (AbstractSingleRoleSerialiserPrivate &d, QObject *parent) | |
![]() | |
AbstractStringSerialiser (AbstractStringSerialiserPrivate &d, QObject *parent) | |
![]() | |
AbstractModelSerialiser (AbstractModelSerialiserPrivate &d, QObject *parent) | |
Properties | |
QString | csvSeparator |
The column separator used in the CSV. More... | |
bool | firstColumnIsHeader |
Should the first column contain headers. More... | |
bool | firstRowIsHeader |
Should the first row contain headers. More... | |
![]() | |
int | roleToSave |
The role that will be serialised. More... | |
![]() | |
const QAbstractItemModel * | constModel |
The model over which the serialiser will operate in read mode. More... | |
QAbstractItemModel * | model |
The model over which the serialiser will operate for reading/writing. More... | |
QList< int > | rolesToSave |
The roles that will be serialised. More... | |
Additional Inherited Members | |
![]() | |
void | setStreamVersion (QDataStream::Version ver) |
Set the datastream version used to serialise binary data. More... | |
![]() | |
static QList< int > | modelDefaultRoles () |
Serialiser to save and load models in csv (comma separated values) format.
|
explicit |
Constructs a serialiser
CsvModelSerialiser::CsvModelSerialiser | ( | QAbstractItemModel * | model, |
QObject * | parent | ||
) |
Constructs a serialiser operating over model
CsvModelSerialiser::CsvModelSerialiser | ( | const QAbstractItemModel * | model, |
QObject * | parent | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
the model will only be allowed to be saved, not loaded
|
virtual |
Reimplemented from base class
Implements AbstractModelSerialiser.
|
virtual |
Reimplemented from base class
Implements AbstractModelSerialiser.
|
virtual |
Reimplemented from base class
Implements AbstractStringSerialiser.
|
virtual |
Loads the model from the given stream
Data previously stored in the model will be removed
|
virtual |
Reimplemented from base class
Implements AbstractModelSerialiser.
|
virtual |
Reimplemented from base class
Implements AbstractModelSerialiser.
|
virtual |
Reimplemented from base class
Implements AbstractStringSerialiser.
|
virtual |
Saves the model to the given stream
|
readwrite |
The column separator used in the CSV.
This is the string that will be used to separate items in the same row but different columns
By default the separator is set to a comma: ,
|
readwrite |
Should the first column contain headers.
If this property is set to true (the default), the serialisation will the write the vertical headerData of the model as the first column of the csv file and will load the first column of the csv file as the model's vertical headerData
|
readwrite |
Should the first row contain headers.
If this property is set to true (the default), the serialisation will the write the horizontal headerData of the model as the first row of the csv file and will load the first row of the csv file as the model's horizontal headerData