|
LibEngsas
|
ExmlModel is a base class to handle XML files very easily. More...
#include <exmlmodel.h>
Inheritance diagram for EXmlModel:
Collaboration diagram for EXmlModel:Signals | |
| void | modified (bool status) |
Signals inherited from EAbstractItemModel | |
| void | error (QString msg) |
| void | warning (QString msg) |
| void | information (QString msg) |
| void | eRowsInserted (const QModelIndex &parent, int start, int end) |
| Replacement of private signal rowsInserted(). More... | |
| void | eRowsRemoved (const QModelIndex &parent, int start, int end) |
| Replacement of private signal rowsRemoved(). More... | |
Public Member Functions | |
| EXmlModel (QUrl validationUrl, QObject *parent=0) | |
| virtual | ~EXmlModel () |
| bool | load (QDomElement element) |
Loads the XML structure below and including element. More... | |
| bool | load (QDomDocument document) |
| Overladed of load(QDomElement) More... | |
| bool | load (QFile *file) |
| Overladed of load(QDomDocument) More... | |
| bool | load (QString file) |
| Overladed of load(QFile*) More... | |
| bool | load (QByteArray data) |
| Overloaded of load(QDomDocument). More... | |
| bool | save (QDomElement &useElem) |
| bool | save (QFile *file) |
| bool | save (QString file) |
| QDomDocument | save () |
| The model contained in a QDomDocument. More... | |
| bool | isValidXML () |
| EXmlItem * | itemFromIndex (QModelIndex index) const |
| QModelIndex | indexFromItem (EXmlItem *item) const |
| bool | removeItem (QModelIndex index) |
Removes and deletes the item with index index. More... | |
| bool | removeItem (EXmlItem *item) |
Removes and deletes the item item. More... | |
| virtual void | setRootItem (EXmlItem *item) |
Replaces or sets the current root item to item. More... | |
| EXmlItem * | rootItem () const |
| bool | isModified () const |
| Returns true, if the model has been modified since the last save. More... | |
| QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const |
| bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) |
| int | columnCount (const QModelIndex &parent=QModelIndex()) const |
| int | rowCount (const QModelIndex &parent=QModelIndex()) const |
| QModelIndex | parent (const QModelIndex &child) const |
| QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const |
| QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const |
| bool | removeRows (int row, int count, const QModelIndex &parent=QModelIndex()) |
Public Member Functions inherited from EAbstractItemModel | |
| EAbstractItemModel (QObject *parent=0) | |
| virtual | ~EAbstractItemModel () |
Protected Slots | |
| virtual void | itemChanged (EXmlItem *item) |
| Reimplement this slot, if you want to recieve EXmlItem::changed() signals. More... | |
| virtual void | itemRowsAboutToBeInserted (EXmlItem *parent, int start, int end) |
| Called by rootItem() signal EXmlItem::rowsAboutToBeInserted(). More... | |
| virtual void | itemRowsInserted () |
| Called by rootItem() signal EXmlItem::rowsInserted(). More... | |
| virtual void | itemRowsAboutToBeRemoved (EXmlItem *parent, int start, int end) |
| Called by rootItem() signal EXmlItem::rowsAboutToBeRemoved(). More... | |
| virtual void | itemRowsRemoved () |
| Called by rootItem() signal EXmlItem::rowsRemoved(). More... | |
Protected Slots inherited from EAbstractItemModel | |
| virtual void | errorByPass (const QString &message) |
Protected Member Functions | |
| bool | registerParser (EXmlItem *(*createCallback)(EXmlModel *)) |
| void | setValidationSchema (QUrl url) |
| virtual bool | prepareForSaving () |
| Called by save(QDomElement) to prepare model for saving. More... | |
Protected Member Functions inherited from EAbstractItemModel | |
| virtual void | warningByPass (const QString &message) |
| virtual void | informationByPass (const QString &message) |
Protected Attributes | |
| QStringList | headerList |
Private Slots | |
| void | setModified (bool status) |
Private Member Functions | |
| QModelIndex | indexFromItem (EXmlItem *find, EXmlItem *parent) const |
Private Attributes | |
| QUrl | validationUrl |
| QMap< QString, EXmlParserItem * > | parsers |
| EXmlItem * | myRootItem |
| bool | _isModified |
Additional Inherited Members | |
Static Public Member Functions inherited from EAbstractItemModel | |
| static void | connectByPass (QObject *parent, EAbstractItemModel *child) |
| static void | connectByPass (EAbstractItemModel *parent, QObject *child) |
ExmlModel is a base class to handle XML files very easily.
To get an working XMl Model, you only have to subclass it and create an Constructor. Inside the constructor, append you header strings to headerList and register your subclassed EXmlItem's with help of registerParser().
To hide the rootItem, use QAbstractItemView::setRootIndex() and set it to the index of the rootItem.
If your model needs to be prepared before it could be saved, implement prepareForSaving() in your subclass.
To copy the complete model, create a new empty model and set a copy of the original root item as the new root item.
| EXmlModel::EXmlModel | ( | QUrl | validationUrl, |
| QObject * | parent = 0 |
||
| ) |
validationUrl can point to a local file via file:// (e.g. file:///tmp/xmlschema.xsd) or to a url (e.g. http://www.example.org/example.dtd)
Here is the call graph for this function:
|
virtual |
| int EXmlModel::columnCount | ( | const QModelIndex & | parent = QModelIndex() | ) | const |
Here is the caller graph for this function:| QVariant EXmlModel::data | ( | const QModelIndex & | index, |
| int | role = Qt::DisplayRole |
||
| ) | const |
Here is the call graph for this function:
Here is the caller graph for this function:| QVariant EXmlModel::headerData | ( | int | section, |
| Qt::Orientation | orientation, | ||
| int | role = Qt::DisplayRole |
||
| ) | const |
| QModelIndex EXmlModel::index | ( | int | row, |
| int | column, | ||
| const QModelIndex & | parent = QModelIndex() |
||
| ) | const |
Here is the call graph for this function:
Here is the caller graph for this function:| QModelIndex EXmlModel::indexFromItem | ( | EXmlItem * | item | ) | const |
Here is the call graph for this function:
Here is the caller graph for this function:
Here is the call graph for this function:| bool EXmlModel::isModified | ( | ) | const |
Returns true, if the model has been modified since the last save.
If the model is modified for the first time after a save() or load(), isModified() is set to true and also the signal modified(true) is emitted. Saving the model with save() resets the modified state to false (emits also modified(false) and the process starts over again.
To detect those changes, EXmlItem::changed() is monitored by the model and also row inserts and removes are observed.
| bool EXmlModel::isValidXML | ( | ) |
checks the actual structure validation against the scheme at validationUrl
Here is the call graph for this function:
|
protectedvirtualslot |
Reimplement this slot, if you want to recieve EXmlItem::changed() signals.
This default implementation emits the dataChanged() signal for the complete row represented by item.
Here is the call graph for this function:
Here is the caller graph for this function:| EXmlItem * EXmlModel::itemFromIndex | ( | QModelIndex | index | ) | const |
Here is the caller graph for this function:
|
protectedvirtualslot |
Called by rootItem() signal EXmlItem::rowsAboutToBeInserted().
It converts the recieved data to call beginInsertRows().
Here is the call graph for this function:
Here is the caller graph for this function:
|
protectedvirtualslot |
Called by rootItem() signal EXmlItem::rowsAboutToBeRemoved().
It calls beginRemoveRows() with converted recieved data.
Here is the call graph for this function:
Here is the caller graph for this function:
|
protectedvirtualslot |
Called by rootItem() signal EXmlItem::rowsInserted().
It calls endInsertRows().
Here is the caller graph for this function:
|
protectedvirtualslot |
Called by rootItem() signal EXmlItem::rowsRemoved().
It calls endRemoveRows().
Here is the caller graph for this function:| bool EXmlModel::load | ( | QDomElement | element | ) |
Loads the XML structure below and including element.
Returns true if everything went fine (e.g. every tag could be parsed)
Here is the call graph for this function:
Here is the caller graph for this function:| bool EXmlModel::load | ( | QDomDocument | document | ) |
Overladed of load(QDomElement)
Here is the call graph for this function:
Here is the caller graph for this function:| bool EXmlModel::load | ( | QFile * | file | ) |
| bool EXmlModel::load | ( | QString | file | ) |
| bool EXmlModel::load | ( | QByteArray | data | ) |
Overloaded of load(QDomDocument).
Constructs a QDomDocument out of the QByteArray.
Here is the call graph for this function:
|
signal |
Here is the caller graph for this function:| QModelIndex EXmlModel::parent | ( | const QModelIndex & | child | ) | const |
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlineprotectedvirtual |
Called by save(QDomElement) to prepare model for saving.
Reimplement this function, if anything needs to be done before the model can be saved.
Here is the caller graph for this function:call this function to register your subclass of EXmlItem. Your subclass should contain a public static function to create the needed function pointer createCallback. This Function pointer is called during loading the structure, to create instances of your subclass and parse the given XML structure
createCallback could be registered to handle tags with name tagName. tagName is empty, or createCallback is NULLThe created EXmlParserItem by this function automatically provides the pointer to this EXmlModel, when calling the createCallback.
Here is the call graph for this function:
Here is the caller graph for this function:| bool EXmlModel::removeItem | ( | QModelIndex | index | ) |
Removes and deletes the item with index index.
Here is the call graph for this function:
Here is the caller graph for this function:| bool EXmlModel::removeItem | ( | EXmlItem * | item | ) |
Removes and deletes the item item.
Conveniance function for removeItem(QModelIndex())
Here is the call graph for this function:| bool EXmlModel::removeRows | ( | int | row, |
| int | count, | ||
| const QModelIndex & | parent = QModelIndex() |
||
| ) |
Here is the call graph for this function:| EXmlItem * EXmlModel::rootItem | ( | ) | const |
Here is the caller graph for this function:| int EXmlModel::rowCount | ( | const QModelIndex & | parent = QModelIndex() | ) | const |
Here is the call graph for this function:
Here is the caller graph for this function:| bool EXmlModel::save | ( | QDomElement & | useElem | ) |
The model is stored into useElem. But be aware, that useElem will contain the rootItem of this model. Therefore useElem should be an empty element (but not a null element)
Here is the call graph for this function:| bool EXmlModel::save | ( | QFile * | file | ) |
overladed of save(QDomElement)
Here is the call graph for this function:| bool EXmlModel::save | ( | QString | file | ) |
| QDomDocument EXmlModel::save | ( | ) |
The model contained in a QDomDocument.
The document is in utf-8 encoding. If an error occurs, an empty QDomDocument is returned.
Here is the caller graph for this function:| bool EXmlModel::setData | ( | const QModelIndex & | index, |
| const QVariant & | value, | ||
| int | role = Qt::EditRole |
||
| ) |
Here is the call graph for this function:
|
privateslot |
Here is the caller graph for this function:
|
virtual |
Replaces or sets the current root item to item.
If an existing item is replaced, the signals modelAboutToBeReset() and modelReset() are emitted. Otherwise the signals layoutAboutToBeChanged() and layoutChanged() are emited.
Here is the call graph for this function:
Here is the caller graph for this function:
|
protected |
Here is the caller graph for this function:
|
private |
|
protected |
append strings to this list, to get more columns
|
private |
|
private |
|
private |
1.8.8