]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/bookmarkselector.cpp
don't use KUrl::upUrl() (thanks to David for the hint!)
[dolphin.git] / src / bookmarkselector.cpp
index 84ec0fc4ee5606519a8e9e691a8cdae7d2c59e50..77fa5b7ac2d4cec364d9f36f8553fc0780da23d8 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <QPainter>
 #include <QPixmap>
+#include <kicon.h>
 
 BookmarkSelector::BookmarkSelector(UrlNavigator* parent, KBookmarkManager* bookmarkManager) :
     UrlButton(parent),
@@ -75,16 +76,16 @@ BookmarkSelector::~BookmarkSelector()
 
 void BookmarkSelector::updateSelection(const KUrl& url)
 {
-    KBookmark bookmark = baseBookmark(m_bookmarkManager, url);
+    KBookmark bookmark = m_bookmarkManager->root().closestBookmark(url);
     if (!bookmark.isNull()) {
         m_selectedAddress = bookmark.address();
-        setIcon(SmallIcon(bookmark.icon()));
+        setIcon(KIcon(bookmark.icon()));
     }
     else {
         m_selectedAddress = QString();
         // No bookmark has been found which matches to the given Url. Show
         // a generic folder icon as pixmap for indication:
-        setIcon(SmallIcon("folder"));
+        setIcon(KIcon("folder"));
     }
 }
 
@@ -99,34 +100,6 @@ QSize BookmarkSelector::sizeHint() const
     return QSize(height, height);
 }
 
-KBookmark BookmarkSelector::baseBookmark(KBookmarkManager* bookmarkManager, const KUrl& url)
-{
-    const KBookmarkGroup root = bookmarkManager->root();
-    KBookmark bookmark = root.first();
-    KBookmark foundBookmark;
-
-    int maxLength = 0;
-
-    // Search the bookmark which is equal to the Url or at least is a parent Url.
-    // If there are more than one possible parent Url candidates, choose the bookmark
-    // which covers the bigger range of the Url.
-    int i = 0;
-    while (!bookmark.isNull()) {
-        const KUrl bookmarkUrl = bookmark.url();
-        if (bookmarkUrl.isParentOf(url)) {
-            const int length = bookmarkUrl.prettyUrl().length();
-            if (length > maxLength) {
-                foundBookmark = bookmark;
-                maxLength = length;
-            }
-        }
-        bookmark = root.next(bookmark);
-        ++i;
-    }
-
-    return foundBookmark;
-}
-
 void BookmarkSelector::paintEvent(QPaintEvent* /*event*/)
 {
     QPainter painter(this);