From a219ae2f7306d2d513eccf988ad9d2fd679c934c Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Wed, 14 Apr 2010 11:58:50 +0200 Subject: Don't create "Open Folder in Tabs" action when there are only folders or separators Implement a missing method : currentBookmarkList() which now allow "Bookmarks Tabs as Folder BUG: 234234 --- src/bookmarks/bookmarksmanager.cpp | 34 ++++++++++++++++++++++++++++++---- src/bookmarks/bookmarksmanager.h | 2 ++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/bookmarks/bookmarksmanager.cpp b/src/bookmarks/bookmarksmanager.cpp index d54abb3c..7e933599 100644 --- a/src/bookmarks/bookmarksmanager.cpp +++ b/src/bookmarks/bookmarksmanager.cpp @@ -35,6 +35,7 @@ #include "mainwindow.h" #include "webtab.h" #include "webview.h" +#include "mainview.h" #include "bookmarkcontextmenu.h" // KDE Includes @@ -53,7 +54,6 @@ #include - BookmarkOwner::BookmarkOwner(QObject *parent) : QObject(parent) , KBookmarkOwner() @@ -112,6 +112,22 @@ void BookmarkOwner::openFolderinTabs(const KBookmarkGroup &bm) } +QList< QPair > BookmarkOwner::currentBookmarkList() const +{ + QList< QPair > bkList; + int tabNumber = Application::instance()->mainWindow()->mainView()->count(); + + for(int i = 0; i < tabNumber; i++) + { + QPair item; + item.first = Application::instance()->mainWindow()->mainView()->webTab(i)->view()->title(); + item.second = Application::instance()->mainWindow()->mainView()->webTab(i)->url().url(); + bkList += item; + } + return bkList; +} + + // ------------------------------------------------------------------------------------------------------ @@ -405,9 +421,19 @@ void BookmarkActionMenu::addFolderActions() if(!m_group.first().isNull()) { - action = new KAction(KIcon("tab-new"), i18n("Open Folder in Tabs"), this); - connect(action, SIGNAL(triggered(bool)), this, SLOT(openActionInTabs())); - addAction(action); + KBookmark bookmark = m_group.first(); + + while(bookmark.isGroup() || bookmark.isSeparator()) + { + bookmark = m_group.next(bookmark); + } + + if(!bookmark.isNull()) + { + action = new KAction(KIcon("tab-new"), i18n("Open Folder in Tabs"), this); + connect(action, SIGNAL(triggered(bool)), this, SLOT(openActionInTabs())); + addAction(action); + } } action = new KAction(KIcon("bookmark-new"), i18n("Add Bookmark Here"), this); diff --git a/src/bookmarks/bookmarksmanager.h b/src/bookmarks/bookmarksmanager.h index c8264633..7fb02970 100644 --- a/src/bookmarks/bookmarksmanager.h +++ b/src/bookmarks/bookmarksmanager.h @@ -115,6 +115,8 @@ public: */ virtual void openFolderinTabs(const KBookmarkGroup &bm); + virtual QList< QPair > currentBookmarkList() const; + signals: /** * This signal is emitted when an url has to be loaded -- cgit v1.2.1