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

void KDirTree::deleteSubtree ( KFileInfo subtree ) [slot]

Delete a subtree.

Definition at line 307 of file kdirtree.cpp.

References childDeleted(), KDirStat::KDirInfo::deletingChild(), deletingChildNotify(), KDirStat::KFileInfo::hasChildren(), KDirStat::KDirInfo::isDotEntry(), KDirStat::KDirInfo::isFinished(), KDirStat::KFileInfo::parent(), selectItem(), and KDirStat::KDirInfo::setDotEntry().

Referenced by KDirStat::TrashBinCleanup::execute(), KDirStat::KCleanup::execute(), and KDirStat::KLocalDirReadJob::startReading().

{
    // kdDebug() << "Deleting subtree " << subtree << endl;
    KDirInfo *parent = subtree->parent();

    if ( parent )
    {
      // Give the parent of the child to be deleted a chance to unlink the
      // child from its children list and take care of internal summary
      // fields
      parent->deletingChild( subtree );
    }

    // Send notification to anybody interested (e.g., to attached views)
    deletingChildNotify( subtree );

    if ( parent )
    {
      if ( parent->isDotEntry() && ! parent->hasChildren() )
          // This was the last child of a dot entry
      {
          // Get rid of that now empty and useless dot entry

          if ( parent->parent() )
          {
            if ( parent->parent()->isFinished() )
            {
                // kdDebug() << "Removing empty dot entry " << parent << endl;

                deletingChildNotify( parent );
                parent->parent()->setDotEntry( 0 );

                delete parent;
            }
          }
          else    // no parent - this should never happen (?)
          {
            kdError() << "Internal error: Killing dot entry without parent " << parent << endl;

            // Better leave that dot entry alone - we shouldn't have come
            // here in the first place. Who knows what will happen if this
            // thing is deleted now?!
            //
            // Intentionally NOT calling:
            //     delete parent;
          }
      }
    }

    delete subtree;

    if ( subtree == _root )
    {
      selectItem( 0 );
      _root = 0;
    }

    emit childDeleted();
}

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