summaryrefslogtreecommitdiff
path: root/src/bookmarks
diff options
context:
space:
mode:
Diffstat (limited to 'src/bookmarks')
-rw-r--r--src/bookmarks/bookmarkowner.cpp369
-rw-r--r--src/bookmarks/bookmarkowner.h155
-rw-r--r--src/bookmarks/bookmarkscontextmenu.cpp2
-rw-r--r--src/bookmarks/bookmarksmanager.cpp345
-rw-r--r--src/bookmarks/bookmarksmanager.h139
-rw-r--r--src/bookmarks/bookmarkspanel.cpp1
-rw-r--r--src/bookmarks/bookmarkstoolbar.cpp4
7 files changed, 539 insertions, 476 deletions
diff --git a/src/bookmarks/bookmarkowner.cpp b/src/bookmarks/bookmarkowner.cpp
new file mode 100644
index 00000000..6c55f724
--- /dev/null
+++ b/src/bookmarks/bookmarkowner.cpp
@@ -0,0 +1,369 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2008-2010 by Andrea Diamantini <adjam7 at gmail dot com>
+* Copyright (C) 2009 by Paweł Prażak <pawelprazak at gmail dot com>
+* Copyright (C) 2009-2010 by Lionel Chauvin <megabigbug@yahoo.fr>
+* Copyright (C) 2010 by Yoann Laissus <yoann dot laissus at gmail dot com>
+*
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License as
+* published by the Free Software Foundation; either version 2 of
+* the License or (at your option) version 3 or any later version
+* accepted by the membership of KDE e.V. (or its successor approved
+* by the membership of KDE e.V.), which shall act as a proxy
+* defined in Section 14 of version 3 of the license.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* ============================================================ */
+
+
+// Self Includes
+#include "bookmarkowner.h"
+
+// Local Includes
+#include "application.h"
+#include "bookmarksmanager.h"
+#include "mainwindow.h"
+#include "webtab.h"
+#include "mainview.h"
+
+// KDE Includes
+#include <KBookmarkDialog>
+#include <KMessageBox>
+
+// Qt Includes
+#include <QtGui/QClipboard>
+
+
+BookmarkOwner::BookmarkOwner(KBookmarkManager *manager, QObject *parent)
+ : QObject(parent)
+ , KBookmarkOwner()
+ , m_manager(manager)
+ , actions(QVector<KAction*>(NUM_ACTIONS))
+{
+ setupActions();
+}
+
+
+KAction* BookmarkOwner::action(const BookmarkAction &bmAction)
+{
+ return static_cast<KAction*>(actions.at(bmAction));
+}
+
+
+void BookmarkOwner::openBookmark(const KBookmark & bookmark,
+ Qt::MouseButtons mouseButtons,
+ Qt::KeyboardModifiers keyboardModifiers)
+{
+ if (keyboardModifiers & Qt::ControlModifier || mouseButtons == Qt::MidButton)
+ {
+ emit openUrl(bookmark.url(), Rekonq::NewTab);
+ }
+ else
+ {
+ emit openUrl(bookmark.url(), Rekonq::CurrentTab);
+ }
+}
+
+
+void BookmarkOwner::bookmarkCurrentPage()
+{
+ KBookmarkGroup parent;
+
+ if (!selected.isNull())
+ {
+ if (selected.isGroup())
+ parent = selected.toGroup();
+ else
+ parent = selected.parentGroup();
+
+ KBookmark newBk = parent.addBookmark(currentTitle().replace('&', "&&"), KUrl(currentUrl()));
+ parent.moveBookmark(newBk, selected);
+ }
+ else
+ {
+ parent = Application::bookmarkProvider()->rootGroup();
+ parent.addBookmark(currentTitle(), KUrl(currentUrl()));
+ }
+
+ m_manager->emitChanged(parent);
+}
+
+
+void BookmarkOwner::newBookmarkFolder()
+{
+ KBookmarkDialog *dialog = bookmarkDialog(m_manager, QApplication::activeWindow());
+ QString folderName = i18n("New folder");
+
+ if (!selected.isNull())
+ {
+ if (selected.isGroup())
+ {
+ dialog->createNewFolder(folderName, selected);
+ }
+ else
+ {
+ KBookmark newBk = dialog->createNewFolder(folderName, selected.parentGroup());
+ if (!newBk.isNull())
+ {
+ KBookmarkGroup parent = newBk.parentGroup();
+ parent.moveBookmark(newBk, selected);
+ m_manager->emitChanged(parent);
+ }
+ }
+ }
+ else
+ {
+ dialog->createNewFolder(folderName);
+ }
+
+ delete dialog;
+}
+
+
+void BookmarkOwner::newSeparator()
+{
+ KBookmark newBk;
+
+ if (!selected.isNull())
+ {
+ if (selected.isGroup())
+ {
+ newBk = selected.toGroup().createNewSeparator();
+ }
+ else
+ {
+ newBk = selected.parentGroup().createNewSeparator();
+ newBk.parentGroup().moveBookmark(newBk, selected);
+ }
+ }
+ else
+ {
+ newBk = Application::bookmarkProvider()->rootGroup().createNewSeparator();
+ }
+
+ newBk.setIcon(("edit-clear"));
+
+ m_manager->emitChanged(newBk.parentGroup());
+}
+
+
+void BookmarkOwner::editBookmark()
+{
+ if (selected.isNull())
+ return;
+
+ selected.setFullText(selected.fullText().replace("&&", "&"));
+ KBookmarkDialog *dialog = bookmarkDialog(m_manager, QApplication::activeWindow());
+
+ dialog->editBookmark(selected);
+ selected.setFullText(selected.fullText().replace('&', "&&"));
+
+ delete dialog;
+}
+
+
+bool BookmarkOwner::deleteBookmark()
+{
+ if (selected.isNull())
+ return false;
+
+ KBookmarkGroup bmg = selected.parentGroup();
+ QString name = QString(selected.fullText()).replace("&&", "&");
+ QString dialogCaption, dialogText;
+
+ if (selected.isGroup())
+ {
+ dialogCaption = i18n("Bookmark Folder Deletion");
+ dialogText = i18n("Are you sure you wish to remove the bookmark folder\n\"%1\"?", name);
+ }
+ else if (selected.isSeparator())
+ {
+ dialogCaption = i18n("Separator Deletion");
+ dialogText = i18n("Are you sure you wish to remove this separator?", name);
+ }
+ else
+ {
+ dialogCaption = i18n("Bookmark Deletion");
+ dialogText = i18n("Are you sure you wish to remove the bookmark\n\"%1\"?", name);
+ }
+
+ if (KMessageBox::warningContinueCancel(
+ QApplication::activeWindow(),
+ dialogText,
+ dialogCaption,
+ KStandardGuiItem::del(),
+ KStandardGuiItem::cancel(),
+ "bookmarkDeletition_askAgain")
+ != KMessageBox::Continue
+ )
+ return false;
+
+ bmg.deleteBookmark(selected);
+ m_manager->emitChanged(bmg);
+ return true;
+}
+
+
+bool BookmarkOwner::supportsTabs() const
+{
+ return true;
+}
+
+
+QString BookmarkOwner::currentUrl() const
+{
+ return Application::instance()->mainWindow()->currentTab()->url().url();
+}
+
+
+QString BookmarkOwner::currentTitle() const
+{
+ return Application::instance()->mainWindow()->currentTab()->view()->title();
+}
+
+
+void BookmarkOwner::openFolderinTabs(const KBookmarkGroup &bookmark)
+{
+ QList<KUrl> urlList = bookmark.groupUrlList();
+
+ if (urlList.length() > 8)
+ {
+ if ( !(KMessageBox::warningContinueCancel( Application::instance()->mainWindow(),
+ i18ncp("%1=Number of tabs. Value is always >=8",
+ "You are about to open %1 tabs.\nAre you sure?",
+ "You are about to open %1 tabs.\nAre you sure?",
+ urlList.length()),
+ "",
+ KStandardGuiItem::cont(),
+ KStandardGuiItem::cancel(),
+ "openFolderInTabs_askAgain"
+ ) == KMessageBox::Continue)
+ )
+ return;
+ }
+
+ QList<KUrl>::iterator url;
+ for (url = urlList.begin(); url != urlList.end(); ++url)
+ {
+ emit openUrl(*url, Rekonq::NewFocusedTab);
+ }
+}
+
+
+QList< QPair<QString, QString> > BookmarkOwner::currentBookmarkList() const
+{
+ QList< QPair<QString, QString> > bkList;
+ int tabNumber = Application::instance()->mainWindow()->mainView()->count();
+
+ for (int i = 0; i < tabNumber; i++)
+ {
+ QPair<QString, QString> 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;
+}
+
+
+void BookmarkOwner::bookmarkSelected(const KBookmark &bookmark)
+{
+ selected = bookmark;
+}
+
+
+void BookmarkOwner::openBookmark()
+{
+ emit openUrl(selected.url(), Rekonq::CurrentTab);
+}
+
+
+void BookmarkOwner::openBookmarkInNewTab()
+{
+ emit openUrl(selected.url(), Rekonq::NewTab);
+}
+
+
+void BookmarkOwner::openBookmarkInNewWindow()
+{
+ emit openUrl(selected.url(), Rekonq::NewWindow);
+}
+
+
+void BookmarkOwner::openBookmarkFolder()
+{
+ if (!selected.isGroup())
+ return;
+
+ QList<KUrl> urlList = selected.toGroup().groupUrlList();
+
+ if (urlList.length() > 8)
+ {
+ if (KMessageBox::warningContinueCancel(
+ Application::instance()->mainWindow(),
+ i18n("You are about to open %1 tabs.\nAre you sure?", urlList.length()))
+ != KMessageBox::Continue
+ )
+ return;
+ }
+
+ foreach (KUrl url, urlList)
+ {
+ emit openUrl(url, Rekonq::NewFocusedTab);
+ }
+}
+
+
+void BookmarkOwner::copyLink()
+{
+ if (selected.isNull())
+ return;
+
+ QApplication::clipboard()->setText(selected.url().url());
+}
+
+
+void BookmarkOwner::setupActions()
+{
+ createAction(OPEN, i18n("Open"), "tab-new",
+ i18n("Open bookmark in current tab"), SLOT(openBookmark()));
+ createAction(OPEN_IN_TAB, i18n("Open in New Tab"), "tab-new",
+ i18n("Open bookmark in new tab"), SLOT(openBookmarkInNewTab()));
+ createAction(OPEN_IN_WINDOW, i18n("Open in New Window"), "window-new",
+ i18n("Open bookmark in new window"), SLOT(openBookmarkInNewWindow()));
+ createAction(OPEN_FOLDER, i18n("Open Folder in Tabs"), "tab-new",
+ i18n("Open all the bookmarks in folder in tabs"), SLOT(openBookmarkFolder()));
+ createAction(BOOKMARK_PAGE, i18n("Add Bookmark"), "bookmark-new",
+ i18n("Bookmark current page"), SLOT(bookmarkCurrentPage()));
+ createAction(NEW_FOLDER, i18n("New Folder"), "folder-new",
+ i18n("Create a new bookmark folder"), SLOT(newBookmarkFolder()));
+ createAction(NEW_SEPARATOR, i18n("New Separator"), "edit-clear",
+ i18n("Create a new bookmark separatork"), SLOT(newSeparator()));
+ createAction(COPY, i18n("Copy Link"), "edit-copy",
+ i18n("Copy the bookmark's link address"), SLOT(copyLink()));
+ createAction(EDIT, i18n("Edit"), "configure",
+ i18n("Edit the bookmark"), SLOT(editBookmark()));
+ createAction(DELETE, i18n("Delete"), "edit-delete",
+ i18n("Delete the bookmark"), SLOT(deleteBookmark()));
+}
+
+
+void BookmarkOwner::createAction(const BookmarkAction &action, const QString &text,
+ const QString &icon, const QString &help, const char *slot)
+{
+ KAction *act = new KAction(KIcon(icon), text, this);
+ act->setHelpText(help);
+ actions[action] = act;
+ connect(act, SIGNAL(triggered()), this, slot);
+}
diff --git a/src/bookmarks/bookmarkowner.h b/src/bookmarks/bookmarkowner.h
new file mode 100644
index 00000000..395edf54
--- /dev/null
+++ b/src/bookmarks/bookmarkowner.h
@@ -0,0 +1,155 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2008-2010 by Andrea Diamantini <adjam7 at gmail dot com>
+* Copyright (C) 2009 by Paweł Prażak <pawelprazak at gmail dot com>
+* Copyright (C) 2009-2010 by Lionel Chauvin <megabigbug@yahoo.fr>
+* Copyright (C) 2010 by Yoann Laissus <yoann dot laissus at gmail dot com>
+*
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License as
+* published by the Free Software Foundation; either version 2 of
+* the License or (at your option) version 3 or any later version
+* accepted by the membership of KDE e.V. (or its successor approved
+* by the membership of KDE e.V.), which shall act as a proxy
+* defined in Section 14 of version 3 of the license.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* ============================================================ */
+
+
+#ifndef BOOKMARKOWNER_H
+#define BOOKMARKOWNER_H
+
+
+// Rekonq Includes
+#include "rekonq_defines.h"
+
+// KDE Includes
+#include <KBookmarkOwner>
+
+class KAction;
+
+
+/**
+ * Reimplementation of KBookmarkOwner, this class allows to manage
+ * bookmarks as actions
+ *
+ */
+class REKONQ_TESTS_EXPORT BookmarkOwner : public QObject , public KBookmarkOwner
+{
+ Q_OBJECT
+
+public:
+ explicit BookmarkOwner(KBookmarkManager *manager, QObject *parent = 0);
+ virtual ~BookmarkOwner() {}
+
+ enum BookmarkAction
+ {
+ OPEN = 0,
+ OPEN_IN_TAB,
+ OPEN_IN_WINDOW,
+ OPEN_FOLDER,
+ BOOKMARK_PAGE,
+ NEW_FOLDER,
+ NEW_SEPARATOR,
+ COPY,
+ EDIT,
+ DELETE,
+ NUM_ACTIONS
+ };
+
+ /**
+ * @return the action or 0 if it doesn't exist.
+ */
+ KAction* action(const BookmarkAction &bmAction);
+
+ /**
+ * This function is called when a bookmark is selected and belongs to
+ * the ancestor class.
+ * This method actually emits signal to load bookmark's url.
+ *
+ * @param bookmark the bookmark to open
+ * @param mouseButtons the mouse buttons clicked to select the bookmark
+ * @param keyboardModifiers the keyboard modifiers pushed when the bookmark was selected
+ */
+ virtual void openBookmark(const KBookmark &bookmark,
+ Qt::MouseButtons mouseButtons,
+ Qt::KeyboardModifiers keyboardModifiers);
+
+
+ /**
+ * this method, from KBookmarkOwner interface, allows to add the current page
+ * to the bookmark list, returning the URL page as QString.
+ *
+ * @return the current page's URL
+ */
+ virtual QString currentUrl() const;
+
+ /**
+ * this method, from KBookmarkOwner interface, allows to add the current page
+ * to the bookmark list, returning the title's page as QString.
+ *
+ * @return the current page's title
+ */
+ virtual QString currentTitle() const;
+
+ /**
+ * This function returns whether the owner supports tabs.
+ */
+ virtual bool supportsTabs() const;
+
+ /**
+ * Called if the user wants to open every bookmark in this folder in a new tab.
+ * The default implementation does nothing.
+ * This is only called if supportsTabs() returns true
+ */
+ virtual void openFolderinTabs(const KBookmarkGroup &bookmark);
+
+ virtual QList< QPair<QString, QString> > currentBookmarkList() const;
+
+signals:
+ /**
+ * This signal is emitted when an url has to be loaded
+ *
+ * @param url the URL to load
+ *
+ */
+ void openUrl(const KUrl &, const Rekonq::OpenType &);
+
+public slots:
+ void bookmarkSelected(const KBookmark &bookmark);
+
+ void openBookmark();
+ void openBookmarkInNewTab();
+ void openBookmarkInNewWindow();
+ void openBookmarkFolder();
+ void bookmarkCurrentPage();
+ void newBookmarkFolder();
+ void newSeparator();
+ void copyLink();
+ void editBookmark();
+ bool deleteBookmark();
+
+private:
+ KBookmarkManager *m_manager;
+
+ QVector<KAction*> actions;
+ KBookmark selected;
+
+ void setupActions();
+ void createAction(const BookmarkAction &action,
+ const QString &text, const QString &icon,
+ const QString &help, const char *slot);
+};
+
+#endif // BOOKMARKOWNER_H
diff --git a/src/bookmarks/bookmarkscontextmenu.cpp b/src/bookmarks/bookmarkscontextmenu.cpp
index 8f64ee4b..45b7f563 100644
--- a/src/bookmarks/bookmarkscontextmenu.cpp
+++ b/src/bookmarks/bookmarkscontextmenu.cpp
@@ -28,7 +28,7 @@
#include "bookmarkscontextmenu.h"
// Local Includes
-#include "bookmarksmanager.h"
+#include "bookmarkowner.h"
BookmarksContextMenu::BookmarksContextMenu(const KBookmark &bookmark, KBookmarkManager *manager, BookmarkOwner *owner, QWidget *parent)
diff --git a/src/bookmarks/bookmarksmanager.cpp b/src/bookmarks/bookmarksmanager.cpp
index 4e675e45..0c3284bb 100644
--- a/src/bookmarks/bookmarksmanager.cpp
+++ b/src/bookmarks/bookmarksmanager.cpp
@@ -29,357 +29,20 @@
// Self Includes
#include "bookmarksmanager.h"
-#include "bookmarksmanager.moc"
// Local Includes
+#include "application.h"
#include "mainwindow.h"
-#include "webtab.h"
-#include "webview.h"
-#include "mainview.h"
+#include "bookmarkspanel.h"
#include "bookmarkscontextmenu.h"
+#include "bookmarkstoolbar.h"
+#include "bookmarkowner.h"
// KDE Includes
-#include <KActionCollection>
-#include <KBookmarkAction>
-#include <KBookmarkDialog>
-#include <KBookmarkGroup>
-#include <KToolBar>
-#include <KMenu>
#include <KStandardDirs>
-#include <KUrl>
-#include <KMessageBox>
// Qt Includes
#include <QtCore/QFile>
-#include <QtGui/QActionGroup>
-#include <QtGui/QClipboard>
-
-
-BookmarkOwner::BookmarkOwner(KBookmarkManager *manager, QObject *parent)
- : QObject(parent)
- , KBookmarkOwner()
- , m_manager(manager)
- , actions(QVector<KAction*>(NUM_ACTIONS))
-{
- setupActions();
-}
-
-
-KAction* BookmarkOwner::action(const BookmarkAction &bmAction)
-{
- return static_cast<KAction*>(actions.at(bmAction));
-}
-
-
-void BookmarkOwner::openBookmark(const KBookmark & bookmark,
- Qt::MouseButtons mouseButtons,
- Qt::KeyboardModifiers keyboardModifiers)
-{
- if (keyboardModifiers & Qt::ControlModifier || mouseButtons == Qt::MidButton)
- {
- emit openUrl(bookmark.url(), Rekonq::NewTab);
- }
- else
- {
- emit openUrl(bookmark.url(), Rekonq::CurrentTab);
- }
-}
-
-
-void BookmarkOwner::bookmarkCurrentPage()
-{
- KBookmarkGroup parent;
-
- if (!selected.isNull())
- {
- if (selected.isGroup())
- parent = selected.toGroup();
- else
- parent = selected.parentGroup();
-
- KBookmark newBk = parent.addBookmark(currentTitle().replace('&', "&&"), KUrl(currentUrl()));
- parent.moveBookmark(newBk, selected);
- }
- else
- {
- parent = Application::bookmarkProvider()->rootGroup();
- parent.addBookmark(currentTitle(), KUrl(currentUrl()));
- }
-
- m_manager->emitChanged(parent);
-}
-
-
-void BookmarkOwner::newBookmarkFolder()
-{
- KBookmarkDialog *dialog = bookmarkDialog(m_manager, QApplication::activeWindow());
- QString folderName = i18n("New folder");
-
- if (!selected.isNull())
- {
- if (selected.isGroup())
- {
- dialog->createNewFolder(folderName, selected);
- }
- else
- {
- KBookmark newBk = dialog->createNewFolder(folderName, selected.parentGroup());
- if (!newBk.isNull())
- {
- KBookmarkGroup parent = newBk.parentGroup();
- parent.moveBookmark(newBk, selected);
- m_manager->emitChanged(parent);
- }
- }
- }
- else
- {
- dialog->createNewFolder(folderName);
- }
-
- delete dialog;
-}
-
-
-void BookmarkOwner::newSeparator()
-{
- KBookmark newBk;
-
- if (!selected.isNull())
- {
- if (selected.isGroup())
- {
- newBk = selected.toGroup().createNewSeparator();
- }
- else
- {
- newBk = selected.parentGroup().createNewSeparator();
- newBk.parentGroup().moveBookmark(newBk, selected);
- }
- }
- else
- {
- newBk = Application::bookmarkProvider()->rootGroup().createNewSeparator();
- }
-
- newBk.setIcon(("edit-clear"));
-
- m_manager->emitChanged(newBk.parentGroup());
-}
-
-
-void BookmarkOwner::editBookmark()
-{
- if (selected.isNull())
- return;
-
- selected.setFullText(selected.fullText().replace("&&", "&"));
- KBookmarkDialog *dialog = bookmarkDialog(m_manager, QApplication::activeWindow());
-
- dialog->editBookmark(selected);
- selected.setFullText(selected.fullText().replace('&', "&&"));
-
- delete dialog;
-}
-
-
-bool BookmarkOwner::deleteBookmark()
-{
- if (selected.isNull())
- return false;
-
- KBookmarkGroup bmg = selected.parentGroup();
- QString name = QString(selected.fullText()).replace("&&", "&");
- QString dialogCaption, dialogText;
-
- if (selected.isGroup())
- {
- dialogCaption = i18n("Bookmark Folder Deletion");
- dialogText = i18n("Are you sure you wish to remove the bookmark folder\n\"%1\"?", name);
- }
- else if (selected.isSeparator())
- {
- dialogCaption = i18n("Separator Deletion");
- dialogText = i18n("Are you sure you wish to remove this separator?", name);
- }
- else
- {
- dialogCaption = i18n("Bookmark Deletion");
- dialogText = i18n("Are you sure you wish to remove the bookmark\n\"%1\"?", name);
- }
-
- if (KMessageBox::warningContinueCancel(
- QApplication::activeWindow(),
- dialogText,
- dialogCaption,
- KStandardGuiItem::del(),
- KStandardGuiItem::cancel(),
- "bookmarkDeletition_askAgain")
- != KMessageBox::Continue
- )
- return false;
-
- bmg.deleteBookmark(selected);
- m_manager->emitChanged(bmg);
- return true;
-}
-
-
-bool BookmarkOwner::supportsTabs() const
-{
- return true;
-}
-
-
-QString BookmarkOwner::currentUrl() const
-{
- return Application::instance()->mainWindow()->currentTab()->url().url();
-}
-
-
-QString BookmarkOwner::currentTitle() const
-{
- return Application::instance()->mainWindow()->currentTab()->view()->title();
-}
-
-
-void BookmarkOwner::openFolderinTabs(const KBookmarkGroup &bookmark)
-{
- QList<KUrl> urlList = bookmark.groupUrlList();
-
- if (urlList.length() > 8)
- {
- if ( !(KMessageBox::warningContinueCancel( Application::instance()->mainWindow(),
- i18ncp("%1=Number of tabs. Value is always >=8",
- "You are about to open %1 tabs.\nAre you sure?",
- "You are about to open %1 tabs.\nAre you sure?",
- urlList.length()),
- "",
- KStandardGuiItem::cont(),
- KStandardGuiItem::cancel(),
- "openFolderInTabs_askAgain"
- ) == KMessageBox::Continue)
- )
- return;
- }
-
- QList<KUrl>::iterator url;
- for (url = urlList.begin(); url != urlList.end(); ++url)
- {
- emit openUrl(*url, Rekonq::NewFocusedTab);
- }
-}
-
-
-QList< QPair<QString, QString> > BookmarkOwner::currentBookmarkList() const
-{
- QList< QPair<QString, QString> > bkList;
- int tabNumber = Application::instance()->mainWindow()->mainView()->count();
-
- for (int i = 0; i < tabNumber; i++)
- {
- QPair<QString, QString> 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;
-}
-
-
-void BookmarkOwner::bookmarkSelected(const KBookmark &bookmark)
-{
- selected = bookmark;
-}
-
-
-void BookmarkOwner::openBookmark()
-{
- emit openUrl(selected.url(), Rekonq::CurrentTab);
-}
-
-
-void BookmarkOwner::openBookmarkInNewTab()
-{
- emit openUrl(selected.url(), Rekonq::NewTab);
-}
-
-
-void BookmarkOwner::openBookmarkInNewWindow()
-{
- emit openUrl(selected.url(), Rekonq::NewWindow);
-}
-
-
-void BookmarkOwner::openBookmarkFolder()
-{
- if (!selected.isGroup())
- return;
-
- QList<KUrl> urlList = selected.toGroup().groupUrlList();
-
- if (urlList.length() > 8)
- {
- if (KMessageBox::warningContinueCancel(
- Application::instance()->mainWindow(),
- i18n("You are about to open %1 tabs.\nAre you sure?", urlList.length()))
- != KMessageBox::Continue
- )
- return;
- }
-
- foreach (KUrl url, urlList)
- {
- emit openUrl(url, Rekonq::NewFocusedTab);
- }
-}
-
-
-void BookmarkOwner::copyLink()
-{
- if (selected.isNull())
- return;
-
- QApplication::clipboard()->setText(selected.url().url());
-}
-
-
-void BookmarkOwner::setupActions()
-{
- createAction(OPEN, i18n("Open"), "tab-new",
- i18n("Open bookmark in current tab"), SLOT(openBookmark()));
- createAction(OPEN_IN_TAB, i18n("Open in New Tab"), "tab-new",
- i18n("Open bookmark in new tab"), SLOT(openBookmarkInNewTab()));
- createAction(OPEN_IN_WINDOW, i18n("Open in New Window"), "window-new",
- i18n("Open bookmark in new window"), SLOT(openBookmarkInNewWindow()));
- createAction(OPEN_FOLDER, i18n("Open Folder in Tabs"), "tab-new",
- i18n("Open all the bookmarks in folder in tabs"), SLOT(openBookmarkFolder()));
- createAction(BOOKMARK_PAGE, i18n("Add Bookmark"), "bookmark-new",
- i18n("Bookmark current page"), SLOT(bookmarkCurrentPage()));
- createAction(NEW_FOLDER, i18n("New Folder"), "folder-new",
- i18n("Create a new bookmark folder"), SLOT(newBookmarkFolder()));
- createAction(NEW_SEPARATOR, i18n("New Separator"), "edit-clear",
- i18n("Create a new bookmark separatork"), SLOT(newSeparator()));
- createAction(COPY, i18n("Copy Link"), "edit-copy",
- i18n("Copy the bookmark's link address"), SLOT(copyLink()));
- createAction(EDIT, i18n("Edit"), "configure",
- i18n("Edit the bookmark"), SLOT(editBookmark()));
- createAction(DELETE, i18n("Delete"), "edit-delete",
- i18n("Delete the bookmark"), SLOT(deleteBookmark()));
-}
-
-
-void BookmarkOwner::createAction(const BookmarkAction &action, const QString &text,
- const QString &icon, const QString &help, const char *slot)
-{
- KAction *act = new KAction(KIcon(icon), text, this);
- act->setHelpText(help);
- actions[action] = act;
- connect(act, SIGNAL(triggered()), this, slot);
-}
-
-
-// ------------------------------------------------------------------------------------------------------
BookmarkProvider::BookmarkProvider(QObject *parent)
diff --git a/src/bookmarks/bookmarksmanager.h b/src/bookmarks/bookmarksmanager.h
index 7cbf0116..49073b2a 100644
--- a/src/bookmarks/bookmarksmanager.h
+++ b/src/bookmarks/bookmarksmanager.h
@@ -34,143 +34,14 @@
// Rekonq Includes
#include "rekonq_defines.h"
-// Local Includes
-#include "application.h"
-#include "urlresolver.h"
-#include "bookmarkspanel.h"
-#include "bookmarkstoolbar.h"
-
-// Qt Includes
-#include <QWidget>
-
// KDE Includes
-#include <KBookmarkOwner>
+#include <KBookmarkMenu>
+#include <KToolBar>
// Forward Declarations
-class BookmarkProvider;
-
-class KAction;
-class KActionCollection;
-class KActionMenu;
-class KUrl;
-class KToolBar;
-class KBookmarkManager;
-
-
-/**
- * Reimplementation of KBookmarkOwner, this class allows to manage
- * bookmarks as actions
- *
- */
-class REKONQ_TESTS_EXPORT BookmarkOwner : public QObject , public KBookmarkOwner
-{
- Q_OBJECT
-
-public:
- explicit BookmarkOwner(KBookmarkManager *manager, QObject *parent = 0);
- virtual ~BookmarkOwner() {}
-
- enum BookmarkAction
- {
- OPEN = 0,
- OPEN_IN_TAB,
- OPEN_IN_WINDOW,
- OPEN_FOLDER,
- BOOKMARK_PAGE,
- NEW_FOLDER,
- NEW_SEPARATOR,
- COPY,
- EDIT,
- DELETE,
- NUM_ACTIONS
- };
-
- /**
- * @return the action or 0 if it doesn't exist.
- */
- KAction* action(const BookmarkAction &bmAction);
-
- /**
- * This function is called when a bookmark is selected and belongs to
- * the ancestor class.
- * This method actually emits signal to load bookmark's url.
- *
- * @param bookmark the bookmark to open
- * @param mouseButtons the mouse buttons clicked to select the bookmark
- * @param keyboardModifiers the keyboard modifiers pushed when the bookmark was selected
- */
- virtual void openBookmark(const KBookmark &bookmark,
- Qt::MouseButtons mouseButtons,
- Qt::KeyboardModifiers keyboardModifiers);
-
-
- /**
- * this method, from KBookmarkOwner interface, allows to add the current page
- * to the bookmark list, returning the URL page as QString.
- *
- * @return the current page's URL
- */
- virtual QString currentUrl() const;
-
- /**
- * this method, from KBookmarkOwner interface, allows to add the current page
- * to the bookmark list, returning the title's page as QString.
- *
- * @return the current page's title
- */
- virtual QString currentTitle() const;
-
- /**
- * This function returns whether the owner supports tabs.
- */
- virtual bool supportsTabs() const;
-
- /**
- * Called if the user wants to open every bookmark in this folder in a new tab.
- * The default implementation does nothing.
- * This is only called if supportsTabs() returns true
- */
- virtual void openFolderinTabs(const KBookmarkGroup &bookmark);
-
- virtual QList< QPair<QString, QString> > currentBookmarkList() const;
-
-signals:
- /**
- * This signal is emitted when an url has to be loaded
- *
- * @param url the URL to load
- *
- */
- void openUrl(const KUrl &, const Rekonq::OpenType &);
-
-public slots:
- void bookmarkSelected(const KBookmark &bookmark);
-
- void openBookmark();
- void openBookmarkInNewTab();
- void openBookmarkInNewWindow();
- void openBookmarkFolder();
- void bookmarkCurrentPage();
- void newBookmarkFolder();
- void newSeparator();
- void copyLink();
- void editBookmark();
- bool deleteBookmark();
-
-private:
- KBookmarkManager *m_manager;
-
- QVector<KAction*> actions;
- KBookmark selected;
-
- void setupActions();
- void createAction(const BookmarkAction &action,
- const QString &text, const QString &icon,
- const QString &help, const char *slot);
-};
-
-
-// ------------------------------------------------------------------------------
+class BookmarksPanel;
+class BookmarkToolBar;
+class BookmarkOwner;
/**
diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp
index 3ab49c1e..231df638 100644
--- a/src/bookmarks/bookmarkspanel.cpp
+++ b/src/bookmarks/bookmarkspanel.cpp
@@ -34,6 +34,7 @@
#include "bookmarkstreemodel.h"
#include "bookmarksproxy.h"
#include "bookmarkscontextmenu.h"
+#include "bookmarkowner.h"
// Auto Includes
#include "rekonq.h"
diff --git a/src/bookmarks/bookmarkstoolbar.cpp b/src/bookmarks/bookmarkstoolbar.cpp
index 3fd9cdc7..3f103104 100644
--- a/src/bookmarks/bookmarkstoolbar.cpp
+++ b/src/bookmarks/bookmarkstoolbar.cpp
@@ -34,6 +34,10 @@
#include "mainwindow.h"
#include "application.h"
#include "bookmarksmanager.h"
+#include "bookmarkowner.h"
+
+// Qt Includes
+#include <QtGui/QFrame>
BookmarkMenu::BookmarkMenu(KBookmarkManager *manager,