Logo Search packages:      
Sourcecode: kdbg version File versions

bool KTreeView::forEveryItem ( KForEveryFunc  func,
void *  user,
KTreeViewItem root = 0 
)

Iterates every item in the tree, visible or not, and applies the function func with a pointer to each item and user data supplied as parameters. The children of the specified root item are visited (root itself is not visited!). If root is 0 all items in the tree are visited. KForEveryFunc is defined as:

typedef bool (KTreeView::*KForEveryFunc)(KTreeViewItem*, void*);

That is, a member function that returns bool and takes a pointer to a KTreeViewItem and pointer to void as parameters. The traversal ends earlier if the supplied function returns bool. In this case the return value is also true.

Parameters:
func the member function to call for every visited item
user extra data that is passed to func
root the root item of the subtree to scan; this item itself is not scanned
See also:
forEveryVisibleItem

Definition at line 762 of file ktreeview.cpp.

References KTreeViewItem::getChild(), KTreeViewItem::getSibling(), KTreeViewItem::hasChild(), and KTreeViewItem::owner.

Referenced by count(), setShowItemText(), and setTreeDrawing().

{
    if (item == 0) {
      item = treeRoot;
    }
    assert(item->owner == this);
    item = item->getChild();

    while (item != 0) {
      // visit the siblings
      if ((*func)(item, user)) {
          return true;
      }
      // visit the children (recursively)
      if (item->hasChild()) {
          if (forEveryItem(func, user, item))
            return true;
      }
      item = item->getSibling();
    }
    return false;
}


Generated by  Doxygen 1.6.0   Back to index