File patch-r890050.diff of Package kdelibs4
Subject: handle updates to remote mimetypes
From: wstephenson@suse.de
Bug:
Patch-upstream: 890050
--- kio/kio/kdirlister_p.h (revision 890049)
+++ kio/kio/kdirlister_p.h (revision 890050)
@@ -369,11 +369,18 @@ private:
typedef QHash<QString /*url*/, KDirListerCacheDirectoryData> DirectoryDataHash;
DirectoryDataHash directoryData;
- // List of files that we have changed recently
+ // Set of local files that we have changed recently (according to KDirWatch)
+ // We temporize the notifications by keeping them 500ms in this list.
QSet<QString /*url*/> pendingUpdates;
// The timer for doing the delayed updates
QTimer pendingUpdateTimer;
+ // Set of remote files that have changed recently -- but we can't emit those
+ // changes yet, we need to wait for the "update" directory listing.
+ // The cmp() call can't differ mimetypes since they are determined on demand,
+ // this is why we need to remember those files here.
+ QSet<KFileItem*> pendingRemoteUpdates;
+
// the KDirNotify signals
OrgKdeKDirNotifyInterface *kdirnotify;
};
--- kio/kio/kdirlister.cpp (revision 890049)
+++ kio/kio/kdirlister.cpp (revision 890050)
@@ -24,9 +24,7 @@
#include "kdirlister_p.h"
#include <QtCore/QRegExp>
-#include <QtCore/QTimer>
-#include <kapplication.h>
#include <kdebug.h>
#include <kde_file.h>
#include <klocale.h>
@@ -792,40 +790,37 @@ void KDirListerCache::slotFilesRemoved(
void KDirListerCache::slotFilesChanged( const QStringList &fileList ) // from KDirNotify signals
{
- KUrl::List dirsToUpdate;
- kDebug(7004) << "only half implemented";
- QStringList::const_iterator it = fileList.begin();
- for ( ; it != fileList.end() ; ++it )
- {
- KUrl url( *it );
- if ( url.isLocalFile() )
- {
- KFileItem *fileitem = findByUrl( 0, url );
- if ( fileitem )
- {
- // we need to refresh the item, because e.g. the permissions can have changed.
- aboutToRefreshItem( *fileitem );
- KFileItem oldItem = *fileitem;
- fileitem->refresh();
- emitRefreshItem( oldItem, *fileitem );
- }
- else
- kDebug(7004) << "item not found";
- } else {
- // For remote files, refresh() won't be able to figure out the new information.
- // Let's update the dir.
- KUrl dir( url );
- dir.setPath( dir.directory() );
- if ( !dirsToUpdate.contains( dir ) )
- dirsToUpdate.prepend( dir );
+ KUrl::List dirsToUpdate;
+ QStringList::const_iterator it = fileList.begin();
+ for (; it != fileList.end() ; ++it) {
+ KUrl url( *it );
+ KFileItem *fileitem = findByUrl(0, url);
+ if (!fileitem) {
+ kDebug(7004) << "item not found for" << url;
+ continue;
+ }
+ if (url.isLocalFile()) {
+ // we need to refresh the item, because e.g. the permissions can have changed.
+ aboutToRefreshItem(*fileitem);
+ KFileItem oldItem = *fileitem;
+ fileitem->refresh();
+ emitRefreshItem(oldItem, *fileitem);
+ } else {
+ pendingRemoteUpdates.insert(fileitem);
+ // For remote files, we won't be able to figure out the new information,
+ // we have to do a update (directory listing)
+ KUrl dir(url);
+ dir.setPath(dir.directory());
+ if (!dirsToUpdate.contains(dir))
+ dirsToUpdate.prepend(dir);
+ }
}
- }
- KUrl::List::const_iterator itdir = dirsToUpdate.begin();
- for ( ; itdir != dirsToUpdate.end() ; ++itdir )
- updateDirectory( *itdir );
- // ## TODO problems with current jobs listing/updating that dir
- // ( see kde-2.2.2's kdirlister )
+ KUrl::List::const_iterator itdir = dirsToUpdate.begin();
+ for (; itdir != dirsToUpdate.end() ; ++itdir)
+ updateDirectory( *itdir );
+ // ## TODO problems with current jobs listing/updating that dir
+ // ( see kde-2.2.2's kdirlister )
}
void KDirListerCache::slotFileRenamed( const QString &_src, const QString &_dst ) // from KDirNotify signals
@@ -1517,12 +1512,17 @@ void KDirListerCache::slotUpdateResult(
}
// Find this item
- KFileItem *tmp = 0;
- if ( (tmp = fileItems.value(item.name())) )
+ if (KFileItem* tmp = fileItems.value(item.name()))
{
- // check if something changed for this file
- if ( !tmp->cmp( item ) )
- {
+ QSet<KFileItem*>::iterator pru_it = pendingRemoteUpdates.find(tmp);
+ const bool inPendingRemoteUpdates = (pru_it != pendingRemoteUpdates.end());
+
+ // check if something changed for this file, using KFileItem::cmp()
+ if (!tmp->cmp( item ) || inPendingRemoteUpdates) {
+
+ if (inPendingRemoteUpdates) {
+ pendingRemoteUpdates.erase(pru_it);
+ }
foreach ( KDirLister *kdl, listers )
kdl->d->aboutToRefreshItem( *tmp );
Index: kio/kio/kdirlister_p.h
===================================================================
Index: kio/kio/kdirlister.cpp
===================================================================