NSCore::QTreeItem Class Reference

Abstract class to arrange items in a tree. More...

#include <qtreeitem.h>

Inheritance diagram for NSCore::QTreeItem:

QObject NSCore::PointerProtection_Skel NSAcqiris::Acqiris NSCore::ActionTreeItem NSCore::DataSetProducer NSCore::MathExpression NSCore::NamedParameterTreeItem NSCore::QTreeItemPointer NSEvaluation::PluginItem DopplerProducer NSAcqiris::Digitizer NSCore::DataSetChainMember NSCore::GaussProducer NSDiskIO::AbstractReader NSCore::MathTreeRoot NSCore::QTreeItemNode NSEvaluation::AnalyzerItem NSEvaluation::FilterItem NSEvaluation::ModifierItem
Collaboration diagram for NSCore::QTreeItem:

Collaboration graph
[legend]

List of all members.

Public Slots

void treeDeleteLater ()
 deferred deletion
bool addChild (QTreeItem *item)
 Adds new childs to this item.

Signals

void newChildAdded (NSCore::QTreeItem *item)
void aboutToDeleteMe ()

Public Member Functions

 QTreeItem (QObject *p=0)
 Create a new QTreeItem.
 QTreeItem (QString n, QObject *p=0)
 Create a new named QTreeItem.
virtual ~QTreeItem ()
 Destructor.
void setObjectName (const QString &)
 Set the objectname and check for duplicates in parents childs.
int childs () const
 Return the number of childs.
const QObjectList childobjects () const
 Return pointers to all the child-treeitems.
template<class T>
QList< T * > childobjects () const
 Return pointers to all child-treeitems of a certain type.
const QStringList childlist () const
 The names of the direct childs.
template<class T>
const QStringList childlist () const
QTreeItemchild (int n) const
 Gives access to the childs by their number.
QTreeItemchild (QString n) const
 Get the named direct child.
template<class T>
T * child (QString n) const
 Get the named direct child of the given type.
QTreeItemgetNamedChild (QString n) const
 Get the named item recursivly.
int row () const
 Returns the row-number of this item inside its parent.
int row (const QTreeItem *child) const
 Returns the row-number of the given child.
QString path () const
 return the parent path
virtual QVariant guiValue () const
 GUI: return a/the value to display.
virtual void guiSetValue (QVariant)
 GUI: set the value.
virtual QStringList guiActions () const
 GUI: return the supported actions.
virtual void guiExecAction (QString n, GuiServer_Interface *gui)
 GUI: execute the named action.
virtual QVariant guiIdentifier (int role=0) const
 GUI: return different types of data used to identify the treeitem.
virtual Qt::ItemFlags guiFlags () const
 GUI: the Flags for this item.
void setToolTip (const QString &n)
 set the tooltip for this item
bool saveToXmlNeeded ()
 recursive determination whether the save to xml is needed.
void debugPrint (QString prefix="") const
 Debugoutput.
QDomNode toXml (QDomDocument)
 Xml functions.
bool fromXml (QDomNode)
 Xml functions.

Protected Member Functions

virtual QString debug () const =0
 Custom debug text.
virtual QDomNode saveToXML (QDomDocument doc)=0
 Store the information of this element into a new QDomElement.
virtual bool needsToSaveToXml ()
 Whether this item needs to be saved or not.
virtual bool restoreFromXML (QDomNode node)=0
 Restore the state of this element from the given QDomNode.
virtual bool createFromXML (QDomNode node)
 Create childs from XML.
QString toolTip () const

Protected Attributes

QString _tooltip

Properties

QString toolTip
 Tooltip to display in the gui ( if appropriate ).
QVariant guiValue
 The value to be shown in guis.
QStringList guiActions
 The actions this item supports.
QVariant guiIdentifier
 Basicly the name to display in guis.

Private Slots

void workOnXmlCache ()

Private Attributes

QObjectList _morechilds
 The additional "childs" not handled by qobjects system.
bool _deferredDelete
 Whether the object is in deferred deletion.
QList< QDomNode > _xmltoparse
bool _xmlcachereturn


Detailed Description

Abstract class to arrange items in a tree.

This class takes care of accessing the items and numbering them.

An QTreeItem can have a maximum number of childs set, so adding one to many might fail.
This is currently not implemented. If it is really needed it can come back but I don't see why.

Managing childs is mainly done by QObject. But as we have the opportunity to add Childs which don't belong to this QObject, please add the foreign childs with addChild(...) and use childobjects() to retrieve the childrens instead of QObject::children().


Constructor & Destructor Documentation

NSCore::QTreeItem::QTreeItem ( QObject p = 0  )  [inline]

Create a new QTreeItem.

Be aware that if the parent isn't 0 and is a QTreeItem it adds itself to the parents childs. So no further action has to be done.

Parameters:
p The parent QTreeItem or QObject this one got inserted to.

References addChild().

NSCore::QTreeItem::QTreeItem ( QString  n,
QObject p = 0 
) [inline]

Create a new named QTreeItem.

Be aware that if the parent isn't 0 and is a QTreeItem it adds itself to the parents childs. So no further action has to be done.

Parameters:
n The name of this QTreeItem. Allows accessing this item and childs by name / path.
p The parent QTreeItem or QObject this one got inserted to.

References addChild(), and setObjectName().

virtual NSCore::QTreeItem::~QTreeItem (  )  [inline, virtual]

Destructor.

References aboutToDeleteMe().


Member Function Documentation

void NSCore::QTreeItem::setObjectName ( const QString &   ) 

Set the objectname and check for duplicates in parents childs.

Note:
Please use this one instead of QObject::setObjectName()

Haha, of course you will use this one as its the same name as QObject::setObjectName() :-)

Referenced by NSEvaluation::AnalyzerItem::AnalyzerItem(), NSEvaluation::FilterItem::FilterItem(), NSEvaluation::ModifierItem::ModifierItem(), and QTreeItem().

int NSCore::QTreeItem::childs (  )  const [inline]

Return the number of childs.

Referenced by debugPrint().

const QObjectList NSCore::QTreeItem::childobjects (  )  const [inline]

Return pointers to all the child-treeitems.

This extends QObject::children() in that it also returns childs that are not children in the QObject-way.

Note:
For usage on QTreeItem's tree-structure this has to be used instead of the QObject::children()!

References _deferredDelete, and _morechilds.

Referenced by child(), childobjects(), debugPrint(), NSEvaluation::FilterItem::process(), NSEvaluation::ModifierItem::process(), and row().

template<class T>
QList<T*> NSCore::QTreeItem::childobjects (  )  const [inline]

Return pointers to all child-treeitems of a certain type.

This extends childobjects() in that it only returns the addresses of the direct children that are of the given type.

References childobjects().

const QStringList NSCore::QTreeItem::childlist (  )  const [inline]

The names of the direct childs.

This returns a QStringList with the names of the direct children.

References child().

template<class T>
const QStringList NSCore::QTreeItem::childlist (  )  const [inline]

References child().

QTreeItem* NSCore::QTreeItem::child ( int  n  )  const [inline]

Gives access to the childs by their number.

Parameters:
n the child you want to access

Reimplemented in NSCore::QTreeItemNode.

References childobjects().

Referenced by child(), childlist(), and getNamedChild().

QTreeItem* NSCore::QTreeItem::child ( QString  n  )  const [inline]

Get the named direct child.

This function is non-recursive and only searches the direct childs for a complete hit of the name.

Parameters:
n name of the child to find.

References child(), and childobjects().

template<class T>
T* NSCore::QTreeItem::child ( QString  n  )  const [inline]

Get the named direct child of the given type.

This functions extends child() and returns a casted pointer. If a child with the given name and type exists. Otherwise it returns 0.

Parameters:
n name of the child to find

References child().

QTreeItem* NSCore::QTreeItem::getNamedChild ( QString  n  )  const [inline]

Get the named item recursivly.

This returns the item you select by path or 0 if no item is found.

Parameters:
n the path to the item you search

References child(), getNamedChild(), and path().

Referenced by getNamedChild().

int NSCore::QTreeItem::row (  )  const [inline]

Returns the row-number of this item inside its parent.

int NSCore::QTreeItem::row ( const QTreeItem child  )  const [inline]

Returns the row-number of the given child.

Parameters:
child the child that is searched for.

References childobjects().

QString NSCore::QTreeItem::path (  )  const [inline]

return the parent path

This checks for all the parent QTreeItem and returns their names as a unix-like-path.

References path().

Referenced by getNamedChild(), and path().

virtual QVariant NSCore::QTreeItem::guiValue (  )  const [inline, virtual]

GUI: return a/the value to display.

If you implement this, always remember to call the parent guiValue() if you can't return the right thing.

Reimplemented in NSCore::ActionTreeItem, NSCore::NamedParameterTreeItem, NSCore::QTreeItemPointer, and NSEvaluation::FilterExpression.

virtual void NSCore::QTreeItem::guiSetValue ( QVariant   )  [inline, virtual]

GUI: set the value.

This function will be called by GUIs to change the value. You should implement it accordingly.

Reimplemented in NSCore::ActionTreeItem, NSCore::NamedParameterTreeItem, NSCore::QTreeItemPointer, and NSEvaluation::FilterExpression.

virtual QStringList NSCore::QTreeItem::guiActions (  )  const [inline, virtual]

GUI: return the supported actions.

These actions will get symbols/buttons to get executed.

If you implement this, remember to call the parent guiActions() too:

 SomeTreeItem::guiActions() const {
   return QStringList() << <your actions> << BaseClass::guiActions();
 }

Reimplemented in NSCore::ActionTreeItem, NSCore::MathExpression, NSCore::MathTreeRoot, NSCore::NamedParameterTreeItem, NSCore::QTreeItemPointer, NSEvaluation::EvaluationPath, NSEvaluation::PluginItem, NSEvaluation::AnalyzerItem, and ResultsToSpectrum.

Referenced by ResultsToSpectrum::guiActions(), and NSCore::MathTreeRoot::guiActions().

virtual void NSCore::QTreeItem::guiExecAction ( QString  n,
GuiServer_Interface gui 
) [inline, virtual]

GUI: execute the named action.

If you implemented guiActions() you will also want to implement this. If you can't handle the named action yourself, call guiExecAction() of the parent class.

Of course this can also be used as a filter if you want to restrict access to actions of the parent class.

The second parameter lets you interact with the user by some basic means.

Parameters:
n The action to execute
gui The gui to use for interactions

Reimplemented in NSCore::ActionTreeItem, NSCore::MathExpression, NSCore::MathTreeRoot, NSCore::NamedParameterTreeItem, NSCore::QTreeItemPointer, NSEvaluation::EvaluationPath, NSEvaluation::PluginItem, and ResultsToSpectrum.

Referenced by NSEvaluation::PluginItem::guiExecAction().

virtual QVariant NSCore::QTreeItem::guiIdentifier ( int  role = 0  )  const [virtual]

GUI: return different types of data used to identify the treeitem.

Things like the name, icon, statustip, tooltip and so on will be accessed by this.

Parameters:
role is actually a combination of Qt::ItemDataRole

Reimplemented in NSCore::ActionTreeItem, NSCore::NamedParameterTreeItem, NSCore::QTreeItemPointer, NSDiskIO::AbstractReader, NSEvaluation::EvaluationPath, and ResultsToSpectrum.

virtual Qt::ItemFlags NSCore::QTreeItem::guiFlags (  )  const [inline, virtual]

void NSCore::QTreeItem::setToolTip ( const QString &  n  )  [inline]

set the tooltip for this item

References _tooltip.

QDomNode NSCore::QTreeItem::toXml ( QDomDocument   ) 

Xml functions.

Storing works as the old functions did.

Restore calls restoreFromXML() and if that returns true (ie. the state of the item itself was successfully restored ), createFromXML() is called to give you a chance to create child elements as needed. If that too returns true, fromXml() is called on every child with every child-xml-element as argument.

bool NSCore::QTreeItem::fromXml ( QDomNode   ) 

Xml functions.

Storing works as the old functions did.

Restore calls restoreFromXML() and if that returns true (ie. the state of the item itself was successfully restored ), createFromXML() is called to give you a chance to create child elements as needed. If that too returns true, fromXml() is called on every child with every child-xml-element as argument.

bool NSCore::QTreeItem::saveToXmlNeeded (  ) 

recursive determination whether the save to xml is needed.

void NSCore::QTreeItem::debugPrint ( QString  prefix = ""  )  const [inline]

Debugoutput.

This prints a tree-view of this item and its childs to qDebug. Every subclass has to implement debug() to return the internal debug-data.

Call it without an argument.

References childobjects(), childs(), debug(), and debugPrint().

Referenced by debugPrint().

void NSCore::QTreeItem::treeDeleteLater (  )  [inline, slot]

deferred deletion

Use this one instead of QObject::deleteLater()!!!

References _deferredDelete, and NSCore::PointerProtection_Skel::clearPointers().

bool NSCore::QTreeItem::addChild ( QTreeItem item  )  [slot]

Adds new childs to this item.

Referenced by QTreeItem().

void NSCore::QTreeItem::newChildAdded ( NSCore::QTreeItem item  )  [signal]

void NSCore::QTreeItem::aboutToDeleteMe (  )  [signal]

Referenced by ~QTreeItem().

virtual QString NSCore::QTreeItem::debug (  )  const [protected, pure virtual]

virtual QDomNode NSCore::QTreeItem::saveToXML ( QDomDocument  doc  )  [protected, pure virtual]

Store the information of this element into a new QDomElement.

This function is only to save the state of this element, all the recursive stuff will be done by toXml().

Parameters:
doc The QDomDocument to use for creation of the element

Implemented in NSCore::ActionTreeItem, NSCore::GaussProducer, NSCore::MathTreeRoot, NSCore::NamedParameterTreeItem, NSCore::QTreeItemPointer, NSDiskIO::AbstractReader, NSDiskIO::AbstractWriter, DopplerProducer, NSEvaluation::EvaluationPath, NSEvaluation::AnalyzerItem, NSEvaluation::ModifierItem, NSEvaluation::FilterItem, NSEvaluation::FilterExpression, OsciWidgetV3_ChainMember, NSAcqiris::Acqiris, NSAcqiris::Digitizer, and ResultsToSpectrum.

virtual bool NSCore::QTreeItem::needsToSaveToXml (  )  [inline, protected, virtual]

Whether this item needs to be saved or not.

If the item itself and all its childs don't need to be saved, it will be skipped.

The default is to save.

Reimplemented in NSCore::ActionTreeItem, and NSCore::NamedParameterTreeItem.

virtual bool NSCore::QTreeItem::restoreFromXML ( QDomNode  node  )  [protected, pure virtual]

Restore the state of this element from the given QDomNode.

You don't have to do the recursive stuff here, that is handled in fromXml() for you. Only the things done in saveToXML need/can be restored here.

If you succeeded and want the childs to be restored too, return true.

Parameters:
node The QDomNode to restore from

Implemented in NSCore::ActionTreeItem, NSCore::GaussProducer, NSCore::MathTreeRoot, NSCore::NamedParameterTreeItem, NSCore::QTreeItemPointer, NSDiskIO::AbstractReader, NSDiskIO::AbstractWriter, DopplerProducer, NSEvaluation::EvaluationPath, NSEvaluation::AnalyzerItem, NSEvaluation::ModifierItem, NSEvaluation::FilterItem, NSEvaluation::FilterExpression, OsciWidgetV3_ChainMember, NSAcqiris::Acqiris, NSAcqiris::Digitizer, and ResultsToSpectrum.

virtual bool NSCore::QTreeItem::createFromXML ( QDomNode  node  )  [inline, protected, virtual]

Create childs from XML.

On fromXml() this gets called after successfull return from restoreFromXML(). If you want to create childs of this item from the childs of the QDomNode given, you can do so.

The return value defines whether fromXml will be called on the childs for the child-xml-items.

The default implementation returns true, so the child items get a chance to restore their state too.

Parameters:
node The QDomNode to restore from

Reimplemented in NSCore::MathTreeRoot, NSEvaluation::EvaluationPath, NSEvaluation::PluginItem, and ResultsToSpectrum.

QString NSCore::QTreeItem::toolTip (  )  const [inline, protected]

private because only qt's metaobject system needs to access it

References _tooltip.

void NSCore::QTreeItem::workOnXmlCache (  )  [private, slot]


Member Data Documentation

QString NSCore::QTreeItem::_tooltip [protected]

Referenced by setToolTip(), and toolTip().

QObjectList NSCore::QTreeItem::_morechilds [private]

The additional "childs" not handled by qobjects system.

Referenced by childobjects().

Whether the object is in deferred deletion.

Referenced by childobjects(), and treeDeleteLater().

QList<QDomNode> NSCore::QTreeItem::_xmltoparse [private]


Property Documentation

QString NSCore::QTreeItem::toolTip [read, write]

Tooltip to display in the gui ( if appropriate ).

QVariant NSCore::QTreeItem::guiValue [read, write]

The value to be shown in guis.

QStringList NSCore::QTreeItem::guiActions [read]

The actions this item supports.

QVariant NSCore::QTreeItem::guiIdentifier [read]

Basicly the name to display in guis.

This actually uses guiIdentifier( int ) with a default of 0 (=QtDisplayRole).

If you want to access the icon and tooltip, use guiIdentifier() directly.


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

Generated on Tue Apr 12 02:10:28 2011 for epos by  doxygen 1.5.5