863
oldurl.adjustPath( KUrl::RemoveTrailingSlash );
864
KFileItem *fileitem = findByUrl( 0, oldurl );
863
oldurl.adjustPath( KUrl::RemoveTrailingSlash );
864
KFileItem *fileitem = findByUrl(0, oldurl);
866
kDebug(7004) << "Item not found:" << oldurl;
870
// Dest already exists? Was overwritten then (testcase: #151851)
871
// We better emit it as deleted -before- doing the renaming, otherwise
872
// the "update" mechanism will emit the old one as deleted and
873
// kdirmodel will delete the new (renamed) one!
874
KFileItem* existingDestItem = findByUrl(0, dst);
875
if (existingDestItem) {
876
//kDebug() << dst << "already existed, let's delete it";
877
slotFilesRemoved(dst);
866
880
// If the item had a UDS_URL as well as UDS_NAME set, the user probably wants
867
881
// to be updating the name only (since they can't see the URL).
868
882
// Check to see if a URL exists, and if so, if only the file part has changed,
869
883
// only update the name and not the underlying URL.
870
bool nameOnly = fileitem && !fileitem->entry().stringValue( KIO::UDSEntry::UDS_URL ).isEmpty();
884
bool nameOnly = !fileitem->entry().stringValue( KIO::UDSEntry::UDS_URL ).isEmpty();
871
885
nameOnly &= src.directory( KUrl::IgnoreTrailingSlash | KUrl::AppendTrailingSlash ) ==
872
886
dst.directory( KUrl::IgnoreTrailingSlash | KUrl::AppendTrailingSlash );
874
if (!nameOnly && (!fileitem || fileitem->isDir())) {
888
if (!nameOnly && fileitem->isDir()) {
875
889
renameDir( src, dst );
876
890
// #172945 - if the fileitem was the root item of a DirItem that was just removed from the cache,
877
891
// then it's a dangling pointer now...
878
892
fileitem = findByUrl( 0, oldurl );
881
// Now update the KFileItem representing that file or dir (not exclusive with the above!)
895
// Now update the KFileItem representing that file or dir (not exclusive with the above!)
884
896
if ( !fileitem->isLocalFile() && !fileitem->localPath().isEmpty() ) // it uses UDS_LOCAL_PATH? ouch, needs an update then
885
897
slotFilesChanged( QStringList() << src.url() );
888
// Dest already exists? Was overwritten then (testcase: #151851)
889
// We better emit it as deleted -before- doing the renaming, otherwise
890
// the "update" mechanism will emit the old one as deleted and
891
// kdirmodel will delete the new (renamed) one!
892
KFileItem* existingDestItem = findByUrl(0, dst);
893
if (existingDestItem) {
894
//kDebug() << dst << "already existed, let's delete it";
895
slotFilesRemoved(dst);
898
900
aboutToRefreshItem( *fileitem );
899
901
const KFileItem oldItem = *fileitem;