|
|
@ -90,14 +90,27 @@ KDirListerCache::~KDirListerCache()
|
|
|
|
bool KDirListerCache::listDir( KDirLister *lister, const KURL& _u,
|
|
|
|
bool KDirListerCache::listDir( KDirLister *lister, const KURL& _u,
|
|
|
|
bool _keep, bool _reload )
|
|
|
|
bool _keep, bool _reload )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// HACK
|
|
|
|
|
|
|
|
// The media:/ tdeioslave has massive problems related to not properly updating its root directory
|
|
|
|
|
|
|
|
// Therefore, force a reload every time the media:/ tdeioslave root is accessed!
|
|
|
|
|
|
|
|
// FIXME
|
|
|
|
|
|
|
|
// For anyone wanting to tackle this problem, it was traced into the KDirListerCache::updateDirectory TDEIO::listDir TDEIO job
|
|
|
|
|
|
|
|
// Specifically, slotUpdateResult is never called for the root directory *iff* the user descends into an unmounted media device
|
|
|
|
|
|
|
|
// Strangely, slotUpdateResult *is* called if the user instead right-clicks on the unmounted media device and selects Mount from the context menu
|
|
|
|
|
|
|
|
if ((_u.protocol() == "media") && (_u.path() == "/")) {
|
|
|
|
|
|
|
|
_reload = true;
|
|
|
|
|
|
|
|
_keep = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// like this we don't have to worry about trailing slashes any further
|
|
|
|
// like this we don't have to worry about trailing slashes any further
|
|
|
|
KURL _url = _u;
|
|
|
|
KURL _url = _u;
|
|
|
|
_url.cleanPath(); // kill consecutive slashes
|
|
|
|
_url.cleanPath(); // kill consecutive slashes
|
|
|
|
_url.adjustPath(-1);
|
|
|
|
_url.adjustPath(-1);
|
|
|
|
TQString urlStr = _url.url();
|
|
|
|
TQString urlStr = _url.url();
|
|
|
|
|
|
|
|
|
|
|
|
if ( !lister->validURL( _url ) )
|
|
|
|
if ( !lister->validURL( _url ) ) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_CACHE
|
|
|
|
#ifdef DEBUG_CACHE
|
|
|
|
printDebug();
|
|
|
|
printDebug();
|
|
|
@ -165,8 +178,9 @@ bool KDirListerCache::listDir( KDirLister *lister, const KURL& _u,
|
|
|
|
if ( lister->d->complete )
|
|
|
|
if ( lister->d->complete )
|
|
|
|
emit lister->completed();
|
|
|
|
emit lister->completed();
|
|
|
|
|
|
|
|
|
|
|
|
if ( _reload || !itemU->complete )
|
|
|
|
if ( _reload || !itemU->complete ) {
|
|
|
|
updateDirectory( _url );
|
|
|
|
updateDirectory( _url );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( !_reload && (itemC = itemsCached.take( urlStr )) )
|
|
|
|
else if ( !_reload && (itemC = itemsCached.take( urlStr )) )
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -181,8 +195,9 @@ bool KDirListerCache::listDir( KDirLister *lister, const KURL& _u,
|
|
|
|
|
|
|
|
|
|
|
|
emit lister->started( _url );
|
|
|
|
emit lister->started( _url );
|
|
|
|
|
|
|
|
|
|
|
|
if ( !lister->d->rootFileItem && lister->d->url == _url )
|
|
|
|
if ( !lister->d->rootFileItem && lister->d->url == _url ) {
|
|
|
|
lister->d->rootFileItem = itemC->rootItem;
|
|
|
|
lister->d->rootFileItem = itemC->rootItem;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lister->addNewItems( *(itemC->lstItems) );
|
|
|
|
lister->addNewItems( *(itemC->lstItems) );
|
|
|
|
lister->emitItems();
|
|
|
|
lister->emitItems();
|
|
|
@ -198,8 +213,9 @@ bool KDirListerCache::listDir( KDirLister *lister, const KURL& _u,
|
|
|
|
if ( lister->d->complete )
|
|
|
|
if ( lister->d->complete )
|
|
|
|
emit lister->completed();
|
|
|
|
emit lister->completed();
|
|
|
|
|
|
|
|
|
|
|
|
if ( !itemC->complete )
|
|
|
|
if ( !itemC->complete ) {
|
|
|
|
updateDirectory( _url );
|
|
|
|
updateDirectory( _url );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // dir not in cache or _reload is true
|
|
|
|
else // dir not in cache or _reload is true
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -539,8 +555,9 @@ void KDirListerCache::updateDirectory( const KURL& _dir )
|
|
|
|
kdDebug(7004) << k_funcinfo << _dir << endl;
|
|
|
|
kdDebug(7004) << k_funcinfo << _dir << endl;
|
|
|
|
|
|
|
|
|
|
|
|
TQString urlStr = _dir.url(-1);
|
|
|
|
TQString urlStr = _dir.url(-1);
|
|
|
|
if ( !checkUpdate( urlStr ) )
|
|
|
|
if ( !checkUpdate( urlStr ) ) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// A job can be running to
|
|
|
|
// A job can be running to
|
|
|
|
// - only list a new directory: the listers are in urlsCurrentlyListed
|
|
|
|
// - only list a new directory: the listers are in urlsCurrentlyListed
|
|
|
@ -562,13 +579,17 @@ void KDirListerCache::updateDirectory( const KURL& _dir )
|
|
|
|
killJob( job );
|
|
|
|
killJob( job );
|
|
|
|
killed = true;
|
|
|
|
killed = true;
|
|
|
|
|
|
|
|
|
|
|
|
if ( listers )
|
|
|
|
if ( listers ) {
|
|
|
|
for ( KDirLister *kdl = listers->first(); kdl; kdl = listers->next() )
|
|
|
|
for ( KDirLister *kdl = listers->first(); kdl; kdl = listers->next() ) {
|
|
|
|
kdl->jobDone( job );
|
|
|
|
kdl->jobDone( job );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( holders )
|
|
|
|
if ( holders ) {
|
|
|
|
for ( KDirLister *kdl = holders->first(); kdl; kdl = holders->next() )
|
|
|
|
for ( KDirLister *kdl = holders->first(); kdl; kdl = holders->next() ) {
|
|
|
|
kdl->jobDone( job );
|
|
|
|
kdl->jobDone( job );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
kdDebug(7004) << k_funcinfo << "Killed = " << killed << endl;
|
|
|
|
kdDebug(7004) << k_funcinfo << "Killed = " << killed << endl;
|
|
|
|
|
|
|
|
|
|
|
@ -587,9 +608,11 @@ void KDirListerCache::updateDirectory( const KURL& _dir )
|
|
|
|
|
|
|
|
|
|
|
|
kdDebug(7004) << k_funcinfo << "update started in " << _dir << endl;
|
|
|
|
kdDebug(7004) << k_funcinfo << "update started in " << _dir << endl;
|
|
|
|
|
|
|
|
|
|
|
|
if ( listers )
|
|
|
|
if ( listers ) {
|
|
|
|
for ( KDirLister *kdl = listers->first(); kdl; kdl = listers->next() )
|
|
|
|
for ( KDirLister *kdl = listers->first(); kdl; kdl = listers->next() ) {
|
|
|
|
kdl->jobStarted( job );
|
|
|
|
kdl->jobStarted( job );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( holders )
|
|
|
|
if ( holders )
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -611,8 +634,9 @@ void KDirListerCache::updateDirectory( const KURL& _dir )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
job->setWindow( window );
|
|
|
|
job->setWindow( window );
|
|
|
|
|
|
|
|
|
|
|
|
for ( KDirLister *kdl = holders->first(); kdl; kdl = holders->next() )
|
|
|
|
for ( KDirLister *kdl = holders->first(); kdl; kdl = holders->next() ) {
|
|
|
|
kdl->jobStarted( job );
|
|
|
|
kdl->jobStarted( job );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -642,8 +666,9 @@ KFileItemList *KDirListerCache::itemsForDir( const KURL &_dir ) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQString urlStr = _dir.url(-1);
|
|
|
|
TQString urlStr = _dir.url(-1);
|
|
|
|
DirItem *item = itemsInUse[ urlStr ];
|
|
|
|
DirItem *item = itemsInUse[ urlStr ];
|
|
|
|
if ( !item )
|
|
|
|
if ( !item ) {
|
|
|
|
item = itemsCached[ urlStr ];
|
|
|
|
item = itemsCached[ urlStr ];
|
|
|
|
|
|
|
|
}
|
|
|
|
return item ? item->lstItems : 0;
|
|
|
|
return item ? item->lstItems : 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -755,21 +780,24 @@ void KDirListerCache::FilesChanged( const KURL::List &fileList )
|
|
|
|
fileitem->refresh();
|
|
|
|
fileitem->refresh();
|
|
|
|
emitRefreshItem( fileitem );
|
|
|
|
emitRefreshItem( fileitem );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else {
|
|
|
|
kdDebug(7004) << "item not found" << endl;
|
|
|
|
kdDebug(7004) << "item not found" << endl;
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// For remote files, refresh() won't be able to figure out the new information.
|
|
|
|
// For remote files, refresh() won't be able to figure out the new information.
|
|
|
|
// Let's update the dir.
|
|
|
|
// Let's update the dir.
|
|
|
|
KURL dir( *it );
|
|
|
|
KURL dir( *it );
|
|
|
|
dir.setPath( dir.directory( true ) );
|
|
|
|
dir.setPath( dir.directory( true ) );
|
|
|
|
if ( dirsToUpdate.find( dir ) == dirsToUpdate.end() )
|
|
|
|
if ( dirsToUpdate.find( dir ) == dirsToUpdate.end() ) {
|
|
|
|
dirsToUpdate.prepend( dir );
|
|
|
|
dirsToUpdate.prepend( dir );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KURL::List::ConstIterator itdir = dirsToUpdate.begin();
|
|
|
|
KURL::List::ConstIterator itdir = dirsToUpdate.begin();
|
|
|
|
for ( ; itdir != dirsToUpdate.end() ; ++itdir )
|
|
|
|
for ( ; itdir != dirsToUpdate.end() ; ++itdir ) {
|
|
|
|
updateDirectory( *itdir );
|
|
|
|
updateDirectory( *itdir );
|
|
|
|
|
|
|
|
}
|
|
|
|
// ## TODO problems with current jobs listing/updating that dir
|
|
|
|
// ## TODO problems with current jobs listing/updating that dir
|
|
|
|
// ( see kde-2.2.2's kdirlister )
|
|
|
|
// ( see kde-2.2.2's kdirlister )
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -873,8 +901,9 @@ void KDirListerCache::slotFileDirty( const TQString& _file )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
KURL dir;
|
|
|
|
KURL dir;
|
|
|
|
dir.setPath( _file );
|
|
|
|
dir.setPath( _file );
|
|
|
|
if ( checkUpdate( dir.url(-1) ) )
|
|
|
|
if ( checkUpdate( dir.url(-1) ) ) {
|
|
|
|
updateDirectory( dir );
|
|
|
|
updateDirectory( dir );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// the parent directory of _file
|
|
|
|
// the parent directory of _file
|
|
|
|
dir.setPath( dir.directory() );
|
|
|
|
dir.setPath( dir.directory() );
|
|
|
@ -979,9 +1008,11 @@ void KDirListerCache::slotEntries( TDEIO::Job *job, const TDEIO::UDSEntryList &e
|
|
|
|
Q_ASSERT( !dir->rootItem );
|
|
|
|
Q_ASSERT( !dir->rootItem );
|
|
|
|
dir->rootItem = new KFileItem( *it, url, delayedMimeTypes, true );
|
|
|
|
dir->rootItem = new KFileItem( *it, url, delayedMimeTypes, true );
|
|
|
|
|
|
|
|
|
|
|
|
for ( KDirLister *kdl = listers->first(); kdl; kdl = listers->next() )
|
|
|
|
for ( KDirLister *kdl = listers->first(); kdl; kdl = listers->next() ) {
|
|
|
|
if ( !kdl->d->rootFileItem && kdl->d->url == url )
|
|
|
|
if ( !kdl->d->rootFileItem && kdl->d->url == url ) {
|
|
|
|
kdl->d->rootFileItem = dir->rootItem;
|
|
|
|
kdl->d->rootFileItem = dir->rootItem;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( name != dotdot )
|
|
|
|
else if ( name != dotdot )
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -991,13 +1022,15 @@ void KDirListerCache::slotEntries( TDEIO::Job *job, const TDEIO::UDSEntryList &e
|
|
|
|
//kdDebug(7004)<< "Adding item: " << item->url() << endl;
|
|
|
|
//kdDebug(7004)<< "Adding item: " << item->url() << endl;
|
|
|
|
dir->lstItems->append( item );
|
|
|
|
dir->lstItems->append( item );
|
|
|
|
|
|
|
|
|
|
|
|
for ( KDirLister *kdl = listers->first(); kdl; kdl = listers->next() )
|
|
|
|
for ( KDirLister *kdl = listers->first(); kdl; kdl = listers->next() ) {
|
|
|
|
kdl->addNewItem( item );
|
|
|
|
kdl->addNewItem( item );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for ( KDirLister *kdl = listers->first(); kdl; kdl = listers->next() )
|
|
|
|
for ( KDirLister *kdl = listers->first(); kdl; kdl = listers->next() ) {
|
|
|
|
kdl->emitItems();
|
|
|
|
kdl->emitItems();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KDirListerCache::slotResult( TDEIO::Job *j )
|
|
|
|
void KDirListerCache::slotResult( TDEIO::Job *j )
|
|
|
@ -1524,8 +1557,9 @@ void KDirListerCache::slotUpdateResult( TDEIO::Job * j )
|
|
|
|
|
|
|
|
|
|
|
|
// check if anyone wants the mimetypes immediately
|
|
|
|
// check if anyone wants the mimetypes immediately
|
|
|
|
bool delayedMimeTypes = true;
|
|
|
|
bool delayedMimeTypes = true;
|
|
|
|
for ( kdl = listers->first(); kdl; kdl = listers->next() )
|
|
|
|
for ( kdl = listers->first(); kdl; kdl = listers->next() ) {
|
|
|
|
delayedMimeTypes = delayedMimeTypes && kdl->d->delayedMimeTypes;
|
|
|
|
delayedMimeTypes = delayedMimeTypes && kdl->d->delayedMimeTypes;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// should be enough to get reasonable speed in most cases
|
|
|
|
// should be enough to get reasonable speed in most cases
|
|
|
|
TQDict<KFileItem> fileItems( 9973 );
|
|
|
|
TQDict<KFileItem> fileItems( 9973 );
|
|
|
@ -1536,7 +1570,12 @@ void KDirListerCache::slotUpdateResult( TDEIO::Job * j )
|
|
|
|
for ( ; kit.current(); ++kit )
|
|
|
|
for ( ; kit.current(); ++kit )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
(*kit)->unmark();
|
|
|
|
(*kit)->unmark();
|
|
|
|
fileItems.insert( (*kit)->url().url(), *kit );
|
|
|
|
if (!((*kit)->listerURL().isEmpty())) {
|
|
|
|
|
|
|
|
fileItems.insert( (*kit)->listerURL().url(), *kit );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
fileItems.insert( (*kit)->url().url(), *kit );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const TQString& dot = TDEGlobal::staticQString(".");
|
|
|
|
static const TQString& dot = TDEGlobal::staticQString(".");
|
|
|
@ -1549,10 +1588,12 @@ void KDirListerCache::slotUpdateResult( TDEIO::Job * j )
|
|
|
|
for ( ; it != buf.end(); ++it )
|
|
|
|
for ( ; it != buf.end(); ++it )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Form the complete url
|
|
|
|
// Form the complete url
|
|
|
|
if ( !item )
|
|
|
|
if ( !item ) {
|
|
|
|
item = new KFileItem( *it, jobUrl, delayedMimeTypes, true );
|
|
|
|
item = new KFileItem( *it, jobUrl, delayedMimeTypes, true );
|
|
|
|
else
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
item->setUDSEntry( *it, jobUrl, delayedMimeTypes, true );
|
|
|
|
item->setUDSEntry( *it, jobUrl, delayedMimeTypes, true );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Find out about the name
|
|
|
|
// Find out about the name
|
|
|
|
TQString name = item->name();
|
|
|
|
TQString name = item->name();
|
|
|
@ -1560,8 +1601,9 @@ void KDirListerCache::slotUpdateResult( TDEIO::Job * j )
|
|
|
|
|
|
|
|
|
|
|
|
// we duplicate the check for dotdot here, to avoid iterating over
|
|
|
|
// we duplicate the check for dotdot here, to avoid iterating over
|
|
|
|
// all items again and checking in matchesFilter() that way.
|
|
|
|
// all items again and checking in matchesFilter() that way.
|
|
|
|
if ( name.isEmpty() || name == dotdot )
|
|
|
|
if ( name.isEmpty() || name == dotdot ) {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( name == dot )
|
|
|
|
if ( name == dot )
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1572,9 +1614,11 @@ void KDirListerCache::slotUpdateResult( TDEIO::Job * j )
|
|
|
|
dir->rootItem = item;
|
|
|
|
dir->rootItem = item;
|
|
|
|
item = 0;
|
|
|
|
item = 0;
|
|
|
|
|
|
|
|
|
|
|
|
for ( KDirLister *kdl = listers->first(); kdl; kdl = listers->next() )
|
|
|
|
for ( KDirLister *kdl = listers->first(); kdl; kdl = listers->next() ) {
|
|
|
|
if ( !kdl->d->rootFileItem && kdl->d->url == jobUrl )
|
|
|
|
if ( !kdl->d->rootFileItem && kdl->d->url == jobUrl ) {
|
|
|
|
kdl->d->rootFileItem = dir->rootItem;
|
|
|
|
kdl->d->rootFileItem = dir->rootItem;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
@ -1588,14 +1632,16 @@ void KDirListerCache::slotUpdateResult( TDEIO::Job * j )
|
|
|
|
// check if something changed for this file
|
|
|
|
// check if something changed for this file
|
|
|
|
if ( !tmp->cmp( *item ) )
|
|
|
|
if ( !tmp->cmp( *item ) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for ( kdl = listers->first(); kdl; kdl = listers->next() )
|
|
|
|
for ( kdl = listers->first(); kdl; kdl = listers->next() ) {
|
|
|
|
kdl->aboutToRefreshItem( tmp );
|
|
|
|
kdl->aboutToRefreshItem( tmp );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//kdDebug(7004) << "slotUpdateResult: file changed: " << tmp->name() << endl;
|
|
|
|
//kdDebug(7004) << "slotUpdateResult: file changed: " << tmp->name() << endl;
|
|
|
|
tmp->assign( *item );
|
|
|
|
tmp->assign( *item );
|
|
|
|
|
|
|
|
|
|
|
|
for ( kdl = listers->first(); kdl; kdl = listers->next() )
|
|
|
|
for ( kdl = listers->first(); kdl; kdl = listers->next() ) {
|
|
|
|
kdl->addRefreshItem( tmp );
|
|
|
|
kdl->addRefreshItem( tmp );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // this is a new file
|
|
|
|
else // this is a new file
|
|
|
@ -1605,16 +1651,18 @@ void KDirListerCache::slotUpdateResult( TDEIO::Job * j )
|
|
|
|
item->mark();
|
|
|
|
item->mark();
|
|
|
|
dir->lstItems->append( item );
|
|
|
|
dir->lstItems->append( item );
|
|
|
|
|
|
|
|
|
|
|
|
for ( kdl = listers->first(); kdl; kdl = listers->next() )
|
|
|
|
for ( kdl = listers->first(); kdl; kdl = listers->next() ) {
|
|
|
|
kdl->addNewItem( item );
|
|
|
|
kdl->addNewItem( item );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// item used, we need a new one for the next iteration
|
|
|
|
// item used, we need a new one for the next iteration
|
|
|
|
item = 0;
|
|
|
|
item = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( item )
|
|
|
|
if ( item ) {
|
|
|
|
delete item;
|
|
|
|
delete item;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
jobs.remove( job );
|
|
|
|
jobs.remove( job );
|
|
|
|
|
|
|
|
|
|
|
@ -1866,6 +1914,7 @@ bool KDirLister::openURL( const KURL& _url, bool _keep, bool _reload )
|
|
|
|
|
|
|
|
|
|
|
|
// If a local path is available, monitor that instead of the given remote URL...
|
|
|
|
// If a local path is available, monitor that instead of the given remote URL...
|
|
|
|
KURL realURL = _url;
|
|
|
|
KURL realURL = _url;
|
|
|
|
|
|
|
|
d->providedURL = _url;
|
|
|
|
if (!realURL.isLocalFile()) {
|
|
|
|
if (!realURL.isLocalFile()) {
|
|
|
|
TDEIO::LocalURLJob* localURLJob = TDEIO::localURL(_url);
|
|
|
|
TDEIO::LocalURLJob* localURLJob = TDEIO::localURL(_url);
|
|
|
|
if (localURLJob) {
|
|
|
|
if (localURLJob) {
|
|
|
@ -1882,6 +1931,7 @@ bool KDirLister::openURL( const KURL& _url, bool _keep, bool _reload )
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
d->listerURL = realURL;
|
|
|
|
return s_pCache->listDir( this, realURL, _keep, _reload );
|
|
|
|
return s_pCache->listDir( this, realURL, _keep, _reload );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -2015,8 +2065,9 @@ void KDirLister::emitChanges()
|
|
|
|
if ( !(*kit)->isDir() )
|
|
|
|
if ( !(*kit)->isDir() )
|
|
|
|
emit deleteItem( *kit );
|
|
|
|
emit deleteItem( *kit );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( !(*kit)->isDir() )
|
|
|
|
else if ( !(*kit)->isDir() ) {
|
|
|
|
addNewItem( *kit );
|
|
|
|
addNewItem( *kit );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2026,10 +2077,12 @@ void KDirLister::emitChanges()
|
|
|
|
if ( d->changes & DOT_FILES )
|
|
|
|
if ( d->changes & DOT_FILES )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// the lister switched to dot files mode
|
|
|
|
// the lister switched to dot files mode
|
|
|
|
if ( d->isShowingDotFiles )
|
|
|
|
if ( d->isShowingDotFiles ) {
|
|
|
|
addNewItem( *kit );
|
|
|
|
addNewItem( *kit );
|
|
|
|
else
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
emit deleteItem( *kit );
|
|
|
|
emit deleteItem( *kit );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2049,12 +2102,14 @@ void KDirLister::emitChanges()
|
|
|
|
emit deleteItem( *kit );
|
|
|
|
emit deleteItem( *kit );
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( !oldName && newName )
|
|
|
|
else if ( !oldName && newName ) {
|
|
|
|
addNewItem( *kit );
|
|
|
|
addNewItem( *kit );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( (d->changes & MIME_FILTER) && !oldMime && newMime )
|
|
|
|
if ( (d->changes & MIME_FILTER) && !oldMime && newMime ) {
|
|
|
|
addNewItem( *kit );
|
|
|
|
addNewItem( *kit );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
emitItems();
|
|
|
|
emitItems();
|
|
|
@ -2250,8 +2305,9 @@ bool KDirLister::validURL( const KURL& _url ) const
|
|
|
|
|
|
|
|
|
|
|
|
void KDirLister::handleError( TDEIO::Job *job )
|
|
|
|
void KDirLister::handleError( TDEIO::Job *job )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( d->autoErrorHandling )
|
|
|
|
if ( d->autoErrorHandling ) {
|
|
|
|
job->showErrorDialog( d->errorParent );
|
|
|
|
job->showErrorDialog( d->errorParent );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -2259,20 +2315,35 @@ void KDirLister::handleError( TDEIO::Job *job )
|
|
|
|
|
|
|
|
|
|
|
|
void KDirLister::addNewItem( const KFileItem *item )
|
|
|
|
void KDirLister::addNewItem( const KFileItem *item )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( ( d->dirOnlyMode && !item->isDir() ) || !matchesFilter( item ) )
|
|
|
|
if ( ( d->dirOnlyMode && !item->isDir() ) || !matchesFilter( item ) ) {
|
|
|
|
return; // No reason to continue... bailing out here prevents a mimetype scan.
|
|
|
|
return; // No reason to continue... bailing out here prevents a mimetype scan.
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (d->listerURL != d->providedURL) {
|
|
|
|
|
|
|
|
// Likely a media:/ tdeioslave URL or similar
|
|
|
|
|
|
|
|
// Rewrite the URL to ensure that the user remains within the media:/ tree!
|
|
|
|
|
|
|
|
TQString itemPath = item->url().path();
|
|
|
|
|
|
|
|
if (itemPath.startsWith(d->listerURL.path())) {
|
|
|
|
|
|
|
|
itemPath = itemPath.remove(0, d->listerURL.path().length());
|
|
|
|
|
|
|
|
itemPath = d->providedURL.pathOrURL() + itemPath;
|
|
|
|
|
|
|
|
const_cast<KFileItem*>(item)->setListerURL(item->url());
|
|
|
|
|
|
|
|
const_cast<KFileItem*>(item)->setURL(itemPath);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( matchesMimeFilter( item ) )
|
|
|
|
if ( matchesMimeFilter( item ) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( !d->lstNewItems )
|
|
|
|
if ( !d->lstNewItems ) {
|
|
|
|
d->lstNewItems = new KFileItemList;
|
|
|
|
d->lstNewItems = new KFileItemList;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
d->lstNewItems->append( item ); // items not filtered
|
|
|
|
d->lstNewItems->append( item ); // items not filtered
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( !d->lstMimeFilteredItems )
|
|
|
|
if ( !d->lstMimeFilteredItems ) {
|
|
|
|
d->lstMimeFilteredItems = new KFileItemList;
|
|
|
|
d->lstMimeFilteredItems = new KFileItemList;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
d->lstMimeFilteredItems->append( item ); // only filtered by mime
|
|
|
|
d->lstMimeFilteredItems->append( item ); // only filtered by mime
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2284,8 +2355,9 @@ void KDirLister::addNewItems( const KFileItemList& items )
|
|
|
|
// DF: was this profiled? The matchesFoo() functions should be fast, w/o filters...
|
|
|
|
// DF: was this profiled? The matchesFoo() functions should be fast, w/o filters...
|
|
|
|
// Of course if there is no filter and we can do a range-insertion instead of a loop, that might be good.
|
|
|
|
// Of course if there is no filter and we can do a range-insertion instead of a loop, that might be good.
|
|
|
|
// But that's for Qt4, not possible with TQPtrList.
|
|
|
|
// But that's for Qt4, not possible with TQPtrList.
|
|
|
|
for ( KFileItemListIterator kit( items ); kit.current(); ++kit )
|
|
|
|
for ( KFileItemListIterator kit( items ); kit.current(); ++kit ) {
|
|
|
|
addNewItem( *kit );
|
|
|
|
addNewItem( *kit );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KDirLister::aboutToRefreshItem( const KFileItem *item )
|
|
|
|
void KDirLister::aboutToRefreshItem( const KFileItem *item )
|
|
|
@ -2307,23 +2379,26 @@ void KDirLister::addRefreshItem( const KFileItem *item )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( d->refreshItemWasFiltered )
|
|
|
|
if ( d->refreshItemWasFiltered )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( !d->lstNewItems )
|
|
|
|
if ( !d->lstNewItems ) {
|
|
|
|
d->lstNewItems = new KFileItemList;
|
|
|
|
d->lstNewItems = new KFileItemList;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
d->lstNewItems->append( item );
|
|
|
|
d->lstNewItems->append( item );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( !d->lstRefreshItems )
|
|
|
|
if ( !d->lstRefreshItems ) {
|
|
|
|
d->lstRefreshItems = new KFileItemList;
|
|
|
|
d->lstRefreshItems = new KFileItemList;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
d->lstRefreshItems->append( item );
|
|
|
|
d->lstRefreshItems->append( item );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( !d->refreshItemWasFiltered )
|
|
|
|
else if ( !d->refreshItemWasFiltered )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( !d->lstRemoveItems )
|
|
|
|
if ( !d->lstRemoveItems ) {
|
|
|
|
d->lstRemoveItems = new KFileItemList;
|
|
|
|
d->lstRemoveItems = new KFileItemList;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// notify the user that the mimetype of a file changed that doesn't match
|
|
|
|
// notify the user that the mimetype of a file changed that doesn't match
|
|
|
|
// a filter or does match an exclude filter
|
|
|
|
// a filter or does match an exclude filter
|
|
|
@ -2365,8 +2440,9 @@ void KDirLister::emitItems()
|
|
|
|
|
|
|
|
|
|
|
|
if ( tmpRemove )
|
|
|
|
if ( tmpRemove )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for ( KFileItem *tmp = tmpRemove->first(); tmp; tmp = tmpRemove->next() )
|
|
|
|
for ( KFileItem *tmp = tmpRemove->first(); tmp; tmp = tmpRemove->next() ) {
|
|
|
|
emit deleteItem( tmp );
|
|
|
|
emit deleteItem( tmp );
|
|
|
|
|
|
|
|
}
|
|
|
|
delete tmpRemove;
|
|
|
|
delete tmpRemove;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2510,19 +2586,22 @@ KFileItemList KDirLister::itemsForDir( const KURL& dir, WhichItems which ) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
KFileItemList result;
|
|
|
|
KFileItemList result;
|
|
|
|
KFileItemList *allItems = s_pCache->itemsForDir( dir );
|
|
|
|
KFileItemList *allItems = s_pCache->itemsForDir( dir );
|
|
|
|
if ( !allItems )
|
|
|
|
if ( !allItems ) {
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( which == AllItems )
|
|
|
|
if ( which == AllItems ) {
|
|
|
|
result = *allItems; // shallow copy
|
|
|
|
result = *allItems; // shallow copy
|
|
|
|
|
|
|
|
}
|
|
|
|
else // only items passing the filters
|
|
|
|
else // only items passing the filters
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for ( KFileItemListIterator kit( *allItems ); kit.current(); ++kit )
|
|
|
|
for ( KFileItemListIterator kit( *allItems ); kit.current(); ++kit )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
KFileItem *item = *kit;
|
|
|
|
KFileItem *item = *kit;
|
|
|
|
bool isExcluded = (d->dirOnlyMode && !item->isDir()) || !matchesFilter( item );
|
|
|
|
bool isExcluded = (d->dirOnlyMode && !item->isDir()) || !matchesFilter( item );
|
|
|
|
if ( !isExcluded && matchesMimeFilter( item ) )
|
|
|
|
if ( !isExcluded && matchesMimeFilter( item ) ) {
|
|
|
|
result.append( item );
|
|
|
|
result.append( item );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|