gui::TreeItemAbstract Class Reference

Abstract tree item class. More...

#include <treeitemabstract.h>

Inheritance diagram for gui::TreeItemAbstract:
gui::TreeItem gui::TreeItemAnnotation gui::TreeItemAnnotationContainer gui::TreeItemContentStream gui::TreeItemOperatorContainer gui::TreeItemPage gui::TreeItemPdf gui::TreeItemPdfOperator

List of all members.

Public Member Functions

void setSelect (bool selected)
void unSelect (Q_ListView *tree)
QString path ()
 TreeItemAbstract (const QString &itemName, TreeData *_data, Q_ListView *parent, Q_ListViewItem *after=NULL)
 TreeItemAbstract (const QString &itemName, TreeData *_data, Q_ListViewItem *parent, Q_ListViewItem *after=NULL)
QString name ()
void setName (const QString &newNameId)
virtual ~TreeItemAbstract ()
void reload (bool reloadThis=true, bool forceReload=false)
virtual void deleteChild (const QString &name)
virtual void deleteChild (Q_ListViewItem *target)
void eraseItems ()
void moveAllChildsFrom (TreeItemAbstract *src)
Q_ListViewItem * child (const QString &name)
virtual QSCObjectgetQSObject (BaseCore *_base)
virtual void setOpen (bool open)
virtual bool deepReload (const QString &childName, Q_ListViewItem *oldItem)
virtual QString itemHint ()
virtual bool validChild (const QString &name, Q_ListViewItem *oldChild)=0
virtual QSCObjectgetQSObject ()=0
virtual TreeItemAbstractcreateChild (const QString &name, ChildType typ, Q_ListViewItem *after=NULL)=0
virtual QStringList getChildNames ()=0
virtual void reloadSelf ()=0
virtual void remove ()=0
virtual ChildType getChildType (const QString &name)=0
virtual bool haveChild ()=0

Protected Attributes

QString nameId
Q_Dict< Q_ListViewItem > items
QMap< QString, ChildTypetypes
TreeDatadata

Private Member Functions

void initAbs ()

Private Attributes

bool parsed
TreeWindowrootWindow

Detailed Description

Abstract tree item class.

Common ancestor of all tree Items, with functions to support automatic loading and reloading of tree, or its parts (subtrees)


Constructor & Destructor Documentation

gui::TreeItemAbstract::TreeItemAbstract ( const QString &  itemName,
TreeData _data,
Q_ListView *  parent,
Q_ListViewItem *  after = NULL 
)

constructor of TreeItemAbstract - create root item

Parameters:
itemName Name of this item
_data TreeData containing necessary information about tree in which this item will be inserted
parent Q_ListView in which to put item
after Item after which this one will be inserted

References data, initAbs(), and nameId.

gui::TreeItemAbstract::TreeItemAbstract ( const QString &  itemName,
TreeData _data,
Q_ListViewItem *  parent,
Q_ListViewItem *  after = NULL 
)

constructor of TreeItemAbstract - create child item

Parameters:
itemName Name of this item
_data TreeData containing necessary information about tree in which this item will be inserted
parent Q_ListViewItem which is parent of this object
after Item after which this one will be inserted

References data, initAbs(), and nameId.

gui::TreeItemAbstract::~TreeItemAbstract (  )  [virtual]

Member Function Documentation

Q_ListViewItem * gui::TreeItemAbstract::child ( const QString &  name  ) 

Look for child with given name and return it. Return NULL if child not found

Parameters:
name Name of child to look for
Returns:
Specified child of this tree item

References items, parsed, and reload().

Referenced by gui::QSTreeItem::child().

virtual TreeItemAbstract* gui::TreeItemAbstract::createChild ( const QString &  name,
ChildType  typ,
Q_ListViewItem *  after = NULL 
) [pure virtual]

Create one subchild

Parameters:
name Name of child (the same as in list returned from getChildNames)
typ Type of TreeItemAbstract's child. (see ChildType)
after Q_ListViewItem after which will be this item added. If unspecified (or NULL), it is added before any other items
Returns:
Pointer to subchild. If returned NULL, the subchild can not be created
See also:
getChildNames

Implemented in gui::TreeItemAnnotation, gui::TreeItemAnnotationContainer, gui::TreeItemArray, gui::TreeItemContentStream, gui::TreeItemCStream, gui::TreeItemDict, gui::TreeItemOperatorContainer, gui::TreeItemPage, gui::TreeItemPdf, gui::TreeItemPdfOperator, gui::TreeItemRef, and gui::TreeItemSimple.

Referenced by reload().

bool gui::TreeItemAbstract::deepReload ( const QString &  childName,
Q_ListViewItem *  oldItem 
) [virtual]

Attempt to "deep reload", i.e. exchange the item inside the tree for an actual (different) one, without destroying the object (destroying have unfortunate effect of losing information about which child were opened ...) oldChild should be modified to refrlect the new object If deep reload is supported and was sucessful, return true, otherwise false.

Note: oldItem should not check or reload its children in this method (at it might lead to multiple reloading of same part of tree) Also, it is guaranteed that reloadSelf will be called on that item, so explicitly reloading the item might be unnecessary too

Parameters:
childName name of (old and new) treeitem
oldItem reference to old child tree item
Returns:
true if successful, false otherwise

Reimplemented in gui::TreeItemDict, gui::TreeItemPage, gui::TreeItemPdf, and gui::TreeItemRef.

Referenced by reload().

void gui::TreeItemAbstract::deleteChild ( Q_ListViewItem *  target  )  [virtual]

Delete subitem, given by its pointer

Parameters:
target Pointer to subitem to delete
void gui::TreeItemAbstract::deleteChild ( const QString &  name  )  [virtual]

Delete subitem, given by its name

Parameters:
name Name of subitem to delete

References debug::DBG_WARN, guiPrintDbg, items, Q_ListViewItem, Q_OUT, and types.

Referenced by eraseItems(), and reload().

void gui::TreeItemAbstract::eraseItems (  ) 

Erase all items in current item dictionary. After returning, the item dictionary is empty

References deleteChild(), items, and types.

Referenced by moveAllChildsFrom(), reload(), and gui::TreeItemRef::reloadSelf().

virtual QStringList gui::TreeItemAbstract::getChildNames (  )  [pure virtual]
virtual ChildType gui::TreeItemAbstract::getChildType ( const QString &  name  )  [pure virtual]
virtual QSCObject* gui::TreeItemAbstract::getQSObject (  )  [pure virtual]
QSCObject * gui::TreeItemAbstract::getQSObject ( BaseCore _base  )  [virtual]

Create and return object for scripting representing this tree item, relocated in different base If the object cannot be copied into new base, return NULL

Parameters:
_base BaseCore for the new object.
Returns:
object for scripting

Reimplemented in gui::TreeItem, gui::TreeItemArray, gui::TreeItemCStream, gui::TreeItemDict, and gui::TreeItemPage.

Referenced by gui::TreeWindow::getSelected(), gui::QSTreeItem::item(), gui::QSTreeItem::itemref(), gui::QSTreeItem::itemtype(), and gui::TreeWindow::nextSelected().

virtual bool gui::TreeItemAbstract::haveChild (  )  [pure virtual]
void gui::TreeItemAbstract::initAbs (  )  [private]

Initialize the class - set root window, check data ...

References data, parsed, Q_ListView, and rootWindow.

Referenced by TreeItemAbstract().

QString gui::TreeItemAbstract::itemHint (  )  [virtual]

Return hint (description) of this item

Returns:
hint for given item

Reimplemented in gui::TreeItemPdfOperator.

References path().

Referenced by gui::TreeWindow::moveOnItem().

void gui::TreeItemAbstract::moveAllChildsFrom ( TreeItemAbstract src  ) 

Move all child items from other item to this item. If current item does have any childs, they will be deleted

Parameters:
src TreeItemAbstract containing childs I want to move to this item

References debug::DBG_DBG, eraseItems(), guiPrintDbg, items, Q_ListViewItem, and types.

Referenced by gui::TreeItemRef::setOpen().

QString gui::TreeItemAbstract::name (  ) 

Return name (id) of this item. Name is unique only for each item's children. Children of different tree items can (and often will) have same name

Returns:
name of itself

References nameId.

Referenced by gui::QSTreeItem::id(), and path().

QString gui::TreeItemAbstract::path (  ) 

Return path of this item (sequence of names from root to this item, separated by slash "/").

Returns:
path of this item

References name().

Referenced by gui::TreeItemPdfOperator::itemHint(), itemHint(), and gui::QSTreeItem::path().

void gui::TreeItemAbstract::reload ( bool  reloadThis = true,
bool  forceReload = false 
)
virtual void gui::TreeItemAbstract::reloadSelf (  )  [pure virtual]
virtual void gui::TreeItemAbstract::remove (  )  [pure virtual]

Remove itself from document (including any children) Do not remove the treeitem itself in this method -> this may lead to crash! If desired, you may call reload() on parent to get rid of the item correctly

Implemented in gui::TreeItem, gui::TreeItemAnnotation, gui::TreeItemAnnotationContainer, gui::TreeItemContentStream, gui::TreeItemOperatorContainer, gui::TreeItemPage, gui::TreeItemPdf, and gui::TreeItemPdfOperator.

Referenced by gui::QSTreeItem::remove().

void gui::TreeItemAbstract::setName ( const QString &  newNameId  ) 

Set name (id) of this item. Name is unique only for each item's children. Children of different tree items can (and often will) have same name Can be used if changing array elements (moving, etc ...)

Parameters:
newNameId New name for this element

References nameId.

Referenced by gui::TreeItemArray::remove().

void gui::TreeItemAbstract::setOpen ( bool  open  )  [virtual]

Slot that will be called when item is opened/closed

Parameters:
open True if item is being opened, false if closed

Reimplemented in gui::TreeItemContentStream, and gui::TreeItemRef.

References parsed, and reload().

Referenced by gui::TreeWindow::init(), and gui::QSTreeItem::setOpen().

void gui::TreeItemAbstract::setSelect ( bool  selected  ) 

Set this item as selected/unselected and repaint the tree

Parameters:
selected true to select, false to unselect

References Q_ListView.

Referenced by gui::QSTreeItem::setSelected().

void gui::TreeItemAbstract::unSelect ( Q_ListView *  tree  ) 

Move selection away from this item to nearest sensible item
If this item is not selected, task is done, does nothing
If it is selected, firt attempt is to move selection on next sibling, then on item above, then on item below.

Parameters:
tree Q_ListView in which this item resides

References debug::DBG_INFO, guiPrintDbg, and Q_ListViewItem.

Referenced by gui::TreeItemDict::remove(), gui::TreeItemCStream::remove(), and gui::TreeItemArray::remove().

virtual bool gui::TreeItemAbstract::validChild ( const QString &  name,
Q_ListViewItem *  oldChild 
) [pure virtual]

Validate child, given its name and reference to old child Usually it is valid, since item with same name refer to same subitem (key-based items), but for value-based items (array) same keys can correspond to different values after reloading. In such cases, false should be returned. Also, similar problems can happen when switching revisions (with almost all types)

Note: false negative it not a problem (only unnecessary reloading), while false positive mean the tree is invalid/outdated

Parameters:
name name of (old and new) treeitem
oldChild reference to old child tree item
Returns:
True, if the old child is pointing to same item as item "name", false, if the child item "name" no longer point to same item as oldChild.

Implemented in gui::TreeItemAnnotation, gui::TreeItemAnnotationContainer, gui::TreeItemArray, gui::TreeItemContentStream, gui::TreeItemCStream, gui::TreeItemDict, gui::TreeItemOperatorContainer, gui::TreeItemPage, gui::TreeItemPdf, gui::TreeItemPdfOperator, gui::TreeItemRef, and gui::TreeItemSimple.

Referenced by reload().


Member Data Documentation

Q_Dict<Q_ListViewItem> gui::TreeItemAbstract::items [protected]

Mapping of all child names to child items for this tree item

Referenced by child(), deleteChild(), eraseItems(), moveAllChildsFrom(), reload(), gui::TreeItemDict::remove(), gui::TreeItemCStream::remove(), and gui::TreeItemArray::remove().

QString gui::TreeItemAbstract::nameId [protected]

Name of this item

Referenced by name(), setName(), and TreeItemAbstract().

False, if childs of this items are yet unknown and to be parsed/added, true if already parsed

Referenced by child(), initAbs(), reload(), and setOpen().

root window (for delete notification)

Referenced by initAbs(), and ~TreeItemAbstract().

QMap<QString,ChildType> gui::TreeItemAbstract::types [protected]

Mapping of all child names to types of child items for this tree item

Referenced by deleteChild(), eraseItems(), moveAllChildsFrom(), and reload().


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