|
|
|
@ -29,9 +29,9 @@ using namespace KDirStat;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
KFileInfo::KFileInfo( KDirTree * tree,
|
|
|
|
|
KDirInfo * tqparent,
|
|
|
|
|
KDirInfo * parent,
|
|
|
|
|
const char * name )
|
|
|
|
|
: _parent( tqparent )
|
|
|
|
|
: _parent( parent )
|
|
|
|
|
, _next( 0 )
|
|
|
|
|
, _tree( tree )
|
|
|
|
|
{
|
|
|
|
@ -50,8 +50,8 @@ KFileInfo::KFileInfo( KDirTree * tree,
|
|
|
|
|
KFileInfo::KFileInfo( const TQString & filenameWithoutPath,
|
|
|
|
|
struct stat * statInfo,
|
|
|
|
|
KDirTree * tree,
|
|
|
|
|
KDirInfo * tqparent )
|
|
|
|
|
: _parent( tqparent )
|
|
|
|
|
KDirInfo * parent )
|
|
|
|
|
: _parent( parent )
|
|
|
|
|
, _next( 0 )
|
|
|
|
|
, _tree( tree )
|
|
|
|
|
{
|
|
|
|
@ -102,15 +102,15 @@ KFileInfo::KFileInfo( const TQString & filenameWithoutPath,
|
|
|
|
|
|
|
|
|
|
KFileInfo::KFileInfo( const KFileItem * fileItem,
|
|
|
|
|
KDirTree * tree,
|
|
|
|
|
KDirInfo * tqparent )
|
|
|
|
|
: _parent( tqparent )
|
|
|
|
|
KDirInfo * parent )
|
|
|
|
|
: _parent( parent )
|
|
|
|
|
, _next( 0 )
|
|
|
|
|
, _tree( tree )
|
|
|
|
|
{
|
|
|
|
|
CHECK_PTR( fileItem );
|
|
|
|
|
|
|
|
|
|
_isLocalFile = fileItem->isLocalFile();
|
|
|
|
|
_name = tqparent ? fileItem->name() : fileItem->url().url();
|
|
|
|
|
_name = parent ? fileItem->name() : fileItem->url().url();
|
|
|
|
|
_device = 0;
|
|
|
|
|
_mode = fileItem->mode();
|
|
|
|
|
_links = 1;
|
|
|
|
@ -151,7 +151,7 @@ KFileInfo::~KFileInfo()
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The destructor should also take care about unlinking this object from
|
|
|
|
|
* its tqparent's tqchildren list, but regrettably that just doesn't work: At
|
|
|
|
|
* its parent's tqchildren list, but regrettably that just doesn't work: At
|
|
|
|
|
* this point (within the destructor) parts of the object are already
|
|
|
|
|
* destroyed, e.g., the virtual table - virtual methods don't work any
|
|
|
|
|
* more. Thus, somebody from outside must call deletingChild() just prior
|
|
|
|
@ -225,7 +225,7 @@ KFileInfo::urlPart( int targetLevel ) const
|
|
|
|
|
while ( level > targetLevel )
|
|
|
|
|
{
|
|
|
|
|
level--;
|
|
|
|
|
item = item->tqparent();
|
|
|
|
|
item = item->parent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return item->name();
|
|
|
|
@ -236,12 +236,12 @@ int
|
|
|
|
|
KFileInfo::treeLevel() const
|
|
|
|
|
{
|
|
|
|
|
int level = 0;
|
|
|
|
|
KFileInfo * tqparent = _parent;
|
|
|
|
|
KFileInfo * parent = _parent;
|
|
|
|
|
|
|
|
|
|
while ( tqparent )
|
|
|
|
|
while ( parent )
|
|
|
|
|
{
|
|
|
|
|
level++;
|
|
|
|
|
tqparent = tqparent->tqparent();
|
|
|
|
|
parent = parent->parent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return level;
|
|
|
|
@ -271,7 +271,7 @@ KFileInfo::isInSubtree( const KFileInfo *subtree ) const
|
|
|
|
|
if ( ancestor == subtree )
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
ancestor = ancestor->tqparent();
|
|
|
|
|
ancestor = ancestor->parent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
@ -343,9 +343,9 @@ KFileInfo::locate( TQString url, bool findDotEntries )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
KDirInfo::KDirInfo( KDirTree * tree,
|
|
|
|
|
KDirInfo * tqparent,
|
|
|
|
|
KDirInfo * parent,
|
|
|
|
|
bool asDotEntry )
|
|
|
|
|
: KFileInfo( tree, tqparent )
|
|
|
|
|
: KFileInfo( tree, parent )
|
|
|
|
|
{
|
|
|
|
|
init();
|
|
|
|
|
|
|
|
|
@ -366,11 +366,11 @@ KDirInfo::KDirInfo( KDirTree * tree,
|
|
|
|
|
KDirInfo::KDirInfo( const TQString & filenameWithoutPath,
|
|
|
|
|
struct stat * statInfo,
|
|
|
|
|
KDirTree * tree,
|
|
|
|
|
KDirInfo * tqparent )
|
|
|
|
|
KDirInfo * parent )
|
|
|
|
|
: KFileInfo( filenameWithoutPath,
|
|
|
|
|
statInfo,
|
|
|
|
|
tree,
|
|
|
|
|
tqparent )
|
|
|
|
|
parent )
|
|
|
|
|
{
|
|
|
|
|
init();
|
|
|
|
|
_dotEntry = new KDirInfo( tree, this, true );
|
|
|
|
@ -379,10 +379,10 @@ KDirInfo::KDirInfo( const TQString & filenameWithoutPath,
|
|
|
|
|
|
|
|
|
|
KDirInfo::KDirInfo( const KFileItem * fileItem,
|
|
|
|
|
KDirTree * tree,
|
|
|
|
|
KDirInfo * tqparent )
|
|
|
|
|
KDirInfo * parent )
|
|
|
|
|
: KFileInfo( fileItem,
|
|
|
|
|
tree,
|
|
|
|
|
tqparent )
|
|
|
|
|
parent )
|
|
|
|
|
{
|
|
|
|
|
init();
|
|
|
|
|
_dotEntry = new KDirInfo( tree, this, true );
|
|
|
|
@ -597,7 +597,7 @@ KDirInfo::insertChild( KFileInfo *newChild )
|
|
|
|
|
**/
|
|
|
|
|
newChild->setNext( _firstChild );
|
|
|
|
|
_firstChild = newChild;
|
|
|
|
|
newChild->setParent( this ); // make sure the tqparent pointer is correct
|
|
|
|
|
newChild->setParent( this ); // make sure the parent pointer is correct
|
|
|
|
|
|
|
|
|
|
childAdded( newChild ); // update summaries
|
|
|
|
|
}
|
|
|
|
@ -669,7 +669,7 @@ KDirInfo::deletingChild( KFileInfo *deletedChild )
|
|
|
|
|
if ( _parent )
|
|
|
|
|
_parent->deletingChild( deletedChild );
|
|
|
|
|
|
|
|
|
|
if ( ! _beingDestroyed && deletedChild->tqparent() == this )
|
|
|
|
|
if ( ! _beingDestroyed && deletedChild->parent() == this )
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Unlink the child from the tqchildren's list - but only if this doesn't
|
|
|
|
@ -686,7 +686,7 @@ KDirInfo::deletingChild( KFileInfo *deletedChild )
|
|
|
|
|
void
|
|
|
|
|
KDirInfo::unlinkChild( KFileInfo *deletedChild )
|
|
|
|
|
{
|
|
|
|
|
if ( deletedChild->tqparent() != this )
|
|
|
|
|
if ( deletedChild->parent() != this )
|
|
|
|
|
{
|
|
|
|
|
kdError() << deletedChild << " is not a child of " << this
|
|
|
|
|
<< " - cannot unlink from tqchildren list!" << endl;
|
|
|
|
@ -773,7 +773,7 @@ KDirInfo::cleanupDotEntries()
|
|
|
|
|
if ( ! _dotEntry || _isDotEntry )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Retqparent dot entry tqchildren if there are no subdirectories on this level
|
|
|
|
|
// Reparent dot entry tqchildren if there are no subdirectories on this level
|
|
|
|
|
|
|
|
|
|
if ( ! _firstChild )
|
|
|
|
|
{
|
|
|
|
@ -953,25 +953,25 @@ KLocalDirReadJob::startReading()
|
|
|
|
|
KFileInfo *
|
|
|
|
|
KLocalDirReadJob::stat( const KURL & url,
|
|
|
|
|
KDirTree * tree,
|
|
|
|
|
KDirInfo * tqparent )
|
|
|
|
|
KDirInfo * parent )
|
|
|
|
|
{
|
|
|
|
|
struct stat statInfo;
|
|
|
|
|
|
|
|
|
|
if ( lstat( url.path(), &statInfo ) == 0 ) // lstat() OK
|
|
|
|
|
{
|
|
|
|
|
TQString name = tqparent ? url.filename() : url.path();
|
|
|
|
|
TQString name = parent ? url.filename() : url.path();
|
|
|
|
|
|
|
|
|
|
if ( S_ISDIR( statInfo.st_mode ) ) // directory?
|
|
|
|
|
{
|
|
|
|
|
KDirInfo * dir = new KDirInfo( name, &statInfo, tree, tqparent );
|
|
|
|
|
KDirInfo * dir = new KDirInfo( name, &statInfo, tree, parent );
|
|
|
|
|
|
|
|
|
|
if ( dir && tqparent && dir->device() != tqparent->device() )
|
|
|
|
|
if ( dir && parent && dir->device() != parent->device() )
|
|
|
|
|
dir->setMountPoint();
|
|
|
|
|
|
|
|
|
|
return dir;
|
|
|
|
|
}
|
|
|
|
|
else // no directory
|
|
|
|
|
return new KFileInfo( name, &statInfo, tree, tqparent );
|
|
|
|
|
return new KFileInfo( name, &statInfo, tree, parent );
|
|
|
|
|
}
|
|
|
|
|
else // lstat() failed
|
|
|
|
|
return 0;
|
|
|
|
@ -1043,7 +1043,7 @@ KAnyDirReadJob::entries ( KIO::Job * job,
|
|
|
|
|
KFileItem entry( *it,
|
|
|
|
|
url,
|
|
|
|
|
true, // determineMimeTypeOnDemand
|
|
|
|
|
true ); // URL is tqparent directory
|
|
|
|
|
true ); // URL is parent directory
|
|
|
|
|
|
|
|
|
|
if ( entry.name() != "." &&
|
|
|
|
|
entry.name() != ".." )
|
|
|
|
@ -1097,7 +1097,7 @@ KAnyDirReadJob::finished( KIO::Job * job )
|
|
|
|
|
KFileInfo *
|
|
|
|
|
KAnyDirReadJob::stat( const KURL & url,
|
|
|
|
|
KDirTree * tree,
|
|
|
|
|
KDirInfo * tqparent )
|
|
|
|
|
KDirInfo * parent )
|
|
|
|
|
{
|
|
|
|
|
KIO::UDSEntry uds_entry;
|
|
|
|
|
|
|
|
|
@ -1105,9 +1105,9 @@ KAnyDirReadJob::stat( const KURL & url,
|
|
|
|
|
{
|
|
|
|
|
KFileItem entry( uds_entry, url,
|
|
|
|
|
true, // determine MIME type on demand
|
|
|
|
|
false ); // URL specifies tqparent directory
|
|
|
|
|
false ); // URL specifies parent directory
|
|
|
|
|
|
|
|
|
|
return entry.isDir() ? new KDirInfo ( &entry, tree, tqparent ) : new KFileInfo( &entry, tree, tqparent );
|
|
|
|
|
return entry.isDir() ? new KDirInfo ( &entry, tree, parent ) : new KFileInfo( &entry, tree, parent );
|
|
|
|
|
}
|
|
|
|
|
else // remote stat() failed
|
|
|
|
|
return 0;
|
|
|
|
@ -1134,7 +1134,7 @@ KAnyDirReadJob::owner( KURL url )
|
|
|
|
|
{
|
|
|
|
|
KFileItem entry( uds_entry, url,
|
|
|
|
|
true, // determine MIME type on demand
|
|
|
|
|
false ); // URL specifies tqparent directory
|
|
|
|
|
false ); // URL specifies parent directory
|
|
|
|
|
|
|
|
|
|
return entry.user();
|
|
|
|
|
}
|
|
|
|
@ -1276,7 +1276,7 @@ KDirTree::refresh( KFileInfo *subtree )
|
|
|
|
|
if ( ! _root )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if ( ! subtree || ! subtree->tqparent() ) // Refresh all (from root)
|
|
|
|
|
if ( ! subtree || ! subtree->parent() ) // Refresh all (from root)
|
|
|
|
|
{
|
|
|
|
|
startReading( fixedUrl( _root->url() ) );
|
|
|
|
|
}
|
|
|
|
@ -1285,7 +1285,7 @@ KDirTree::refresh( KFileInfo *subtree )
|
|
|
|
|
// Save some values from the old subtree.
|
|
|
|
|
|
|
|
|
|
KURL url = subtree->url();
|
|
|
|
|
KDirInfo * tqparent = subtree->tqparent();
|
|
|
|
|
KDirInfo * parent = subtree->parent();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Select nothing if the current selection is to be deleted
|
|
|
|
@ -1300,7 +1300,7 @@ KDirTree::refresh( KFileInfo *subtree )
|
|
|
|
|
// kdDebug() << "Deleting subtree " << subtree << endl;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This may sound stupid, but the tqparent must be told to unlink its
|
|
|
|
|
* This may sound stupid, but the parent must be told to unlink its
|
|
|
|
|
* child from the tqchildren list. The child cannot simply do this by
|
|
|
|
|
* itself in its destructor since at this point important parts of the
|
|
|
|
|
* object may already be destroyed, e.g., the virtual table -
|
|
|
|
@ -1308,7 +1308,7 @@ KDirTree::refresh( KFileInfo *subtree )
|
|
|
|
|
*
|
|
|
|
|
* I just found that out the hard way by several hours of debugging. ;-}
|
|
|
|
|
**/
|
|
|
|
|
tqparent->deletingChild( subtree );
|
|
|
|
|
parent->deletingChild( subtree );
|
|
|
|
|
delete subtree;
|
|
|
|
|
emit childDeleted();
|
|
|
|
|
|
|
|
|
@ -1316,7 +1316,7 @@ KDirTree::refresh( KFileInfo *subtree )
|
|
|
|
|
// Create new subtree root.
|
|
|
|
|
|
|
|
|
|
subtree = ( _readMethod == KDirReadLocal ) ?
|
|
|
|
|
KLocalDirReadJob::stat( url, this, tqparent ) : KAnyDirReadJob::stat( url, this, tqparent );
|
|
|
|
|
KLocalDirReadJob::stat( url, this, parent ) : KAnyDirReadJob::stat( url, this, parent );
|
|
|
|
|
|
|
|
|
|
// kdDebug() << "New subtree: " << subtree << endl;
|
|
|
|
|
|
|
|
|
@ -1324,7 +1324,7 @@ KDirTree::refresh( KFileInfo *subtree )
|
|
|
|
|
{
|
|
|
|
|
// Insert new subtree root into the tree hierarchy.
|
|
|
|
|
|
|
|
|
|
tqparent->insertChild( subtree );
|
|
|
|
|
parent->insertChild( subtree );
|
|
|
|
|
childAddedNotify( subtree );
|
|
|
|
|
|
|
|
|
|
if ( subtree->isDir() )
|
|
|
|
@ -1444,48 +1444,48 @@ void
|
|
|
|
|
KDirTree::deleteSubtree( KFileInfo *subtree )
|
|
|
|
|
{
|
|
|
|
|
// kdDebug() << "Deleting subtree " << subtree << endl;
|
|
|
|
|
KDirInfo *tqparent = subtree->tqparent();
|
|
|
|
|
KDirInfo *parent = subtree->parent();
|
|
|
|
|
|
|
|
|
|
if ( tqparent )
|
|
|
|
|
if ( parent )
|
|
|
|
|
{
|
|
|
|
|
// Give the tqparent of the child to be deleted a chance to unlink the
|
|
|
|
|
// Give the parent of the child to be deleted a chance to unlink the
|
|
|
|
|
// child from its tqchildren list and take care of internal summary
|
|
|
|
|
// fields
|
|
|
|
|
tqparent->deletingChild( subtree );
|
|
|
|
|
parent->deletingChild( subtree );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Send notification to anybody interested (e.g., to attached views)
|
|
|
|
|
deletingChildNotify( subtree );
|
|
|
|
|
|
|
|
|
|
if ( tqparent )
|
|
|
|
|
if ( parent )
|
|
|
|
|
{
|
|
|
|
|
if ( tqparent->isDotEntry() && ! tqparent->hasChildren() )
|
|
|
|
|
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 ( tqparent->tqparent() )
|
|
|
|
|
if ( parent->parent() )
|
|
|
|
|
{
|
|
|
|
|
if ( tqparent->tqparent()->isFinished() )
|
|
|
|
|
if ( parent->parent()->isFinished() )
|
|
|
|
|
{
|
|
|
|
|
// kdDebug() << "Removing empty dot entry " << tqparent << endl;
|
|
|
|
|
// kdDebug() << "Removing empty dot entry " << parent << endl;
|
|
|
|
|
|
|
|
|
|
deletingChildNotify( tqparent );
|
|
|
|
|
tqparent->tqparent()->setDotEntry( 0 );
|
|
|
|
|
deletingChildNotify( parent );
|
|
|
|
|
parent->parent()->setDotEntry( 0 );
|
|
|
|
|
|
|
|
|
|
delete tqparent;
|
|
|
|
|
delete parent;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // no tqparent - this should never happen (?)
|
|
|
|
|
else // no parent - this should never happen (?)
|
|
|
|
|
{
|
|
|
|
|
kdError() << "Internal error: Killing dot entry without tqparent " << tqparent << endl;
|
|
|
|
|
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 tqparent;
|
|
|
|
|
// delete parent;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|