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

List:       kde-core-devel
Subject:    Re: [PATCH] UDS_TARGET_URL and UDS_DISPLAY_NAME
From:       nf2 <nf2 () scheinwelt ! at>
Date:       2008-02-29 16:36:14
Message-ID: 47C8347E.2090300 () scheinwelt ! at
[Download RAW message or body]

David Faure wrote:
>
> assuming you change KFileItem::targetUrl() to return the same as url() if UDS_TARGET_URL is not set
> (I think it would make things simpler in the application code in all cases)
>
>
>   

Here are the new patches, which implement this behavior for 
KFileItem::targetUrl() and also make Konqueror and Dolphin use the new API.

Any objections? If not, feel free to commit. :-)

Cheers,
Norbert




["kdelibs_uds_target_url2.patch" (text/x-patch)]

Index: kfile/kdiroperator.cpp
===================================================================
--- kfile/kdiroperator.cpp	(revision 777170)
+++ kfile/kdiroperator.cpp	(working copy)
@@ -1453,7 +1453,7 @@
 
 void KDirOperator::selectDir(const KFileItem &item)
 {
-    setUrl(item.url(), true);
+    setUrl(item.targetUrl(), true);
 }
 
 void KDirOperator::selectFile(const KFileItem &item)
Index: kio/kio/kfileitem.cpp
===================================================================
--- kio/kio/kfileitem.cpp	(revision 777170)
+++ kio/kio/kfileitem.cpp	(working copy)
@@ -260,7 +260,13 @@
     m_fileMode = m_entry.numberValue( KIO::UDSEntry::UDS_FILE_TYPE );
     m_permissions = m_entry.numberValue( KIO::UDSEntry::UDS_ACCESS );
     m_strName = m_entry.stringValue( KIO::UDSEntry::UDS_NAME );
-    m_strText = KIO::decodeFileName( m_strName );
+    
+    const QString displayName = m_entry.stringValue( KIO::UDSEntry::UDS_DISPLAY_NAME );
+    if (!displayName.isEmpty())
+      m_strText = displayName;
+    else
+      m_strText = KIO::decodeFileName( m_strName );
+    
     const QString urlStr = m_entry.stringValue( KIO::UDSEntry::UDS_URL );
     const bool UDS_URL_seen = !urlStr.isEmpty();
     if ( UDS_URL_seen ) {
@@ -945,6 +951,10 @@
         else
             text += i18n("(%1, Link to %2)", comment, linkDest());
     }
+    else if ( targetUrl() != url() )
+    {
+        text += i18n ( " (Points to %1)", targetUrl().url());
+    }
     else if ( S_ISREG( d->m_fileMode ) )
     {
         text += QString(" (%1, %2)").arg( comment, KIO::convertSize( size() ) );
@@ -1229,6 +1239,15 @@
     return d->m_strLowerCaseName;
 }
 
+KUrl KFileItem::targetUrl() const
+{
+    const QString targetUrlStr = d->m_entry.stringValue( KIO::UDSEntry::UDS_TARGET_URL );
+    if (!targetUrlStr.isEmpty())
+      return KUrl(targetUrlStr);
+    else
+      return url();
+}
+
 /*
  * Mimetype handling.
  *
Index: kio/kio/kfileitem.h
===================================================================
--- kio/kio/kfileitem.h	(revision 777170)
+++ kio/kio/kfileitem.h	(working copy)
@@ -253,6 +253,13 @@
     QString linkDest() const;
 
     /**
+     * Returns the target url of the file, which is the same as url()
+     * in cases where the slave doesn't specify UDS_TARGET_URL
+     * @return the target url. 
+     */
+    KUrl targetUrl() const;
+
+    /**
      * Returns the local path if isLocalFile() == true or the KIO item has
      * a UDS_LOCAL_PATH atom.
      * @return the item local path, or QString() if not known
Index: kio/kio/udsentry.h
===================================================================
--- kio/kio/udsentry.h	(revision 777170)
+++ kio/kio/udsentry.h	(working copy)
@@ -193,7 +193,14 @@
             /// The default access control list serialized into a single string.
             /// Only available for directories.
             UDS_DEFAULT_ACL_STRING = 21 | UDS_STRING,
-
+            
+            /// If set, contains the label to display instead of
+            /// the 'real name' in UDS_NAME
+            UDS_DISPLAY_NAME = 22 | UDS_STRING,
+            /// This file is a shortcut or mount, pointing to an
+            /// URL in a different hierarchy
+            UDS_TARGET_URL = 23 | UDS_STRING,
+            
             /// Extra data (used only if you specified Columns/ColumnsTypes)
             /// KDE 4.0 change: you cannot repeat this entry anymore, use UDS_EXTRA + i
             /// until UDS_EXTRA_END.


["dolphin_and_konqeror_follow_uds_target_url2.patch" (text/x-patch)]

Index: apps/konqueror/src/konqmainwindow.cpp
===================================================================
--- apps/konqueror/src/konqmainwindow.cpp	(revision 777207)
+++ apps/konqueror/src/konqmainwindow.cpp	(working copy)
@@ -2408,7 +2408,7 @@
     const KFileItemList::const_iterator end = m_popupItems.end();
     for ( ; it != end; ++it )
     {
-        KonqMisc::createNewWindow( (*it).url(), m_popupUrlArgs, m_popupUrlBrowserArgs );
+      KonqMisc::createNewWindow( (*it).targetUrl(), m_popupUrlArgs, m_popupUrlBrowserArgs );
     }
 }
 
@@ -2448,7 +2448,7 @@
     {
       req.newTabInFront = true;
     }
-    openUrl( 0, m_popupItems[i].url(), QString(), req );
+    openUrl( 0, m_popupItems[i].targetUrl(), QString(), req );
   }
 }
 
Index: apps/dolphin/src/dolphinpart.cpp
===================================================================
--- apps/dolphin/src/dolphinpart.cpp	(revision 777207)
+++ apps/dolphin/src/dolphinpart.cpp	(working copy)
@@ -273,7 +273,7 @@
     } else {
         // Left button. [Right button goes to slotOpenContextMenu before triggered can be emitted]
         kDebug() << "LMB";
-        emit m_extension->openUrlRequest(item.url(), args, browserArgs);
+        emit m_extension->openUrlRequest(item.targetUrl(), args, browserArgs);
     }
 }
 
Index: apps/dolphin/src/dolphinviewcontainer.cpp
===================================================================
--- apps/dolphin/src/dolphinviewcontainer.cpp	(revision 777207)
+++ apps/dolphin/src/dolphinviewcontainer.cpp	(working copy)
@@ -392,9 +392,7 @@
 
 void DolphinViewContainer::slotItemTriggered(const KFileItem& item)
 {
-    // Prefer the local path over the URL.
-    bool isLocal;
-    KUrl url = item.mostLocalUrl(isLocal);
+    KUrl url = item.targetUrl();
 
     if (item.isDir()) {
         m_view->setUrl(url);


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

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