[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kio/kio
From:       David Faure <faure () kde ! org>
Date:       2009-01-20 2:04:01
Message-ID: 1232417041.517209.17184.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 913897 by dfaure:

Fix KDirLister::url() not being updated when the toplevel dir of that dirlister is \
renamed; my last changes to the unittest actually test for that, but somehow I must \
have missed that it reported a failure. The funny part is that the fix is to simply \
implement the TODO "### consider replacing this block with kdl->redirect(oldUrl, \
newUrl)..."


 M  +12 -17    kdirlister.cpp  
 M  +7 -1      kdirlister_p.h  


--- trunk/KDE/kdelibs/kio/kio/kdirlister.cpp #913896:913897
@@ -1159,7 +1159,7 @@
     Q_ASSERT( !listers.isEmpty() );
 
     foreach ( KDirLister *kdl, listers ) {
-        kdl->d->redirect(oldUrlStr, newUrl);
+        kdl->d->redirect(oldUrlStr, newUrl, false /*clear items*/);
     }
 
     // when a lister was stopped before the job emits the redirection signal, the \
old url will @@ -1171,7 +1171,7 @@
         // TODO: maybe don't emit started if there's an update running for newUrl \
already?  emit kdl->started( oldUrl );
 
-        kdl->d->redirect(oldUrl, newUrl);
+        kdl->d->redirect(oldUrl, newUrl, false /*clear items*/);
     }
 
     DirItem *newDir = itemsInUse.value(newUrlStr);
@@ -1416,14 +1416,7 @@
 
     // And notify the dirlisters of the redirection
     foreach ( KDirLister *kdl, holders ) {
-        // ### consider replacing this block with kdl->redirect(oldUrl, newUrl)...
-        KUrl::List& lstDirs = kdl->d->lstDirs;
-        lstDirs[ lstDirs.indexOf( oldUrl ) ] = newUrl;
-
-        if ( lstDirs.count() == 1 )
-            emit kdl->redirection( newUrl );
-
-        emit kdl->redirection( oldUrl, newUrl );
+        kdl->d->redirect(oldUrl, newUrl, true /*keep items*/);
     }
 }
 
@@ -2466,29 +2459,31 @@
 }
 
 // called by KDirListerCache::slotRedirection
-void KDirLister::Private::redirect( const KUrl& oldUrl, const KUrl& newUrl )
+void KDirLister::Private::redirect(const KUrl& oldUrl, const KUrl& newUrl, bool \
keepItems)  {
     if ( url.equals( oldUrl, KUrl::CompareWithoutTrailingSlash ) ) {
-        rootFileItem = KFileItem();
+        if (!keepItems)
+            rootFileItem = KFileItem();
         url = newUrl;
     }
 
     const int idx = lstDirs.indexOf( oldUrl );
     if (idx == -1) {
         kWarning(7004) << "Unexpected redirection from" << oldUrl << "to" << newUrl
-                       << "but this dirlister is currently listing" << lstDirs;
+                       << "but this dirlister is currently listing/holding" << \
lstDirs;  } else {
         lstDirs[ idx ] = newUrl;
     }
 
     if ( lstDirs.count() == 1 ) {
-        emit m_parent->clear();
+        if (!keepItems)
+            emit m_parent->clear();
         emit m_parent->redirection( newUrl );
-        emit m_parent->redirection( oldUrl, newUrl );
     } else {
-        emit m_parent->clear( oldUrl );
-        emit m_parent->redirection( oldUrl, newUrl );
+        if (!keepItems)
+            emit m_parent->clear( oldUrl );
     }
+    emit m_parent->redirection( oldUrl, newUrl );
 }
 
 void KDirListerCacheDirectoryData::moveListersWithoutCachedItemsJob()
--- trunk/KDE/kdelibs/kio/kio/kdirlister_p.h #913896:913897
@@ -86,9 +86,15 @@
   void emitItems();
   void emitDeleteItem( const KFileItem &item );
   void emitItemsDeleted(const KFileItemList &items);
-  void redirect( const KUrl& oldUrl, const KUrl& newUrl );
 
     /**
+     * Redirect this dirlister from oldUrl to newUrl.
+     * @param keepItems if true, keep the fileitems (e.g. when renaming an existing \
dir); +     * if false, clear out everything (e.g. when redirecting during listing).
+     */
+    void redirect(const KUrl& oldUrl, const KUrl& newUrl, bool keepItems);
+
+    /**
      * Should this item be visible according to the current filter settings?
      */
     bool isItemVisible(const KFileItem& item) const;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic