Optika GUI Toolik Version of the Day
Signals | Public Member Functions | Private Slots | Private Member Functions | Private Attributes
Optika::TreeModel Class Reference

#include <Optika_treemodel.hpp>

List of all members.

Signals

void hideData (int row, const QModelIndex &parent)
void showData (int row, const QModelIndex &parent)
void badValue (QModelIndex badItem, QString message)

Public Member Functions

 TreeModel (Teuchos::RCP< Teuchos::ParameterList > validParameters, QString saveFileName=QString(), QObject *parent=0)
 TreeModel (Teuchos::RCP< Teuchos::ParameterList > validParameters, Teuchos::RCP< Optika::DependencySheet > dependencySheet, QString saveFileName=QString(), QObject *parent=0)
 ~TreeModel ()
QVariant data (const QModelIndex &index, int role) 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
void issueInitilizationSignals ()
void printOut () const
bool writeOutput (QString fileName)
void readInput (QString fileName)
QString getSaveFileName ()
bool isSaved ()
void reset ()
QString itemType (const QModelIndex &index) const
bool hasDependencies ()
bool hasValidValue (QModelIndex valueToCheck) const
Teuchos::RCP< const
Teuchos::ParameterEntryValidator
getValidator (const QModelIndex &index) const
template<class S >
Teuchos::Array< S > getArray (const QModelIndex &index)
Teuchos::RCP< const
Teuchos::ParameterList
getCurrentParameters ()

Private Slots

void currentFileNowModified ()
void dataChangedListener (const QModelIndex &index1, const QModelIndex &index2)

Private Member Functions

QModelIndex findParameterEntryIndex (const Teuchos::ParameterEntry *parameterEntry, std::string parameterName)
const Teuchos::ParameterEntryitemEntry (const QModelIndex &index) const
void readInParameterList (Teuchos::RCP< Teuchos::ParameterList > validParameters, TreeItem *parentItem)
void insertParameterList (Teuchos::RCP< Teuchos::ParameterList > parameterList, Teuchos::ParameterEntry *listEntry, std::string name, TreeItem *parent)
void insertParameter (Teuchos::ParameterEntry *parameter, std::string name, TreeItem *parent)
void basicSetup (QString saveFileName)
void checkDependentState (const QModelIndex dependee, Teuchos::RCP< Dependency > dependency)
void redrawArray (const QModelIndex arrayIndex)

Private Attributes

bool saved
bool dependencies
QString saveFileName
TreeItemrootItem
Teuchos::RCP
< Teuchos::ParameterList
validParameters
Teuchos::RCP< const
Teuchos::ParameterList
canonicalList
Teuchos::RCP
< Optika::DependencySheet
dependencySheet

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.

Definition at line 55 of file Optika_treemodel.hpp.


Constructor & Destructor Documentation

Optika::TreeModel::TreeModel ( Teuchos::RCP< Teuchos::ParameterList validParameters,
QString  saveFileName = QString(),
QObject *  parent = 0 
)

Constructs the TreeModel.

Parameters:
validParametersA list of parameters for which the users must enter values. Note the Parameter List will be edited. All user input will be stored in it.
saveFileNameName of a save file used in a previous attempt to get values for the validParameters ParameterList.
parentThe parent object.

Definition at line 36 of file Optika_treemodel.cpp.

Optika::TreeModel::TreeModel ( Teuchos::RCP< Teuchos::ParameterList validParameters,
Teuchos::RCP< Optika::DependencySheet dependencySheet,
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.

Definition at line 44 of file Optika_treemodel.cpp.

Optika::TreeModel::~TreeModel ( )

Deconstructor for the TreeModel.

Definition at line 56 of file Optika_treemodel.cpp.


Member Function Documentation

QVariant Optika::TreeModel::data ( const QModelIndex &  index,
int  role 
) const

Definition at line 60 of file Optika_treemodel.cpp.

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

Definition at line 71 of file Optika_treemodel.cpp.

QVariant Optika::TreeModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const

Definition at line 83 of file Optika_treemodel.cpp.

QModelIndex Optika::TreeModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const

Definition at line 90 of file Optika_treemodel.cpp.

QModelIndex Optika::TreeModel::parent ( const QModelIndex &  index) const

Definition at line 110 of file Optika_treemodel.cpp.

bool Optika::TreeModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
)

Definition at line 125 of file Optika_treemodel.cpp.

int Optika::TreeModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const

Definition at line 136 of file Optika_treemodel.cpp.

int Optika::TreeModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const

Definition at line 152 of file Optika_treemodel.cpp.

void Optika::TreeModel::issueInitilizationSignals ( )

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 161 of file Optika_treemodel.cpp.

void Optika::TreeModel::printOut ( ) const

Prints out the model.

Definition at line 168 of file Optika_treemodel.cpp.

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.

Definition at line 172 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:
fileNameThe name of the file from which the TreeModel should read parameter values.

Definition at line 189 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 210 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 214 of file Optika_treemodel.cpp.

void Optika::TreeModel::reset ( )

Resets all the inputs to their default values.

Definition at line 218 of file Optika_treemodel.cpp.

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.

Definition at line 239 of file Optika_treemodel.cpp.

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.

Definition at line 245 of file Optika_treemodel.cpp.

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.

Definition at line 249 of file Optika_treemodel.cpp.

Teuchos::RCP< const Teuchos::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.

Definition at line 254 of file Optika_treemodel.cpp.

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

Gets the array for a particular TreeItem.

Parameters:
indexThe index of the TreeItem whose arrays is sought.
Returns:
The array at the given index.

Definition at line 183 of file Optika_treemodel.hpp.

Teuchos::RCP< const Teuchos::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.

Definition at line 258 of file Optika_treemodel.cpp.

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.
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.
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.
QModelIndex Optika::TreeModel::findParameterEntryIndex ( const Teuchos::ParameterEntry parameterEntry,
std::string  parameterName 
) [private]

Finds the index of a particular parameter entry.

Parameters:
parameterEntryThe ParameterEntry whose index is being sought.
parameterNameThe name of the parameter whose index is being sought.

Definition at line 262 of file Optika_treemodel.cpp.

const Teuchos::ParameterEntry * Optika::TreeModel::itemEntry ( const QModelIndex &  index) const [private]

Gets the ParameterEntry object given a QModelIndex.

Parameters:
indexIndex of the TreeItem for which the ParameterEntry is desired.
Returns:
The ParameterEntry associated with the QModelIndex.

Definition at line 275 of file Optika_treemodel.cpp.

void Optika::TreeModel::readInParameterList ( Teuchos::RCP< Teuchos::ParameterList validParameters,
TreeItem parentItem 
) [private]

Reads in the parameter list to be represented by the model.

Parameters:
validParametersThe list to be read.
parentItemThe initial parent tree item to be used.

Definition at line 280 of file Optika_treemodel.cpp.

void Optika::TreeModel::insertParameterList ( Teuchos::RCP< Teuchos::ParameterList parameterList,
Teuchos::ParameterEntry listEntry,
std::string  name,
TreeItem parent 
) [private]

Inserts a new parameter list into the model.

Parameters:
parameterListThe ParameterList to be inserted.
listEntryThe ParameterEntry of the ParameterList to be inserted.
nameThe name of the ParameterList.
Theparent TreeItem.

Definition at line 292 of file Optika_treemodel.cpp.

void Optika::TreeModel::insertParameter ( Teuchos::ParameterEntry parameter,
std::string  name,
TreeItem parent 
) [private]

Inserts a new parameter into the model.

Parameters:
listEntryThe ParameterEntry of the Parameter to be inserted.
nameThe name of the Parameter.
Theparent TreeItem.

Definition at line 310 of file Optika_treemodel.cpp.

void Optika::TreeModel::basicSetup ( QString  saveFileName) [private]

Basic setup shared by each of the constructors

Parameters:
saveFileNameThe saveFileName parameter passed to the constructors.

Definition at line 363 of file Optika_treemodel.cpp.

void Optika::TreeModel::checkDependentState ( const QModelIndex  dependee,
Teuchos::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 379 of file Optika_treemodel.cpp.

void Optika::TreeModel::redrawArray ( const QModelIndex  arrayIndex) [private]

Redraws the array at arrayIndex if it's length has changed.

Parameters:
arrayIndexThe index of the array to be redrawn.

Definition at line 405 of file Optika_treemodel.cpp.

void Optika::TreeModel::currentFileNowModified ( ) [private, slot]

When the state of any of the MainTree's items is changed, this slot should be called

Definition at line 415 of file Optika_treemodel.cpp.

void Optika::TreeModel::dataChangedListener ( const QModelIndex &  index1,
const QModelIndex &  index2 
) [private, slot]

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:
index1The start index of the data that changed.
index2The end index of the data that changed.

Definition at line 419 of file Optika_treemodel.cpp.


Member Data Documentation

bool Optika::TreeModel::saved [private]

Whether or not the model has been saved since it was last modified.

Definition at line 223 of file Optika_treemodel.hpp.

Whether or not the model has any dependencies.

Definition at line 228 of file Optika_treemodel.hpp.

The name of the savefile associated with the model.

Definition at line 233 of file Optika_treemodel.hpp.

The Root item of the model.

Definition at line 238 of file Optika_treemodel.hpp.

The list of valid parameters.

Definition at line 243 of file Optika_treemodel.hpp.

A canonical list of what the validParameters were when they were first passed to the treemodel. Used by the reset function.

Definition at line 249 of file Optika_treemodel.hpp.

The dependency sheet being used to determine any depdendencies between parameters.

Definition at line 255 of file Optika_treemodel.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends