diff options
author | Yoann Laissus <yoann.laissus@gmail.com> | 2012-08-17 10:00:55 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2012-12-10 02:48:05 +0100 |
commit | f09caa376e40678fff10525b7249455a819337c4 (patch) | |
tree | f464d2b762dfdb524cff601685ede107b2728ae9 /src | |
parent | Manage Bookmarks Toolbar show/hide (&& create/delete) (diff) | |
download | rekonq-f09caa376e40678fff10525b7249455a819337c4.tar.xz |
BookmarkWidget:
Don't display an empty entry if the bookmark is in the root folder
Improve the code to choose the current index
Add an icon for the toolbar root entry in the BookmarkWidget
Don't duplicate the toolbar root entry in some cases
Clean up setupFolderComboBox()
--- Imported from rekonq code by adjam :)
Diffstat (limited to 'src')
-rw-r--r-- | src/urlbar/bookmarkwidget.cpp | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/src/urlbar/bookmarkwidget.cpp b/src/urlbar/bookmarkwidget.cpp index 1a69c052..6c6763b0 100644 --- a/src/urlbar/bookmarkwidget.cpp +++ b/src/urlbar/bookmarkwidget.cpp @@ -236,44 +236,47 @@ void BookmarkWidget::accept() void BookmarkWidget::setupFolderComboBox() { - KBookmarkGroup root = BookmarkManager::self()->manager()->toolbar(); + KBookmarkGroup toolBarRoot = BookmarkManager::self()->manager()->toolbar(); + KBookmarkGroup root = BookmarkManager::self()->rootGroup(); - if (BookmarkManager::self()->manager()->toolbar().address() == BookmarkManager::self()->manager()->root().address()) + if (toolBarRoot.address() == root.address()) { - m_folder->addItem(i18n("Bookmark Toolbar"), - BookmarkManager::self()->manager()->toolbar().address()); + m_folder->addItem(KIcon("bookmark-toolbar"), + i18n("Bookmark Toolbar"), + toolBarRoot.address()); } else { - m_folder->addItem(BookmarkManager::self()->manager()->toolbar().text(), - BookmarkManager::self()->manager()->toolbar().address()); + m_folder->addItem(KIcon("bookmark-toolbar"), + toolBarRoot.text(), + toolBarRoot.address()); } m_folder->insertSeparator(1); - if (m_bookmark->parentGroup().address() != BookmarkManager::self()->manager()->toolbar().address()) + if (m_bookmark->parentGroup().address() != toolBarRoot.address()) { - m_folder->addItem(m_bookmark->parentGroup().text(), + QString parentText = m_bookmark->parentGroup().text(); + + if (m_bookmark->parentGroup().address() == root.address()) + { + parentText = i18n("Root folder"); + } + + m_folder->addItem(parentText, m_bookmark->parentGroup().address()); m_folder->insertSeparator(3); } - for (KBookmark bookmark = root.first(); !bookmark.isNull(); bookmark = root.next(bookmark)) + for (KBookmark bookmark = toolBarRoot.first(); !bookmark.isNull(); bookmark = toolBarRoot.next(bookmark)) { - if (bookmark.isGroup()) + if (bookmark.isGroup() && bookmark.address() != m_bookmark->parentGroup().address()) { m_folder->addItem(bookmark.text(), bookmark.address()); } } - if (m_bookmark->parentGroup().address() == root.address()) - { - m_folder->setCurrentIndex(0); - } - else - { - int index = m_folder->findText(m_bookmark->parentGroup().text()); - m_folder->setCurrentIndex(index); - } + int index = m_folder->findData(m_bookmark->parentGroup().address()); + m_folder->setCurrentIndex(index); } |