Logo Search packages:      
Sourcecode: k4dirstat version File versions  Download package

void KDirInfo::insertChild ( KFileInfo newChild ) [virtual]

Insert a child into the children list.

The order of children in this list is absolutely undefined; don't rely on any implementation-specific order.

Only directories are stored directly in pure directory nodes - unless something went terribly wrong, e.g. there is no dot entry to use. If this is a dot entry, store everything it gets directly within it.

In any of those cases, insert the new child in the children list.

We don't bother with this list's order - it's explicitly declared to be unordered, so be warned! We simply insert this new child at the list head since this operation can be performed in constant time without the need for any additional lastChild etc. pointers or - even worse - seeking the correct place for insertion first. This is none of our business; the corresponding "view" object for this tree will take care of such niceties.

Reimplemented from KDirStat::KFileInfo.

Definition at line 276 of file kdirinfo.cpp.

References childAdded(), KDirStat::KFileInfo::insertChild(), KDirStat::KFileInfo::isDir(), KDirStat::KFileInfo::setNext(), and KDirStat::KFileInfo::setParent().

Referenced by KDirStat::KCacheReader::addItem(), KDirStat::KioDirReadJob::entries(), KDirStat::KDirTree::refresh(), and KDirStat::KLocalDirReadJob::startReading().

{
    Q_CHECK_PTR( newChild );

    if ( newChild->isDir() || _dotEntry == 0 || _isDotEntry )
    {
      /**
       * Only directories are stored directly in pure directory nodes -
       * unless something went terribly wrong, e.g. there is no dot entry to use.
       * If this is a dot entry, store everything it gets directly within it.
       *
       * In any of those cases, insert the new child in the children list.
       *
       * We don't bother with this list's order - it's explicitly declared to
       * be unordered, so be warned! We simply insert this new child at the
       * list head since this operation can be performed in constant time
       * without the need for any additional lastChild etc. pointers or -
       * even worse - seeking the correct place for insertion first. This is
       * none of our business; the corresponding "view" object for this tree
       * will take care of such niceties.
       **/
      newChild->setNext( _firstChild );
      _firstChild = newChild;
      newChild->setParent( this );  // make sure the parent pointer is correct

      childAdded( newChild );       // update summaries
    }
    else
    {
      /*
       * If the child is not a directory, don't store it directly here - use
       * this entry's dot entry instead.
       */
      _dotEntry->insertChild( newChild );
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index