Qt Model Utilities  2.0.3
A set of utilities for the model/view framework of Qt
Public Member Functions | Protected Member Functions | Properties | List of all members
XmlModelSerialiser Class Reference

Serialiser to save and load models in XML format. More...

Inheritance diagram for XmlModelSerialiser:
AbstractStringSerialiser AbstractModelSerialiser

Public Member Functions

 XmlModelSerialiser (const QAbstractItemModel *model, QObject *parent)
 
 XmlModelSerialiser (QAbstractItemModel *model, QObject *parent)
 
 XmlModelSerialiser (QObject *parent=Q_NULLPTR)
 
 ~XmlModelSerialiser ()
 
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 (QXmlStreamReader &stream)
 
bool printStartDocument () const
 
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 (QXmlStreamWriter &stream) const
 
void setPrintStartDocument (bool val)
 
- Public Member Functions inherited from AbstractStringSerialiser
 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)
 
- Public Member Functions inherited from AbstractModelSerialiser
 AbstractModelSerialiser (const QAbstractItemModel *model, QObject *parent)
 
 AbstractModelSerialiser (QAbstractItemModel *model, QObject *parent)
 
 AbstractModelSerialiser (QObject *parent=Q_NULLPTR)
 
virtual ~AbstractModelSerialiser ()=0
 
virtual Q_INVOKABLE void addRoleToSave (int role)
 Appends role to the list of roles to save. More...
 
virtual Q_INVOKABLE void clearRoleToSave ()
 empties the list of roles to save More...
 
virtual const QAbstractItemModel * constModel () const
 
virtual QAbstractItemModel * model () const
 
virtual Q_INVOKABLE void removeRoleToSave (int role)
 Removes role from the list of roles to save. More...
 
virtual void resetRoleToSave ()
 resetter of rolesToSave property More...
 
virtual const QList< int > & rolesToSave () const
 
void setModel (const QAbstractItemModel *val)
 
void setModel (QAbstractItemModel *val)
 
virtual void setRoleToSave (const QList< int > &val)
 
Q_INVOKABLE QDataStream::Version streamVersion () const
 The datastream version used to serialise binary data. More...
 

Protected Member Functions

 XmlModelSerialiser (XmlModelSerialiserPrivate &d, QObject *parent)
 
- Protected Member Functions inherited from AbstractStringSerialiser
 AbstractStringSerialiser (AbstractStringSerialiserPrivate &d, QObject *parent)
 
- Protected Member Functions inherited from AbstractModelSerialiser
 AbstractModelSerialiser (AbstractModelSerialiserPrivate &d, QObject *parent)
 

Properties

bool printStartDocument
 This property determines if the start of the xml document should be written. More...
 
- Properties inherited from AbstractModelSerialiser
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

- Public Slots inherited from AbstractModelSerialiser
void setStreamVersion (QDataStream::Version ver)
 Set the datastream version used to serialise binary data. More...
 
- Static Public Member Functions inherited from AbstractModelSerialiser
static QList< int > modelDefaultRoles ()
 

Detailed Description

Serialiser to save and load models in XML format.

Constructor & Destructor Documentation

◆ XmlModelSerialiser() [1/3]

XmlModelSerialiser::XmlModelSerialiser ( QObject *  parent = Q_NULLPTR)
explicit

Constructs a serialiser

◆ XmlModelSerialiser() [2/3]

XmlModelSerialiser::XmlModelSerialiser ( QAbstractItemModel *  model,
QObject *  parent 
)

Constructs a serialiser operating over model

◆ XmlModelSerialiser() [3/3]

XmlModelSerialiser::XmlModelSerialiser ( 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

◆ ~XmlModelSerialiser()

XmlModelSerialiser::~XmlModelSerialiser ( )
default

Destructor

Member Function Documentation

◆ loadModel() [1/4]

bool XmlModelSerialiser::loadModel ( const QByteArray &  source)
virtual

Reimplemented from base class

Implements AbstractModelSerialiser.

◆ loadModel() [2/4]

bool XmlModelSerialiser::loadModel ( QIODevice *  source)
virtual

Reimplemented from base class

Implements AbstractModelSerialiser.

◆ loadModel() [3/4]

bool XmlModelSerialiser::loadModel ( QString *  source)
virtual

Reimplemented from base class

Implements AbstractStringSerialiser.

◆ loadModel() [4/4]

bool XmlModelSerialiser::loadModel ( QXmlStreamReader &  stream)
virtual

Loads the model from the given stream

Data previously stored in the model will be removed

◆ saveModel() [1/4]

bool XmlModelSerialiser::saveModel ( QByteArray *  destination) const
virtual

Reimplemented from base class

Implements AbstractModelSerialiser.

◆ saveModel() [2/4]

bool XmlModelSerialiser::saveModel ( QIODevice *  destination) const
virtual

Reimplemented from base class

Implements AbstractModelSerialiser.

◆ saveModel() [3/4]

bool XmlModelSerialiser::saveModel ( QString *  destination) const
virtual

Reimplemented from base class

Implements AbstractStringSerialiser.

◆ saveModel() [4/4]

bool XmlModelSerialiser::saveModel ( QXmlStreamWriter &  stream) const
virtual

Saves the model to the given stream

Property Documentation

◆ printStartDocument

XmlModelSerialiser::printStartDocument
readwrite

This property determines if the start of the xml document should be written.

Access functions: printStartDocument(), setPrintStartDocument()

If this property is set to true (the default) the serialiser will write the <?xml> starting block. Set this to false to save the model as part of a larger xml document