summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/application.cpp2
-rw-r--r--src/bookmarks.cpp56
-rw-r--r--src/bookmarks.h5
3 files changed, 47 insertions, 16 deletions
diff --git a/src/application.cpp b/src/application.cpp
index bd6e6d48..94821653 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -178,7 +178,7 @@ BookmarkProvider *Application::bookmarkProvider()
{
if (!s_bookmarkProvider)
{
- s_bookmarkProvider = new BookmarkProvider();
+ s_bookmarkProvider = new BookmarkProvider(instance()->mainWindow());
}
return s_bookmarkProvider;
}
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);
+ }
+}
diff --git a/src/bookmarks.h b/src/bookmarks.h
index 1de181e3..4e2349ad 100644
--- a/src/bookmarks.h
+++ b/src/bookmarks.h
@@ -156,7 +156,7 @@ protected slots:
*
*
*/
-class BookmarkProvider : public QWidget
+class BookmarkProvider : public QObject
{
Q_OBJECT
@@ -221,8 +221,11 @@ public slots:
void slotBookmarksChanged(const QString &group, const QString &caller);
private:
+ KAction *fillBookmarkBar(const KBookmark &bookmark);
void setupToolBar();
+ QWidget *m_parent;
+
KBookmarkManager *m_manager;
BookmarkOwner *m_owner;
KMenu *m_menu;