diff options
| author | David Faure <[email protected]> | 2007-03-26 23:04:43 +0000 |
|---|---|---|
| committer | David Faure <[email protected]> | 2007-03-26 23:04:43 +0000 |
| commit | 85bc196887fbed01187e3830cd28c2500cb01cb2 (patch) | |
| tree | 98cde59002e2e1214e61a328c253ba58546bb532 /src/bookmarkselector.cpp | |
| parent | c6bc5511a8ba05d8f44217b404d615d4d56bb53f (diff) | |
Ported to KBookmarkManager::closestBookmark - which even solves another TODO about code duplication.
Improved urlnavigator API to avoid exposing the full QList (api independent from implementation now).
svn path=/trunk/KDE/kdebase/apps/; revision=646954
Diffstat (limited to 'src/bookmarkselector.cpp')
| -rw-r--r-- | src/bookmarkselector.cpp | 30 |
1 files changed, 1 insertions, 29 deletions
diff --git a/src/bookmarkselector.cpp b/src/bookmarkselector.cpp index 84ec0fc4e..1e4aaadc9 100644 --- a/src/bookmarkselector.cpp +++ b/src/bookmarkselector.cpp @@ -75,7 +75,7 @@ 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())); @@ -99,34 +99,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); |
