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

void KDirTreeViewItem::init ( KDirTreeView view,
KDirTreeViewItem parent,
KFileInfo orig 
) [private]

Initializations common to all constructors.

Definition at line 1067 of file kdirtreeview.cpp.

References KDirStat::KFileInfo::allocatedSize(), KDirStat::KFileInfo::byteSize(), KDirStat::KDirTreeView::doLazyClone(), KDirStat::KFileInfo::hasChildren(), KDirStat::KFileInfo::isDevice(), KDirStat::KFileInfo::isDir(), KDirStat::KFileInfo::isDotEntry(), KDirStat::KFileInfo::isExcluded(), KDirStat::KFileInfo::isFile(), KDirStat::KFileInfo::isSparseFile(), KDirStat::KFileInfo::links(), KDirStat::KFileInfo::name(), KDirStat::KDirTreeView::openLevel(), orig(), parent(), KDirStat::KFileInfo::readState(), setIcon(), setOpen(), KDirStat::KFileInfo::size(), KDirStat::KFileInfo::treeLevel(), and view().

Referenced by KDirTreeViewItem().

{
    _view   = view;
    _parent = parent;
    _orig   = orig;
    _percent      = 0.0;
    _pacMan = 0;
    _openCount    = 0;

    // _view->incDebugCount(1);
    // kdDebug() << "new KDirTreeViewItem for " << orig << endl;

    if ( _orig->isDotEntry() )
    {
       setText( view->nameCol(), i18n( "<Files>" ) );
       Q3ListViewItem::setOpen ( false );
    }
    else
    {
      setText( view->nameCol(), QString::fromLocal8Bit(_orig->name()) );

      if ( ! _orig->isDevice() )
      {
          QString text;

          if ( _orig->isFile() && ( _orig->links() > 1 ) ) // Regular file with multiple links
          {
            if ( _orig->isSparseFile() )
            {
                text = i18n( "%1 / %2 Links (allocated: %3)" )
                  .arg( formatSize( _orig->byteSize() ) )
                  .arg( formatSize( _orig->links() ) )
                  .arg( formatSize( _orig->allocatedSize() ) );
            }
            else
            {
                text = i18n( "%1 / %2 Links" )
                  .arg( formatSize( _orig->byteSize() ) )
                  .arg( _orig->links() );
            }
          }
          else // No multiple links or no regular file
          {
            if ( _orig->isSparseFile() )
            {
                text = i18n( "%1 (allocated: %2)" )
                  .arg( formatSize( _orig->byteSize() ) )
                  .arg( formatSize( _orig->allocatedSize() ) );
            }
            else
            {
                text = formatSize( _orig->size() );
            }
          }

          setText( view->ownSizeCol(), text );

#ifdef NEVER_EXECUTED
          // Never executed because during init() a read job for this
          // directory will still be pending. Only the read job will figure
          // out if an exclude rule applies.

          if ( _orig->isExcluded() )
          {
            setText( _view->percentBarCol(), i18n( "[excluded]" ) );
          }
#endif
      }

      Q3ListViewItem::setOpen ( _orig->treeLevel() < _view->openLevel() );
      /*
       * Don't use KDirTreeViewItem::setOpen() here since this might call
       * KDirTreeViewItem::deferredClone() which would confuse bookkeeping
       * with addChild() signals that might arrive, too - resulting in double
       * dot entries.
       */
    }

    if ( _view->doLazyClone() &&
       ( _orig->isDir() || _orig->isDotEntry() ) )
    {
      /*
       * Determine whether or not this item can be opened.
       *
       * Normally, Qt handles this very well, but when lazy cloning is in
       * effect, Qt cannot know whether or not there are children - they may
       * only be in the original tree until the user tries to open this
       * item. So let's assume there may be children as long as the directory
       * is still being read.
       */

      if ( _orig->readState() == KDirQueued  ||
           _orig->readState() == KDirReading ||
           _orig->readState() == KDirCached    )
      {
          setExpandable( true );
      }
      else  // KDirFinished, KDirError, KDirAborted
      {
          setExpandable( _orig->hasChildren() );
      }
    }

    if ( ! parent || parent->isOpen() )
    {
      setIcon();
    }

    _openCount = isOpen() ? 1 : 0;
}

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