MeVisLab Scripting Reference
MLABTree Class Reference

#include <mlabScriptWrappers.h>

Inherits QObject.

Inherited by MLABMLITree.

Public Slots

Scripting access


int getLine ()
 
int getValueLine ()
 
QString getFileName ()
 
int count ()
 
MLABTreechild (int i)
 
QStringList getAllChildNames ()
 
MLABTreeget (QString propertyName, QVariant defaultVal=QVariant())
 
QList< MLABTree * > getAll (const QString &propertyName)
 
QStringList getAllValues (const QString &propertyName, char separator=0)
 
QString getName ()
 
void setName (const QString &name)
 
QString getValue ()
 
void setValue (const QString &value)
 
QStringList getListValue ()
 
QRect getRectValue ()
 
QSize getSizeValue ()
 
bool getBoolValue ()
 
int getIntValue ()
 
int getScaledIntValue (float scaleFactor)
 
float getFloatValue ()
 
unsigned long getUlongValue ()
 
QString getValueResolveEscapes ()
 
MLABTreefindChild (const QString &name)
 
MLABTreefindChildren (const QString &name)
 
QString childValue (const QString &name)
 
MLABTreefindChildrenRecursive (const QString &name)
 
MLABTreeappend (const QString &name, const QString &value)
 
MLABTreeinsert (int idx, const QString &name, const QString &value)
 
void append (MLABTree *child)
 
void insert (int idx, MLABTree *child)
 
bool remove (MLABTree *child)
 
MLABTreedeepCopy () const
 
void printError (const QString &msg)
 
void printWarning (const QString &msg)
 
QString toString ()
 

Detailed Description

MLAB Tree element of parsed MDL files.

MLAB Tree element of parsed MDL files. The items can be created with MLAB::newTree() and can be loaded/saved via MLAB::readTreeFromFile(),MLAB::readTreeFromString() and MLAB::writeTreeToFile(), MLAB::writeTreeToString().

Member Function Documentation

◆ append [1/2]

MLABTree * MLABTree::append ( const QString & name,
const QString & value )
slot

Appends a new tree child.

◆ append [2/2]

void MLABTree::append ( MLABTree * child)
slot

Appends a given tree child.

◆ child

MLABTree * MLABTree::child ( int i)
slot

Returns the child at index i.

◆ childValue

QString MLABTree::childValue ( const QString & name)
slot

Searches for the direct child with name and returns the first encountered child's value or an empty string (search is case insensitive).

◆ count

int MLABTree::count ( )
slot

Returns count of direct children (non-recursive).

◆ deepCopy

MLABTree * MLABTree::deepCopy ( ) const
slot

Create a deep copy of the tree.

◆ findChild

MLABTree * MLABTree::findChild ( const QString & name)
slot

Searches for the direct child with name and returns the first encountered child or NULL (search is case insensitive).

◆ findChildren

MLABTree * MLABTree::findChildren ( const QString & name)
slot

Searches for the direct children with name and returns a tree which contains the found children (search is case insensitive).

◆ findChildrenRecursive

MLABTree * MLABTree::findChildrenRecursive ( const QString & name)
slot

Searches for the children with name recursively and returns a tree which contains the found children (search is case insensitive).

◆ get

MLABTree * MLABTree::get ( QString propertyName,
QVariant defaultVal = QVariant() )
slot

Returns a property by name.

Dot-notation can be used to access children. Returns first child with name propertyName.split(".")[-1]. Returns defaultVal if not found. Example: get("Interface.Inputs.Field")

◆ getAll

QList< MLABTree * > MLABTree::getAll ( const QString & propertyName)
slot

Returns all properties by name.

Dot-notation can be used to access children. Returns all children with name propertyName.split(".")[-1]. Returns defaultVal if not found.

◆ getAllChildNames

QStringList MLABTree::getAllChildNames ( )
slot

Returns a list of names of all child tree node.

◆ getAllValues

QStringList MLABTree::getAllValues ( const QString & propertyName,
char separator = 0 )
slot

Convenience function, returns the values of the tree nodes returned by getAll.

If separator is given, values are split against this separator first. If separator is a whitespace character, empty values are removed.

◆ getBoolValue

bool MLABTree::getBoolValue ( )
slot

Returns whether the value is true or false (yes/true/1).

◆ getFileName

QString MLABTree::getFileName ( )
slot

Returns the file name of the MDL file where this tag was defined.

◆ getFloatValue

float MLABTree::getFloatValue ( )
slot

Returns the value as float.

◆ getIntValue

int MLABTree::getIntValue ( )
slot

Returns the value as integer.

◆ getLine

int MLABTree::getLine ( )
slot

Returns the line of the file where this tag was defined.

◆ getListValue

QStringList MLABTree::getListValue ( )
slot

Get/set value as a list.

A string value is separated at ',' e.g.: a value of "1, 4, 3, 44" would be returned as ("1", "4", "3", "44")

◆ getName

QString MLABTree::getName ( )
slot

Returns the name of the tree node.

◆ getRectValue

QRect MLABTree::getRectValue ( )
slot

get/set rect value of this tree (by parsing the value string).

A rect as a string value looks like this: "100 100 20 40" (x y w h)

◆ getScaledIntValue

int MLABTree::getScaledIntValue ( float scaleFactor)
slot

Returns the value as scaled integer.

◆ getSizeValue

QSize MLABTree::getSizeValue ( )
slot

Get/set size value of this tree (by parsing the value string).

A size as a string value looks like this: "100 100" (w h)

◆ getUlongValue

unsigned long MLABTree::getUlongValue ( )
slot

Returns the value as unsigned long.

◆ getValue

QString MLABTree::getValue ( )
slot

Returns the value of the tree node.

◆ getValueLine

int MLABTree::getValueLine ( )
slot

Returns the line of the file where this tags value was defined.

◆ getValueResolveEscapes

QString MLABTree::getValueResolveEscapes ( )
slot

Returns the value of this tree with resolved escape-sequences.

◆ insert [1/2]

MLABTree * MLABTree::insert ( int idx,
const QString & name,
const QString & value )
slot

Inserts a new tree child at the given position (i must be between 0 and count()-1).

◆ insert [2/2]

void MLABTree::insert ( int idx,
MLABTree * child )
slot

Inserts a given tree child.

◆ printError

void MLABTree::printError ( const QString & msg)
slot

Prints an error to the console for this tree.

◆ printWarning

void MLABTree::printWarning ( const QString & msg)
slot

Prints a warning to the console for this tree.

◆ remove

bool MLABTree::remove ( MLABTree * child)
slot

Removes a given tree child.

◆ setName

void MLABTree::setName ( const QString & name)
slot

Sets the name of the tree. Be careful, since it affects all trees which reference this tree.

◆ setValue

void MLABTree::setValue ( const QString & value)
slot

Sets the value of the tree. Be careful, since it affects all trees which reference this tree.

◆ toString

QString MLABTree::toString ( )
inlineslot

Returns an MDL string with the whole recursive tree (excluding the root item on which this method is called).