]> cloud.milkyroute.net Git - dolphin.git/commitdiff
* Fixed a bug that caused dolphin to crash when clicking on the "Root" button
authorLuca Gugelmann <luca.gugelmann@gmail.com>
Sun, 25 Mar 2007 13:49:38 +0000 (13:49 +0000)
committerLuca Gugelmann <luca.gugelmann@gmail.com>
Sun, 25 Mar 2007 13:49:38 +0000 (13:49 +0000)
  in the url navigation bar.

* As a side effect this also prevents a small graphics glitch, where the path
  labels in the navigation bar would shift a few pixels to the left when
  clicked twice.

svn path=/trunk/KDE/kdebase/apps/; revision=646362

src/urlnavigator.cpp

index f1b39fb32f22593a7d048f71d72db8bb4e739ee1..ee06f558a101898950f9e4c5c14f0915b9c6a7d0 100644 (file)
@@ -150,15 +150,19 @@ const KUrl& UrlNavigator::url() const
 KUrl UrlNavigator::url(int index) const
 {
     assert(index >= 0);
-    QString path(url().pathOrUrl());
-    path = path.section('/', 0, index);
-
-    if ( path.length() >= 1 && path.at(path.length()-1) != '/')
-    {
-        path.append('/');
+    // keep scheme, hostname etc. maybe we will need this in the future
+    // for e.g. browsing ftp repositories.
+    QString pre(((QUrl)url()).toString(QUrl::RemovePath));
+    QString path(url().path());
+
+    if (!path.isEmpty()) {
+        if (index == 0) //prevent the last "/" from being stripped
+            path = "/"; //or we end up with an empty path
+        else
+            path = path.section('/', 0, index);
     }
 
-    return path;
+    return KUrl(pre + path);
 }
 
 const QLinkedList<UrlNavigator::HistoryElem>& UrlNavigator::history(int& index) const