summaryrefslogtreecommitdiff
path: root/src/bookmarks.cpp
diff options
context:
space:
mode:
authoradjam <adjam@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-06-08 14:05:59 +0000
committeradjam <adjam@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-06-08 14:05:59 +0000
commitc307691a6356a330940cd29b6f67b5a64f37d336 (patch)
tree73b5367d5399c7b86bc8961ca1f58d150f9b697f /src/bookmarks.cpp
parentfixuifiles (diff)
downloadrekonq-c307691a6356a330940cd29b6f67b5a64f37d336.tar.xz
bookmark toolbar displaying ALL the bookmarks.
This commit is based on patch from Matthieu Gicquel (many thanks). While I don't like this "super-filled" bm toolbar, this is probably the best solution, waiting for an akonadi based bookmarks model. git-svn-id: svn+ssh://svn.kde.org/home/kde/trunk/playground/network/rekonq@978915 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/bookmarks.cpp')
-rw-r--r--src/bookmarks.cpp56
1 files changed, 42 insertions, 14 deletions
diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp
index d280f376..ace45c2f 100644
--- a/src/bookmarks.cpp
+++ b/src/bookmarks.cpp
@@ -121,7 +121,12 @@ BookmarkMenu::~BookmarkMenu()
KMenu *BookmarkMenu::viewContextMenu(QAction *action)
{
- return contextMenu(action);
+ // contextMenu() returns an invalid KMenu (seg fault) for the folders in the toolbar
+ KMenu *menu = contextMenu(action);
+ if(menu)
+ return menu;
+
+ return 0; // new KMenu();
}
@@ -145,10 +150,11 @@ void BookmarkMenu::slotAddBookmark()
BookmarkProvider::BookmarkProvider(QWidget *parent)
- : QWidget(parent)
+ : QObject(parent)
+ , m_parent(parent)
, m_manager(0)
, m_owner(0)
- , m_menu(new KMenu(this))
+ , m_menu(new KMenu(m_parent))
, m_actionCollection(new KActionCollection(this))
, m_bookmarkMenu(0)
, m_bookmarkToolBar(0)
@@ -197,7 +203,7 @@ BookmarkProvider::~BookmarkProvider()
void BookmarkProvider::setupToolBar()
{
- m_bookmarkToolBar = new KToolBar(this);
+ m_bookmarkToolBar = new KToolBar(m_parent);
m_bookmarkToolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
m_bookmarkToolBar->setIconDimensions(16);
m_bookmarkToolBar->setAcceptDrops(true);
@@ -222,25 +228,18 @@ void BookmarkProvider::slotBookmarksChanged(const QString &group, const QString
return;
}
- KActionCollection bookmarkCollection(this);
-
KBookmarkGroup toolBarGroup = m_manager->toolbar();
if (toolBarGroup.isNull())
return;
+ m_bookmarkToolBar->clear();
+
KBookmark bookmark = toolBarGroup.first();
while (!bookmark.isNull())
{
- if (!bookmark.isGroup())
- {
- KAction *action = new KBookmarkAction(bookmark, m_owner, this);
- QString text = bookmark.address();
- bookmarkCollection.addAction(text, action);
- }
+ m_bookmarkToolBar->addAction(fillBookmarkBar(bookmark));
bookmark = toolBarGroup.next(bookmark);
}
- m_bookmarkToolBar->clear();
- m_bookmarkToolBar->addActions(bookmarkCollection.actions());
}
@@ -282,3 +281,32 @@ KAction* BookmarkProvider::bookmarkToolBarAction()
bookmarkToolBarAction->setShortcutConfigurable(false);
return bookmarkToolBarAction;
}
+
+
+KAction *BookmarkProvider::fillBookmarkBar(const KBookmark &bookmark)
+{
+ if (bookmark.isGroup())
+ {
+ KBookmarkGroup group = bookmark.toGroup();
+ KBookmark bm = group.first();
+ KActionMenu *menuAction = new KActionMenu(KIcon(bookmark.icon()), bookmark.text(), this);
+ menuAction->setDelayed(false);
+ while (!bm.isNull())
+ {
+ menuAction->addAction(fillBookmarkBar(bm));
+ bm = group.next(bm);
+ }
+ return menuAction;
+ }
+
+ if(bookmark.isSeparator())
+ {
+ KAction *a = new KAction(this);
+ a->setSeparator(true);
+ return a;
+ }
+ else
+ {
+ return new KBookmarkAction(bookmark, m_owner, this);
+ }
+}