Optika  Development
 All Classes Files Functions Variables Typedefs Pages
List of all members
Optika::TreeModel Class Reference

TreeModel is a type of QAbstractItemModel that has a Tree like structure. More...

#include <Optika_treemodel.hpp>

Inheritance diagram for Optika::TreeModel:
Inheritance graph
[legend]
Collaboration diagram for Optika::TreeModel:
Collaboration graph
[legend]

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

Optika::TreeModel::TreeModel ( RCP< ParameterList >  validParameters,
RCP< DependencySheet >  dependencySheet = null,
QString  saveFileName = QString(),
QObject *  parent = 0 
)

Constructs the TreeModel.

Parameters
validParametersA list of parameters for which the users must enter values.
dependencySheetA sheet listing any dependencies between parameters in the validParameters ParameterList.
saveFileNameName of a save file used in a previous attempt to get values for the validParameters ParameterList.
parentThe parent object.

Member Function Documentation

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
badItemThe index of the item that now has a bad value.
messageA message describing what happened to cause the item to obtain an invalid value.

Referenced by setData().

int Optika::TreeModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
QVariant Optika::TreeModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const
QModelIndex Optika::TreeModel::findParameterEntryIndex ( RCP< const ParameterEntry >  parameterEntry)

Finds the index of a particular parameter entry.

Parameters
parameterEntryThe ParameterEntry whose index is being sought.

References index().

Referenced by issueInitilizationSignals().

Qt::ItemFlags Optika::TreeModel::flags ( const QModelIndex &  index) const

template<class S >
Array<S> Optika::TreeModel::getArray ( const QModelIndex &  index)
inline

Gets the array for a particular TreeItem.

Parameters
indexThe index of the TreeItem whose array is sought.
Returns
The array at the given index.
RCP< const ParameterList > Optika::TreeModel::getCurrentParameters ( )

Get a ParameterList containing all of the parameters at their current settings.

Returns
A ParameterList containing all of the parameters at their current settings.
static const int Optika::TreeModel::getRawDataRole ( )
inlinestatic

Returns constant representing the RawDataRole.

Returns
The constant representing the RawDataRole.

Referenced by data(), and Optika::TreeItem::data().

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.
template<class S >
TwoDArray<S> Optika::TreeModel::getTwoDArray ( const QModelIndex &  index)
inline

Gets the TwoDArray for a particular TreeItem.

Parameters
indexThe index of the TreeItem whose TwoDArray is sought.
Returns
The TwoDArray at the given index.
RCP< const ParameterEntryValidator > Optika::TreeModel::getValidator ( const QModelIndex &  index) const

Gets the validator for a particular TreeItem.

Parameters
indexThe index of the TreeItem whose validators is sought.
Returns
The validator at the given index.
bool Optika::TreeModel::hasDependencies ( )

Determines whether or not a Dependent Parameter List is being used in the TreeModel.

Returns
True if the TreeModel has dependencies, false otherwise.

Referenced by Optika::TreeView::TreeView().

bool Optika::TreeModel::hasValidValue ( QModelIndex  valueToCheck) const

Determines whether or not the value at the valueToCheck is valid.

Parameters
valueToCheckThe index of the item whose valididty is in questions.
Returns
True if the value at index is valid, false otherwise.

References Optika::TreeItem::hasValidValue().

QVariant Optika::TreeModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const
void Optika::TreeModel::hideData ( int  row,
const QModelIndex &  parent 
)
signal

Emitted when a row should be hidden.

Parameters
rowThe row of the item that should be hidden.
parentThe 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.

Returns
True if the current state of the TreeModel has been saved. False otherwise.

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.

Parameters
indexThe index of the TreeItem.
Returns
The type of the item at the index.
QModelIndex Optika::TreeModel::parent ( const QModelIndex &  index) const
void Optika::TreeModel::readInput ( QString  fileName)

Reads an xml file that describes the state of current parameters in xml format.

Parameters
fileNameThe name of the file from which the TreeModel should read parameter values.

Referenced by reset().

int Optika::TreeModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
bool Optika::TreeModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
)
void Optika::TreeModel::showData ( int  row,
const QModelIndex &  parent 
)
signal

Emitted when a row should be shown.

Parameters
rowThe row of the item that should be shown.
parentThe 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.

Parameters
fileNameThe name of the file to which the TreeModel should write the XML output.

The documentation for this class was generated from the following files: