TreeModel is a type of QAbstractItemModel that has a Tree like structure. More...
#include <Optika_treemodel.hpp>
Signals | |
Public Signals | |
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... | |
Public Member Functions | |
Constructors/Destructor | |
TreeModel (RCP< ParameterList > validParameters, RCP< DependencySheet > dependencySheet=null, QString saveFileName=QString(), QObject *parent=0) | |
Constructs the TreeModel. More... | |
~TreeModel () | |
Deconstructor for the TreeModel. | |
Overridden from 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 |
Helper Functions | |
void | issueInitilizationSignals () |
Issues any signals that need to be emitted right away. More... | |
Debug Functions | |
void | printOut () const |
Prints out the model. | |
Input/Output Functions | |
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... | |
Getters and Setters | |
QString | getSaveFileName () |
Gets the name of the save file with which the TreeModel is associated. More... | |
bool | isSaved () |
Determines wether or not the current state of TreeModel has been saved. More... | |
void | setIsSaved () |
Set save state to true. | |
void | reset () |
Resets all the inputs to their default values. | |
QString | itemType (const QModelIndex &index) const |
Returns the type of item located at the specified QModelIndex. More... | |
bool | hasDependencies () |
Determines whether or not a Dependent Parameter List is being used in the TreeModel. More... | |
bool | hasValidValue (QModelIndex valueToCheck) const |
Determines whether or not the value at the valueToCheck is valid. More... | |
RCP< const ParameterEntryValidator > | getValidator (const QModelIndex &index) const |
Gets the validator for a particular TreeItem. More... | |
template<class S > | |
Array< S > | getArray (const QModelIndex &index) |
Gets the array for a particular TreeItem. More... | |
template<class S > | |
TwoDArray< S > | getTwoDArray (const QModelIndex &index) |
Gets the TwoDArray for a particular TreeItem. More... | |
RCP< const ParameterList > | getCurrentParameters () |
Get a ParameterList containing all of the parameters at their current settings. More... | |
QModelIndex | findParameterEntryIndex (RCP< const ParameterEntry > parameterEntry) |
Finds the index of a particular parameter entry. More... | |
Static Public Member Functions | |
Constant Getting Functions. | |
static const int | getRawDataRole () |
Returns constant representing the RawDataRole. More... | |
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.
Optika::TreeModel::TreeModel | ( | RCP< ParameterList > | validParameters, |
RCP< DependencySheet > | dependencySheet = null , |
||
QString | saveFileName = QString() , |
||
QObject * | parent = 0 |
||
) |
Constructs the TreeModel.
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. |
|
signal |
int Optika::TreeModel::columnCount | ( | const QModelIndex & | parent = QModelIndex() | ) | const |
References Optika::TreeItem::columnCount().
QVariant Optika::TreeModel::data | ( | const QModelIndex & | index, |
int | role = Qt::DisplayRole |
||
) | const |
References Optika::TreeItem::data(), and getRawDataRole().
QModelIndex Optika::TreeModel::findParameterEntryIndex | ( | RCP< const ParameterEntry > | parameterEntry | ) |
Finds the index of a particular parameter entry.
parameterEntry | The ParameterEntry whose index is being sought. |
References index().
Referenced by issueInitilizationSignals().
Qt::ItemFlags Optika::TreeModel::flags | ( | const QModelIndex & | index | ) | const |
|
inline |
RCP< const ParameterList > Optika::TreeModel::getCurrentParameters | ( | ) |
Get a ParameterList containing all of the parameters at their current settings.
|
inlinestatic |
Returns constant representing the RawDataRole.
Referenced by data(), and Optika::TreeItem::data().
QString Optika::TreeModel::getSaveFileName | ( | ) |
|
inline |
RCP< const ParameterEntryValidator > Optika::TreeModel::getValidator | ( | const QModelIndex & | index | ) | const |
bool Optika::TreeModel::hasDependencies | ( | ) |
Determines whether or not a Dependent Parameter List is being used in the TreeModel.
Referenced by Optika::TreeView::TreeView().
bool Optika::TreeModel::hasValidValue | ( | QModelIndex | valueToCheck | ) | const |
Determines whether or not the value at the valueToCheck is valid.
valueToCheck | The index of the item whose valididty is in questions. |
References Optika::TreeItem::hasValidValue().
QVariant Optika::TreeModel::headerData | ( | int | section, |
Qt::Orientation | orientation, | ||
int | role = Qt::DisplayRole |
||
) | const |
References Optika::TreeItem::data().
|
signal |
Emitted when a row should be hidden.
row | The row of the item that should be hidden. |
parent | The parent of the item that should be hidden. |
QModelIndex Optika::TreeModel::index | ( | int | row, |
int | column, | ||
const QModelIndex & | parent = QModelIndex() |
||
) | const |
bool Optika::TreeModel::isSaved | ( | ) |
Determines wether or not the current state of TreeModel has been saved.
Referenced by Optika::MetaWindow::closeEvent().
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.
References findParameterEntryIndex().
Referenced by reset(), and Optika::TreeView::TreeView().
QString Optika::TreeModel::itemType | ( | const QModelIndex & | index | ) | const |
Returns the type of item located at the specified QModelIndex.
index | The index of the TreeItem. |
QModelIndex Optika::TreeModel::parent | ( | const QModelIndex & | index | ) | const |
References Optika::TreeItem::parent(), and Optika::TreeItem::row().
void Optika::TreeModel::readInput | ( | QString | fileName | ) |
int Optika::TreeModel::rowCount | ( | const QModelIndex & | parent = QModelIndex() | ) | const |
References Optika::TreeItem::childCount().
bool Optika::TreeModel::setData | ( | const QModelIndex & | index, |
const QVariant & | value, | ||
int | role = Qt::EditRole |
||
) |
|
signal |
Emitted when a row should be shown.
row | The row of the item that should be shown. |
parent | The parent of the item that should be shown. |
bool Optika::TreeModel::writeOutput | ( | QString | fileName | ) |
Writes out the state of the current parameters in xml format.
fileName | The name of the file to which the TreeModel should write the XML output. |