TreeModel is a type of QAbstractItemModel that has a Tree like structure.
More...
#include <Optika_treemodel.hpp>
Inherits QAbstractItemModel.
|
QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const |
|
Qt::ItemFlags | flags (const QModelIndex &index) const |
|
QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const |
|
QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const |
|
QModelIndex | parent (const QModelIndex &index) const |
|
bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) |
|
int | rowCount (const QModelIndex &parent=QModelIndex()) const |
|
int | columnCount (const QModelIndex &parent=QModelIndex()) const |
|
|
bool | writeOutput (QString fileName) |
| Writes out the state of the current parameters in xml format. More...
|
|
void | readInput (QString fileName) |
| Reads an xml file that describes the state of current parameters in xml format. More...
|
|
|
void | hideData (int row, const QModelIndex &parent) |
| Emitted when a row should be hidden. More...
|
|
void | showData (int row, const QModelIndex &parent) |
| Emitted when a row should be shown. More...
|
|
void | badValue (QModelIndex badItem, QString message) |
| Emitted when it has been determined that a TreeItem no longer has a valid value. More...
|
|
|
RCP< const ParameterEntry > | itemEntry (const QModelIndex &index) const |
| Gets the ParameterEntry object given a QModelIndex. More...
|
|
void | readInParameterList (RCP< ParameterList > validParameters, TreeItem *parentItem) |
| Reads in the parameter list to be represented by the model. More...
|
|
void | insertParameterList (RCP< ParameterList > parameterList, RCP< ParameterEntry > listEntry, std::string plname, TreeItem *parent) |
| Inserts a new parameter list into the model. More...
|
|
void | insertParameter (RCP< ParameterEntry > parameter, std::string name, TreeItem *parent) |
| Inserts a new parameter into the model. More...
|
|
void | basicSetup (QString saveFileName) |
| Basic setup shared by each of the constructors. More...
|
|
void | checkDependentState (const QModelIndex dependee, RCP< Dependency > dependency) |
| Checks the state of a dependent after it's dependency has been evaluated. More...
|
|
QModelIndex | parameterEntryMatch (const QModelIndex &start, const RCP< const ParameterEntry > ¶meterEntry) const |
| Finds the QModelIndex associated with a parameter entry. More...
|
|
void | processInputElement (const QDomElement &element) |
| Given a Dom element, searches for the corresponding parameter in the model, updates it's value with the value from the Dom element, and then recusively does the same for all children. More...
|
|
bool | isRealMatch (const QDomElement &element, const QModelIndex &potentialMatch) const |
| Determines whether or not a model index corresponds to the parameter represented by the DomElement. More...
|
|
bool | isRootIndex (const QModelIndex &index) const |
|
TreeModel is a type of QAbstractItemModel that has a Tree like structure.
Note: For all undocumented functions, please refer to the Qt api. They will have a good desciption.
Definition at line 66 of file Optika_treemodel.hpp.
Optika::TreeModel::TreeModel |
( |
RCP< ParameterList > |
validParameters, |
|
|
RCP< DependencySheet > |
dependencySheet = null , |
|
|
QString |
saveFileName = QString() , |
|
|
QObject * |
parent = 0 |
|
) |
| |
Constructs the TreeModel.
- Parameters
-
validParameters | A list of parameters for which the users must enter values. |
dependencySheet | A sheet listing any dependencies between parameters in the validParameters ParameterList. |
saveFileName | Name of a save file used in a previous attempt to get values for the validParameters ParameterList. |
parent | The parent object. |
Definition at line 51 of file Optika_treemodel.cpp.
Optika::TreeModel::~TreeModel |
( |
| ) |
|
QVariant Optika::TreeModel::data |
( |
const QModelIndex & |
index, |
|
|
int |
role = Qt::DisplayRole |
|
) |
| const |
Qt::ItemFlags Optika::TreeModel::flags |
( |
const QModelIndex & |
index | ) |
const |
QVariant Optika::TreeModel::headerData |
( |
int |
section, |
|
|
Qt::Orientation |
orientation, |
|
|
int |
role = Qt::DisplayRole |
|
) |
| const |
QModelIndex Optika::TreeModel::index |
( |
int |
row, |
|
|
int |
column, |
|
|
const QModelIndex & |
parent = QModelIndex() |
|
) |
| const |
QModelIndex Optika::TreeModel::parent |
( |
const QModelIndex & |
index | ) |
const |
bool Optika::TreeModel::setData |
( |
const QModelIndex & |
index, |
|
|
const QVariant & |
value, |
|
|
int |
role = Qt::EditRole |
|
) |
| |
int Optika::TreeModel::rowCount |
( |
const QModelIndex & |
parent = QModelIndex() | ) |
const |
int Optika::TreeModel::columnCount |
( |
const QModelIndex & |
parent = QModelIndex() | ) |
const |
void Optika::TreeModel::issueInitilizationSignals |
( |
| ) |
|
Issues any signals that need to be emitted right away.
If this TreeModel has a dependent Parameter List, then all the depndencies need to be evaluated before the Parameter List may be displayed. Certain items might need to be hidden before the user even starts entering data. This function goes through all of the depndees in the Dependent Parameter List and issues a signal saying they've changed. They really haven't changed yet, but this allows all the depndencies to be evaluated and any initial visual settings to be displayed correctly.
Definition at line 179 of file Optika_treemodel.cpp.
void Optika::TreeModel::printOut |
( |
| ) |
const |
bool Optika::TreeModel::writeOutput |
( |
QString |
fileName | ) |
|
Writes out the state of the current parameters in xml format.
- Parameters
-
fileName | The name of the file to which the TreeModel should write the XML output. |
Definition at line 206 of file Optika_treemodel.cpp.
void Optika::TreeModel::readInput |
( |
QString |
fileName | ) |
|
Reads an xml file that describes the state of current parameters in xml format.
- Parameters
-
fileName | The name of the file from which the TreeModel should read parameter values. |
Definition at line 287 of file Optika_treemodel.cpp.
QString Optika::TreeModel::getSaveFileName |
( |
| ) |
|
Gets the name of the save file with which the TreeModel is associated.
If the TreeModel has yet to be saved and thus has no save file associated with it, the funtion will return an empty string.
- Returns
- The name of the save file with which the TreeModel is associated.
Definition at line 302 of file Optika_treemodel.cpp.
bool Optika::TreeModel::isSaved |
( |
| ) |
|
Determines wether or not the current state of TreeModel has been saved.
- Returns
- True if the current state of the TreeModel has been saved. False otherwise.
Definition at line 306 of file Optika_treemodel.cpp.
void Optika::TreeModel::setIsSaved |
( |
| ) |
|
|
inline |
void Optika::TreeModel::reset |
( |
| ) |
|
QString Optika::TreeModel::itemType |
( |
const QModelIndex & |
index | ) |
const |
Returns the type of item located at the specified QModelIndex.
- Parameters
-
- Returns
- The type of the item at the index.
Definition at line 330 of file Optika_treemodel.cpp.
bool Optika::TreeModel::hasDependencies |
( |
| ) |
|
bool Optika::TreeModel::hasValidValue |
( |
QModelIndex |
valueToCheck | ) |
const |
Determines whether or not the value at the valueToCheck is valid.
- Parameters
-
valueToCheck | The index of the item whose valididty is in questions. |
- Returns
- True if the value at index is valid, false otherwise.
Definition at line 340 of file Optika_treemodel.cpp.
Gets the validator for a particular TreeItem.
- Parameters
-
index | The index of the TreeItem whose validators is sought. |
- Returns
- The validator at the given index.
Definition at line 345 of file Optika_treemodel.cpp.
template<class S >
Array<S> Optika::TreeModel::getArray |
( |
const QModelIndex & |
index | ) |
|
|
inline |
Gets the array for a particular TreeItem.
- Parameters
-
index | The index of the TreeItem whose array is sought. |
- Returns
- The array at the given index.
Definition at line 229 of file Optika_treemodel.hpp.
template<class S >
TwoDArray<S> Optika::TreeModel::getTwoDArray |
( |
const QModelIndex & |
index | ) |
|
|
inline |
Gets the TwoDArray for a particular TreeItem.
- Parameters
-
index | The index of the TreeItem whose TwoDArray is sought. |
- Returns
- The TwoDArray at the given index.
Definition at line 240 of file Optika_treemodel.hpp.
Get a ParameterList containing all of the parameters at their current settings.
- Returns
- A ParameterList containing all of the parameters at their current settings.
Definition at line 349 of file Optika_treemodel.cpp.
QModelIndex Optika::TreeModel::findParameterEntryIndex |
( |
RCP< const ParameterEntry > |
parameterEntry | ) |
|
Finds the index of a particular parameter entry.
- Parameters
-
parameterEntry | The ParameterEntry whose index is being sought. |
Definition at line 380 of file Optika_treemodel.cpp.
static const int Optika::TreeModel::getRawDataRole |
( |
| ) |
|
|
inlinestatic |
Returns constant representing the RawDataRole.
- Returns
- The constant representing the RawDataRole.
Definition at line 268 of file Optika_treemodel.hpp.
void Optika::TreeModel::hideData |
( |
int |
row, |
|
|
const QModelIndex & |
parent |
|
) |
| |
|
signal |
Emitted when a row should be hidden.
- Parameters
-
row | The row of the item that should be hidden. |
parent | The parent of the item that should be hidden. |
void Optika::TreeModel::showData |
( |
int |
row, |
|
|
const QModelIndex & |
parent |
|
) |
| |
|
signal |
Emitted when a row should be shown.
- Parameters
-
row | The row of the item that should be shown. |
parent | The parent of the item that should be shown. |
void Optika::TreeModel::badValue |
( |
QModelIndex |
badItem, |
|
|
QString |
message |
|
) |
| |
|
signal |
Emitted when it has been determined that a TreeItem no longer has a valid value.
- Parameters
-
badItem | The index of the item that now has a bad value. |
message | A message describing what happened to cause the item to obtain an invalid value. |
RCP< const ParameterEntry > Optika::TreeModel::itemEntry |
( |
const QModelIndex & |
index | ) |
const |
|
private |
Gets the ParameterEntry object given a QModelIndex.
- Parameters
-
index | Index of the TreeItem for which the ParameterEntry is desired. |
- Returns
- The ParameterEntry associated with the QModelIndex.
Definition at line 388 of file Optika_treemodel.cpp.
Reads in the parameter list to be represented by the model.
- Parameters
-
validParameters | The list to be read. |
parentItem | The initial parent tree item to be used. |
Definition at line 401 of file Optika_treemodel.cpp.
Inserts a new parameter list into the model.
- Parameters
-
parameterList | The ParameterList to be inserted. |
listEntry | The ParameterEntry of the ParameterList to be inserted. |
plname | The name of the ParameterList. |
The | parent TreeItem. |
Definition at line 413 of file Optika_treemodel.cpp.
Inserts a new parameter into the model.
- Parameters
-
listEntry | The ParameterEntry of the Parameter to be inserted. |
name | The name of the Parameter. |
The | parent TreeItem. |
Definition at line 432 of file Optika_treemodel.cpp.
void Optika::TreeModel::basicSetup |
( |
QString |
saveFileName | ) |
|
|
private |
Basic setup shared by each of the constructors.
- Parameters
-
saveFileName | The saveFileName parameter passed to the constructors. |
Definition at line 436 of file Optika_treemodel.cpp.
void Optika::TreeModel::checkDependentState |
( |
const QModelIndex |
dependee, |
|
|
RCP< Dependency > |
dependency |
|
) |
| |
|
private |
Checks the state of a dependent after it's dependency has been evaluated.
Takes appropriate action if any more modifications to the model need to be made or if the view needs to know anything as a result of the change.
Definition at line 451 of file Optika_treemodel.cpp.
QModelIndex Optika::TreeModel::parameterEntryMatch |
( |
const QModelIndex & |
start, |
|
|
const RCP< const ParameterEntry > & |
parameterEntry |
|
) |
| const |
|
private |
Finds the QModelIndex associated with a parameter entry.
- Parameters
-
start | The index where we should start looking. |
parameterEntry | The parameter entry we're looking for. |
- Returns
- The index associated with the parameter entry.
Definition at line 353 of file Optika_treemodel.cpp.
void Optika::TreeModel::processInputElement |
( |
const QDomElement & |
element | ) |
|
|
private |
Given a Dom element, searches for the corresponding parameter in the model, updates it's value with the value from the Dom element, and then recusively does the same for all children.
- Parameters
-
element | The element for which the corresponding parameter in the model and it's children should be updated. |
Definition at line 250 of file Optika_treemodel.cpp.
bool Optika::TreeModel::isRealMatch |
( |
const QDomElement & |
element, |
|
|
const QModelIndex & |
potentialMatch |
|
) |
| const |
|
private |
Determines whether or not a model index corresponds to the parameter represented by the DomElement.
This funciton determines whether or not the Dom Element and the model index actually represent the same parameter by verifying they have the same set of parent nodes.
Definition at line 230 of file Optika_treemodel.cpp.
bool Optika::TreeModel::isRootIndex |
( |
const QModelIndex & |
index | ) |
const |
|
private |
Determines whether or not the given index is the root index.
- Parameters
-
- Returns
- True is the index is the root index, false otherwise.
Definition at line 224 of file Optika_treemodel.cpp.
void Optika::TreeModel::currentFileNowModified |
( |
| ) |
|
|
privateslot |
When the state of any of the MainTree's items is changed, this slot should be called.
Definition at line 481 of file Optika_treemodel.cpp.
void Optika::TreeModel::dataChangedListener |
( |
const QModelIndex & |
index1, |
|
|
const QModelIndex & |
index2 |
|
) |
| |
|
privateslot |
Listens to see if any data has changed.
If so and the item has dependencies, this function will make sure all appropriate signals are emitted, and any changes that need to be made to the model are made.
- Parameters
-
index1 | The start index of the data that changed. |
index2 | The end index of the data that changed. |
Definition at line 485 of file Optika_treemodel.cpp.
bool Optika::TreeModel::saved |
|
private |
Whether or not the model has been saved since it was last modified.
Definition at line 314 of file Optika_treemodel.hpp.
bool Optika::TreeModel::dependencies |
|
private |
QString Optika::TreeModel::saveFileName |
|
private |
A canonical list of what the validParameters were when they were first passed to the treemodel. Used by the reset function.
Definition at line 340 of file Optika_treemodel.hpp.
The dependency sheet being used to determine any depdendencies between parameters.
Definition at line 346 of file Optika_treemodel.hpp.
The documentation for this class was generated from the following files: