[PATCH] Renaming entries with KDirLister

Jeff Mitchell kde-dev at emailgoeshere.com
Tue Jul 31 21:10:55 BST 2007


The attached patch fixes a problem that I run into when writing a custom 
kioslave.

Entries (directories or files) are returned from a slave to the 
requestor via UDSEntry objects.  These objects must have a UDS_NAME 
property defined; usually this UDS_NAME property is appended to the 
directory to form the full path/url.

However, it is possible to define a separate UDS_URL.  If this is done, 
the UDS_NAME becomes the "display name" shown in a file browser whereas 
the UDS_URL becomes the actual object URL that is accessed when you i.e. 
double-click on it.

At the moment a rename operation on such an object will modify both 
properties.  If a UDS_URL is set, this is almost certainly not what the 
user wants to do, as the URL is not visible to the user anyways -- 
instead, the user wanted to modify the "display name" associated with 
the URL.  The result is that the name looks correct in the file browser, 
but links to an invalid URL.

A couple points:
* Dolphin (at least) will display the URL instead of the "display name" 
when the user chooses to rename the file.  This is rather weird 
behavior, but I'm not sure if this is Dolphin-specific or not.
* Another way around this, but more hacky, is to call a 
KDirNotify::emitFileAdded on the directory, causing a re-list.  
Obviously this can have performance problems, but there is also a race 
condition between the fileAdded call and the fileRenamed call (that is 
automatically sent by Job when the slave is finished), so that sometimes 
doing this works, but not always.  This race condition should probably 
get sorted out anyways but I so far have not had luck figuring it out.

Comments appreciated.

Thanks,
Jeff
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: kdirlister.cpp.patch
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070731/a98e83b2/attachment.ksh>


More information about the kde-core-devel mailing list