tuchulcha  0.10.1
Graphical Workflow Configuration Editor
ParameterFileModel Class Reference

This model serves to provide a model frontend to access a ParameterFile instance. More...

#include <ParameterFileModel.h>

Inheritance diagram for ParameterFileModel:

Public Slots

virtual void clear ()
 Clear ParameterFile content.
 
virtual bool load (const QString &fName="")
 Load model content from parameterFile. More...
 
virtual void loadMetaInfo (const QString &fileName)
 load metaFile More...
 
virtual void save (const QString &fileName="")
 Save model content to a text file. More...
 
virtual void setFileName (const QString &fileName)
 Set new value for Property _fileName. More...
 
void setHandleDynamics (bool)
 set _handleDynamics
 
void setMinPriority (int value)
 Set property _minPriority. More...
 
void setOnlyParams (bool value)
 Set property _onlyparams. More...
 
virtual QString setPrefix (const QString &prefix)
 Change prefix. More...
 
void setUseMetaInfo (bool value)
 Set property _useMetadata. More...
 

Signals

void commentChanged (QString comment)
 inform about editor comment change
 
void dynamicUpdate ()
 inform about dynamic plugin update
 
void fileNameChanged (QString fileName)
 Property _fileName has changed. More...
 
void metaInfoChanged (bool valid)
 New metadata have been loaded. More...
 
void minPriorityChanged (int value)
 Property _minPriority changed. More...
 
void modified (bool val)
 inform about modifications More...
 
void onlyParamsChanged (bool value)
 Property _onlyParams changed. More...
 
void prefixChanged (const QString &prefix)
 Property _prefix has changed. More...
 
void statusMessage (const QString &msg)
 send status message More...
 
void useMetaInfoChanged (bool value)
 Property _useMetadata changed. More...
 

Public Member Functions

 ParameterFileModel (QString fileName="", QObject *parent=0, QString metaFile="")
 Constructor initializing the model with the given file. More...
 
virtual ~ParameterFileModel ()
 Default destructor.
 
bool active () const
 Returns the bool value of the Active Parameter.
 
void deactivate ()
 Deactivate all following plugins.
 
QString fileName () const
 Get property _fileName.
 
int minPriority () const
 Get property _minPriority.
 
bool onlyParams () const
 Get property _onlyparams.
 
const QParameterFileparameterFile () const
 Get const pointer of ParameterFile.
 
QString prefix () const
 Get property _prefix.
 
bool prefixValid () const
 Check prefix.
 
void reactivate ()
 Reactivate all following plugins.
 
void reactivatePreviousPlugins ()
 Reactivates all previous plugins.
 
bool useMetaInfo () const
 Get property _useMetadata;.
 
model/view interface
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const
 Return number of table rows. More...
 
virtual int columnCount (const QModelIndex &parent=QModelIndex()) const
 Return number of table columns. More...
 
virtual QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
 Access to item content. More...
 
virtual bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
 Set item content. More...
 
virtual Qt::ItemFlags flags (const QModelIndex &index) const
 Item flags (editable etc). More...
 
virtual QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
 Data for the table headers. More...
 
virtual bool insertRows (int row, int count, const QModelIndex &parent=QModelIndex())
 Add data to the model. More...
 
virtual bool removeRows (int row, int count, const QModelIndex &parent=QModelIndex())
 Remove data from the model. More...
 
virtual Qt::DropActions supportedDropActions () const
 
virtual QStringList mimeTypes () const
 
virtual bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
 
Metadata Queries with dynamic Information
bool metaInfoValid () const
 check for available metaInfos
 
QStringList getClasses () const
 get classes contained in metadata file
 
QString getClass (QString objName, bool fixCase=false) const
 get class of some given object More...
 
QString getType (QString parName, bool applyTmplType=true) const
 Get type of some parameter or slot. More...
 
QString getDefault (QString parName) const
 pass to metaInfo, use dynamic metadata if needed
 
QString getDoc (QString parName) const
 pass to metaInfo, use dynamic metadata if needed
 
QStringList getInputs (QString objName) const
 Get input slots of object. More...
 
QStringList getInputDisplayNames (QString objName) const
 Get input slots of object. More...
 
QStringList getOutputs (QString objName) const
 Get output slots of object. More...
 
QStringList getOutputDisplayNames (QString objName) const
 Get output slots of object. More...
 
QStringList getParameters (QString objName) const
 Get parameters of object. More...
 
bool isParameter (QString name) const
 Check if some parameter/slot is a parameter. More...
 
bool isInputSlot (QString name) const
 Check if some parameter/slot is an input slot. More...
 
bool isOutputSlot (QString name) const
 Check if some parameter/slot is an output slot. More...
 
bool isMultiSlot (QString name) const
 Check if some slot is a multi slot. More...
 
QParameterFile wrapper functions
QString getValue (QString parName) const
 Get a parameter from the underlying parameter file. More...
 
void setValue (QString parName, QString value)
 Set a parameter in the underlying parameter file. More...
 
bool isSet (QString parName) const
 pass to QParameterFile::isSet
 
void erase (QString parName)
 Delete a parameter from the the underlying parameter file. More...
 
bool rename (QString oldPrefix, QString newPrefix)
 rename prefix More...
 

Protected Slots

virtual bool _load ()
 Load data without showing OpenFile Dialog. More...
 
virtual void _update ()
 Update content (e.g. when prefix has changed)
 
virtual void _updatePriority (const QModelIndex &topLeft, const QModelIndex &bottomRight)
 Update filter if priority changed.
 

Protected Attributes

QMutex * _resetMutex
 avoid multiple reset model calls
 

Properties

QString _fileName
 Store filename of the model data file.
 
int _minPriority
 minimum priority to be listed
 
bool _onlyParams
 only show configurable parameters
 
QString _prefix
 Parameter prefix.
 
bool _useMetaInfo
 toggle usage of metadata
 

Private Member Functions

QStringList _collectObjects (QStringList list) const
 Return set of objects contained in given parameter list. More...
 
QString _getDynamicMetaFile (QString objName) const
 creates path to dynamic meta info file for object
 
QStringList _paramFilter (QStringList list) const
 filter keys listed in the classes parameter section More...
 
QStringList _prefixFilter (QStringList list) const
 filter keys starting with the given prefix More...
 
QStringList _priorityFilter (QStringList list) const
 filter keys depending on their priority More...
 
QStringList _priorityTagFilter (QStringList list) const
 filter keys containing priority information More...
 
void _updateDynamics ()
 update dynamic objects
 

Private Attributes

QMap< QString, QString > _classCaseMap
 map to fix class name cases
 
bool _handleDynamics
 handle dynamics by calling update-dynamics process
 
QStringList _keys
 Cache stored parameter names.
 
const MetaData_metaInfos
 ParameterFile describing classes and in-/output slots.
 
QParameterFile_parameterFile
 Pointer to the ParameterFile instance storing the model content.
 

Detailed Description

It can be used in a TableView.

Definition at line 37 of file ParameterFileModel.h.

Constructor & Destructor Documentation

ParameterFileModel::ParameterFileModel ( QString  fileName = "",
QObject *  parent = 0,
QString  metaFile = "" 
)
Parameters
parentparent QObject passed to inherited constructor.
fileNamefilename of the textfile to load.
metaFileParameterFile describing classes and in-/outputs

Definition at line 44 of file ParameterFileModel.cpp.

References _fileName, _load(), _updatePriority(), loadMetaInfo(), and setOnlyParams().

Member Function Documentation

QStringList ParameterFileModel::_collectObjects ( QStringList  list) const
private
Parameters
listparameter list
Returns
set of objects (no duplicates)

Definition at line 863 of file ParameterFileModel.cpp.

bool ParameterFileModel::_load ( )
protectedvirtualslot
Return values
falseerror during load

Definition at line 646 of file ParameterFileModel.cpp.

References _fileName, _parameterFile, _resetMutex, _update(), _updateDynamics(), clear(), QParameterFile::load(), and statusMessage().

QStringList ParameterFileModel::_paramFilter ( QStringList  list) const
private
Parameters
listlist to filter
Returns
filtered list (only parameters)

Definition at line 872 of file ParameterFileModel.cpp.

References _collectObjects(), _onlyParams, and getParameters().

QStringList ParameterFileModel::_prefixFilter ( QStringList  list) const
private
Parameters
listlist to filter
Returns
filtered list (only with given prefix)

Definition at line 851 of file ParameterFileModel.cpp.

References _prefix, and prefixValid().

QStringList ParameterFileModel::_priorityFilter ( QStringList  list) const
private
Parameters
listlist to filter
Returns
filtered list

Definition at line 901 of file ParameterFileModel.cpp.

References _minPriority, and getValue().

QStringList ParameterFileModel::_priorityTagFilter ( QStringList  list) const
private
Parameters
listlist to filter
Returns
filtered list (no *.editorpriority keys)

Definition at line 891 of file ParameterFileModel.cpp.

int ParameterFileModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
virtual
Parameters
parentindex of parent item
Returns
number of columns (currently always 2)

Definition at line 82 of file ParameterFileModel.cpp.

QVariant ParameterFileModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const
virtual

Returns data specific to the given role (display, icon, ...)

Parameters
indexitem index
roledisplay role
Returns
data encapsuled in a QVariant

Definition at line 86 of file ParameterFileModel.cpp.

References _keys, _metaInfos, _onlyParams, _parameterFile, _prefix, _useMetaInfo, QParameterFile::get(), getClass(), getDefault(), MetaData::getDocString(), getType(), getValue(), VarTypeMap::instance(), isParameter(), QParameterFile::isSet(), isSet(), and type().

void ParameterFileModel::erase ( QString  parName)
Parameters
parNamename of the parameter

Definition at line 984 of file ParameterFileModel.cpp.

References _keys, _parameterFile, QParameterFile::isSet(), and modified().

void ParameterFileModel::fileNameChanged ( QString  fileName)
signal
Parameters
fileNamenew value
Qt::ItemFlags ParameterFileModel::flags ( const QModelIndex &  index) const
virtual
Parameters
indexitem index
Returns
flags of current item

Definition at line 460 of file ParameterFileModel.cpp.

References _keys, _onlyParams, _useMetaInfo, data(), getType(), isParameter(), and prefixValid().

QString ParameterFileModel::getClass ( QString  objName,
bool  fixCase = false 
) const
Parameters
objNamename of the object
fixCaseclass list lookup to get name case right
Returns
empty string if class is unknown

Definition at line 842 of file ParameterFileModel.cpp.

References _classCaseMap, and getValue().

QStringList ParameterFileModel::getInputDisplayNames ( QString  objName) const
Parameters
objNamename of the object
Returns
name of input slots

Definition at line 1082 of file ParameterFileModel.cpp.

References _getDynamicMetaFile(), _metaInfos, getClass(), MetaData::getInputDisplayNames(), and MetaData::isDynamic().

QStringList ParameterFileModel::getInputs ( QString  objName) const
Parameters
objNamename of the object
Returns
name of input slots

Definition at line 1069 of file ParameterFileModel.cpp.

References _getDynamicMetaFile(), _metaInfos, getClass(), MetaData::getInputs(), and MetaData::isDynamic().

QStringList ParameterFileModel::getOutputDisplayNames ( QString  objName) const
Parameters
objNamename of the object
Returns
name of output slots

Definition at line 1108 of file ParameterFileModel.cpp.

References _getDynamicMetaFile(), _metaInfos, getClass(), MetaData::getOutputDisplayNames(), and MetaData::isDynamic().

QStringList ParameterFileModel::getOutputs ( QString  objName) const
Parameters
objNamename of the object
Returns
name of output slots

Definition at line 1095 of file ParameterFileModel.cpp.

References _getDynamicMetaFile(), _metaInfos, getClass(), MetaData::getOutputs(), and MetaData::isDynamic().

QStringList ParameterFileModel::getParameters ( QString  objName) const
Parameters
objNamename of the object
Returns
name of parameters

Definition at line 1122 of file ParameterFileModel.cpp.

References _getDynamicMetaFile(), _metaInfos, getClass(), MetaData::getParameters(), and MetaData::isDynamic().

QString ParameterFileModel::getType ( QString  parName,
bool  applyTmplType = true 
) const

This also handles presence of some template parameters.

Parameters
parNamename of the parameter
applyTmplTypereplace template parameter by selected type
Returns
parameter/slot type

Definition at line 914 of file ParameterFileModel.cpp.

References _getDynamicMetaFile(), _metaInfos, _useMetaInfo, QParameterFile::get(), getClass(), getDefault(), MetaData::getType(), getValue(), and MetaData::isDynamic().

QString ParameterFileModel::getValue ( QString  parName) const
Parameters
parNamename of the parameter
Returns
QParameterFile parameter value

Definition at line 946 of file ParameterFileModel.cpp.

References _parameterFile.

QVariant ParameterFileModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const
virtual
Parameters
sectionrow/column number
orientationhorizontal or vertical header
roledisplay role
Returns
data encapsuled in a QVariant

Definition at line 514 of file ParameterFileModel.cpp.

bool ParameterFileModel::insertRows ( int  row,
int  count,
const QModelIndex &  parent = QModelIndex() 
)
virtual
Parameters
rowrow to prepend the new rows to
countnumber of rows to append
parentparent item (here unused)
Returns
sucess of the operation
Remarks
Only appending is allowed!

Definition at line 530 of file ParameterFileModel.cpp.

References _keys, _minPriority, _onlyParams, _parameterFile, _prefix, _prefixFilter(), _priorityFilter(), _priorityTagFilter(), QParameterFile::getKeyList(), QParameterFile::isSet(), prefixValid(), and setValue().

bool ParameterFileModel::isInputSlot ( QString  name) const
Parameters
namename of the slot
Return values
truegiven object is an input slot

Definition at line 1142 of file ParameterFileModel.cpp.

References getInputs().

bool ParameterFileModel::isMultiSlot ( QString  name) const
Parameters
namename of the slot
Return values
trueslot may have multiple targets

Definition at line 1156 of file ParameterFileModel.cpp.

References _getDynamicMetaFile(), _metaInfos, getClass(), MetaData::isDynamic(), and MetaData::isMultiSlot().

bool ParameterFileModel::isOutputSlot ( QString  name) const
Parameters
namename of the slot
Return values
truegiven object is an output slot

Definition at line 1149 of file ParameterFileModel.cpp.

References getOutputs().

bool ParameterFileModel::isParameter ( QString  name) const
Parameters
namename of the parameter/slot
Return values
truegiven object is a parameter

Definition at line 1135 of file ParameterFileModel.cpp.

References getParameters().

bool ParameterFileModel::load ( const QString &  fName = "")
virtualslot

Shows OpenFile Dialog and loads the selected file.

Parameters
fNamefile to load, shows OpenFile dialog if empty.
Return values
falseerror during load

Definition at line 693 of file ParameterFileModel.cpp.

References _fileName, _load(), setFileName(), and statusMessage().

void ParameterFileModel::loadMetaInfo ( const QString &  fileName)
virtualslot
Parameters
fileNamefilename to load from

Definition at line 782 of file ParameterFileModel.cpp.

References _classCaseMap, _metaInfos, MetaData::getClasses(), metaInfoChanged(), and setUseMetaInfo().

void ParameterFileModel::metaInfoChanged ( bool  valid)
signal
Parameters
validtrue, if metadata are valid
void ParameterFileModel::minPriorityChanged ( int  value)
signal
Parameters
valuenew value
void ParameterFileModel::modified ( bool  val)
signal
Parameters
valnew modification status
void ParameterFileModel::onlyParamsChanged ( bool  value)
signal
Parameters
valuenew value
void ParameterFileModel::prefixChanged ( const QString &  prefix)
signal
Parameters
prefixnew value
bool ParameterFileModel::removeRows ( int  row,
int  count,
const QModelIndex &  parent = QModelIndex() 
)
virtual
Parameters
rowfirst row to delete
countnumber of rows to append
parentparent item (here unused)
Returns
sucess of the operation
Remarks
Only removing the tail is allowed!

Reimplemented in GraphModel.

Definition at line 575 of file ParameterFileModel.cpp.

References _keys, _onlyParams, _parameterFile, _prefix, QParameterFile::erase(), QParameterFile::getKeyList(), isSet(), and prefixValid().

bool ParameterFileModel::rename ( QString  oldPrefix,
QString  newPrefix 
)

renames all keys starting with oldPrefix to ones with the given new prefix and also renames occurrences of the oldPrefix in values of other parameters (like slot connections)

The new prefix must match the rules for parameter file prefixes (as specified in QParameterFile::prefixCheck ). The old prefix is not checked, if there are dots, the part before the dots is used. In the worst case, there are no occurrences of an invalid keys which causes the function to return and skip the parameter renaming.

Parameters
oldPrefixold prefix
newPrefixnew prefix (checks for valid prefix)
Return values
truerenaming successful
falsesome error occured, nothing changed at all

Definition at line 998 of file ParameterFileModel.cpp.

References _parameterFile, _resetMutex, modified(), QParameterFile::rename(), and setPrefix().

int ParameterFileModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
virtual
Parameters
parentindex of parent item
Returns
number of rows

Definition at line 78 of file ParameterFileModel.cpp.

References _keys.

void ParameterFileModel::save ( const QString &  fileName = "")
virtualslot

When filename is empty, the old filename will be used (if avaiable). When filename is given, the internal filename will be overwritten.

Parameters
fileNamename of the file to store

Definition at line 731 of file ParameterFileModel.cpp.

References _fileName, _parameterFile, modified(), QParameterFile::save(), setFileName(), and statusMessage().

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

Overwrite the current value with the given one.

Parameters
indexitem index
valuenew value to set
roledisplay role
Return values
truedata successfully set
falsefailure setting value

Reimplemented in GraphModel.

Definition at line 212 of file ParameterFileModel.cpp.

References _keys, _metaInfos, _onlyParams, _parameterFile, _prefix, _update(), _updateDynamics(), _useMetaInfo, deactivate(), dynamicUpdate(), erase(), getClass(), getType(), getValue(), MetaData::isDynamic(), isParameter(), QParameterFile::isSet(), isSet(), prefixValid(), reactivatePreviousPlugins(), save(), and setValue().

void ParameterFileModel::setFileName ( const QString &  fileName)
virtualslot
Parameters
fileNamenew value for _fileName

Definition at line 748 of file ParameterFileModel.cpp.

References _fileName, and fileNameChanged().

void ParameterFileModel::setMinPriority ( int  value)
slot
Parameters
valuenew value to set

Definition at line 1016 of file ParameterFileModel.cpp.

References _minPriority, _update(), and minPriorityChanged().

void ParameterFileModel::setOnlyParams ( bool  value)
slot
Parameters
valuenew value to set

Definition at line 832 of file ParameterFileModel.cpp.

References _onlyParams, _update(), _useMetaInfo, onlyParamsChanged(), and setUseMetaInfo().

QString ParameterFileModel::setPrefix ( const QString &  prefix)
virtualslot
Parameters
prefixnew prefix
Returns
previous prefix

Definition at line 755 of file ParameterFileModel.cpp.

References _prefix, _update(), and prefixChanged().

void ParameterFileModel::setUseMetaInfo ( bool  value)
slot
Parameters
valuenew value to set

Definition at line 808 of file ParameterFileModel.cpp.

References _onlyParams, _useMetaInfo, rowCount(), setOnlyParams(), and useMetaInfoChanged().

void ParameterFileModel::setValue ( QString  parName,
QString  value 
)
Parameters
parNamename of the parameter
valuenew value of the parameter

Definition at line 954 of file ParameterFileModel.cpp.

References _parameterFile, _update(), commentChanged(), getValue(), isSet(), and modified().

void ParameterFileModel::statusMessage ( const QString &  msg)
signal
Parameters
msgmessage
void ParameterFileModel::useMetaInfoChanged ( bool  value)
signal
Parameters
valuenew value

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