|
Updraft
1.0
Open source glider flight visualisation tool.
|
Model that stores all settings. More...
#include <settingsmodel.h>

Signals | |
| void | itemChanged (SettingsItem *item) |
| Signals that an item's data changed. | |
Public Member Functions | |
| SettingsModel () | |
| ~SettingsModel () | |
| void | loadSettings (QString filename) |
| Loads settings from a xml settings file. | |
| void | saveSettings (QString filename) |
| Saves the settings to a settings file. | |
| int | columnCount (const QModelIndex &index) const |
| Returns the number of columns under the given index. | |
| QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const |
| Gets the data for the given index and data role. | |
| QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const |
| Gets the index for the desired SettingsItem. | |
| QModelIndex | indexFromItem (SettingsItem *item) const |
| Looks up the model index for a given SettingsItem. | |
| bool | insertRow (int row, const QModelIndex &parent=QModelIndex()) |
| Inserts a row into the model under the given parent item. | |
| SettingsItem * | itemFromIndex (const QModelIndex &index) const |
| Converts the model index to the item at that index. | |
| QModelIndex | parent (const QModelIndex &index) const |
| Returns a parent model index for the given index. | |
| int | rowCount (const QModelIndex &parent=QModelIndex()) const |
| Returns the number of rows under the given index. | |
| bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::DisplayRole) |
| Sets the item data. | |
| QModelIndex | sibling (int row, int column, const QModelIndex &index) const |
| Gets the index of a sibling item to the given item. | |
Private Member Functions | |
| QString | dataRoleToString (int role) const |
| Gets a textual representation of the given data role. | |
| void | insertRowInternal (int row, SettingsItem *item) |
| Internal helper function for adding rows. | |
| void | reinitializeData () |
| Reinitializes the internal data structures, effectively erasing the whole data model. | |
Private Attributes | |
| QDomDocument | domDoc |
| The representation of the XML document where the settings are stored. | |
| SettingsItem * | rootItem |
| The root item of the SettingsItem hieararchy. | |
Model that stores all settings.
The setting values are internally stored in a QDomDocument and a hierarchy of SettingsItem instances is kept that points to the QDomDocument.
| int Updraft::Core::SettingsModel::columnCount | ( | const QModelIndex & | index | ) | const [inline] |
Returns the number of columns under the given index.
This is always equal to 1 in the SettingsModel.
| index | The index whose number of columns should be retrieved |
| QVariant Updraft::Core::SettingsModel::data | ( | const QModelIndex & | index, |
| int | role = Qt::DisplayRole |
||
| ) | const |
Gets the data for the given index and data role.
| index | The model index denoting the desired setting or settings group. |
| role | The data role for the data to be retrieved. |
| QString Updraft::Core::SettingsModel::dataRoleToString | ( | int | role | ) | const [private] |
Gets a textual representation of the given data role.
This representation is used when saving into the settings file.
| role | The data role whose textual representation we want. |
| QModelIndex Updraft::Core::SettingsModel::index | ( | int | row, |
| int | column, | ||
| const QModelIndex & | parent = QModelIndex() |
||
| ) | const |
Gets the index for the desired SettingsItem.
| row | The row index of the desired item. |
| column | The column index of the desired item. |
| parent | The parent of the desired item. |
| QModelIndex Updraft::Core::SettingsModel::indexFromItem | ( | SettingsItem * | item | ) | const |
Looks up the model index for a given SettingsItem.
| item | The item whose QModelIndex should be returned. |
| bool Updraft::Core::SettingsModel::insertRow | ( | int | row, |
| const QModelIndex & | parent = QModelIndex() |
||
| ) |
Inserts a row into the model under the given parent item.
| row | The row index of the row to be inserted. |
| parent | The model index of the parent item. |
| void Updraft::Core::SettingsModel::insertRowInternal | ( | int | row, |
| SettingsItem * | item | ||
| ) | [private] |
Internal helper function for adding rows.
| row | The row index of the new row. |
| item | The SettingsItem under which we want the row to be added. |
| void Updraft::Core::SettingsModel::itemChanged | ( | SettingsItem * | item | ) | [signal] |
Signals that an item's data changed.
| item | The item whose data was changed |
| SettingsItem * Updraft::Core::SettingsModel::itemFromIndex | ( | const QModelIndex & | index | ) | const |
Converts the model index to the item at that index.
| index | The model index of the item to be retrieved. |
| void Updraft::Core::SettingsModel::loadSettings | ( | QString | filename | ) |
Loads settings from a xml settings file.
If the file does not exist, the application attempts to create it.
| filename | Path to the settings file. |
| QModelIndex Updraft::Core::SettingsModel::parent | ( | const QModelIndex & | index | ) | const |
Returns a parent model index for the given index.
| index | The model index whose parent we want. |
| void Updraft::Core::SettingsModel::reinitializeData | ( | ) | [private] |
Reinitializes the internal data structures, effectively erasing the whole data model.
| int Updraft::Core::SettingsModel::rowCount | ( | const QModelIndex & | parent = QModelIndex() | ) | const |
Returns the number of rows under the given index.
| parent | The index whose number of rows we want. |
| void Updraft::Core::SettingsModel::saveSettings | ( | QString | filename | ) |
Saves the settings to a settings file.
| filename | Path to the settings file. |
| bool Updraft::Core::SettingsModel::setData | ( | const QModelIndex & | index, |
| const QVariant & | value, | ||
| int | role = Qt::DisplayRole |
||
| ) |
Sets the item data.
| index | The index of the item whose data we want to set. |
| value | The value to be set. |
| role | The desired data role of the data being set. |
| QModelIndex Updraft::Core::SettingsModel::sibling | ( | int | row, |
| int | column, | ||
| const QModelIndex & | index | ||
| ) | const |
Gets the index of a sibling item to the given item.
| row | Row index of the sibling. |
| column | Column index of the sibling. |
| index | The model index of the item whose sibling we want. |
QDomDocument Updraft::Core::SettingsModel::domDoc [private] |
The representation of the XML document where the settings are stored.
The root item of the SettingsItem hieararchy.