summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt11
-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
-rw-r--r--src/mainwindow.cpp131
-rw-r--r--src/urlbar/bookmarkwidget.cpp1
10 files changed, 612 insertions, 546 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f7d94777..0130c2d4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -7,13 +7,13 @@ ADD_SUBDIRECTORY( tests )
### ------- SETTING REKONQ FILES..
SET( rekonq_KDEINIT_SRCS
- application.cpp
+ application.cpp
clicktoflash.cpp
filterurljob.cpp
findbar.cpp
zoombar.cpp
mainview.cpp
- mainwindow.cpp
+ mainwindow.cpp
networkaccessmanager.cpp
newtabpage.cpp
paneltreeview.cpp
@@ -31,7 +31,7 @@ SET( rekonq_KDEINIT_SRCS
webtab.cpp
searchengine.cpp
#----------------------------------------
- history/autosaver.cpp
+ history/autosaver.cpp
history/historymanager.cpp
history/historymodels.cpp
history/historypanel.cpp
@@ -50,6 +50,7 @@ SET( rekonq_KDEINIT_SRCS
bookmarks/bookmarksproxy.cpp
bookmarks/bookmarkscontextmenu.cpp
bookmarks/bookmarkstoolbar.cpp
+ bookmarks/bookmarkowner.cpp
#----------------------------------------
adblock/adblockmanager.cpp
adblock/adblocknetworkreply.cpp
@@ -110,8 +111,8 @@ KDE4_ADD_KDEINIT_EXECUTABLE( rekonq ${rekonq_KDEINIT_SRCS} main.cpp )
### --------------- TARGETTING LINK LIBRARIES...
TARGET_LINK_LIBRARIES ( kdeinit_rekonq
- ${QT_LIBRARIES}
- ${QT_QTWEBKIT_LIBRARY}
+ ${QT_LIBRARIES}
+ ${QT_QTWEBKIT_LIBRARY}
${KDE4_KDEWEBKIT_LIBS}
${KDE4_KUTILS_LIBS}
${KDE4_KDEUI_LIBS}
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,
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 73779627..1479e477 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -38,6 +38,7 @@
#include "settingsdialog.h"
#include "historymanager.h"
#include "bookmarksmanager.h"
+#include "bookmarkstoolbar.h"
#include "webtab.h"
#include "mainview.h"
#include "findbar.h"
@@ -139,16 +140,16 @@ MainWindow::MainWindow()
// setting up rekonq toolbar(s)
setupToolbars();
- // a call to KXmlGuiWindow::setupGUI() populates the GUI
- // with actions, using KXMLGUI.
- // It also applies the saved mainwindow settings, if any, and ask the
- // mainwindow to automatically save settings if changed: window size,
- // toolbar position, icon size, etc.
+ // a call to KXmlGuiWindow::setupGUI() populates the GUI
+ // with actions, using KXMLGUI.
+ // It also applies the saved mainwindow settings, if any, and ask the
+ // mainwindow to automatically save settings if changed: window size,
+ // toolbar position, icon size, etc.
setupGUI();
-
+
// no menu bar in rekonq: we have other plans..
menuBar()->setVisible(false);
-
+
// no more status bar..
setStatusBar(0);
@@ -164,7 +165,7 @@ MainWindow::~MainWindow()
Application::bookmarkProvider()->removeToolBar(m_bookmarksBar);
Application::bookmarkProvider()->removeBookmarkPanel(m_bookmarksPanel);
Application::instance()->removeMainWindow(this);
-
+
delete m_view;
delete m_findBar;
delete m_zoomBar;
@@ -187,7 +188,7 @@ MainWindow::~MainWindow()
void MainWindow::setupToolbars()
{
kDebug() << "setup toolbars...";
-
+
KAction *a;
// location bar
@@ -212,7 +213,7 @@ void MainWindow::setupToolbars()
void MainWindow::postLaunch()
{
setupBookmarksAndToolsShortcuts();
-
+
// setting popup notification
m_popup->setAutoDelete(false);
connect(Application::instance(), SIGNAL(focusChanged(QWidget*, QWidget*)), m_popup, SLOT(hide()));
@@ -246,7 +247,7 @@ void MainWindow::postLaunch()
connect(m_view, SIGNAL(currentChanged(int)), m_zoomBar, SLOT(updateSlider(int)));
// Ctrl + wheel handling
connect(this->currentTab()->view(), SIGNAL(zoomChanged(int)), m_zoomBar, SLOT(setValue(int)));
-
+
// setting up toolbars to NOT have context menu enabled
setContextMenuPolicy(Qt::DefaultContextMenu);
@@ -266,7 +267,7 @@ QSize MainWindow::sizeHint() const
void MainWindow::setupActions()
{
kDebug() << "setup actions...";
-
+
// this let shortcuts work..
actionCollection()->addAssociatedWidget(this);
@@ -377,7 +378,7 @@ void MainWindow::setupActions()
a->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev());
actionCollection()->addAction(QL1S("show_prev_tab"), a);
connect(a, SIGNAL(triggered(bool)), m_view, SLOT(previousTab()));
-
+
a = new KAction(KIcon("tab-new"), i18n("Open Closed Tabs"), this);
a->setShortcut(KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_T));
actionCollection()->addAction(QL1S("open_closed_tabs"), a);
@@ -443,7 +444,7 @@ void MainWindow::setupTools()
toolsMenu->setDelayed(false);
toolsMenu->setShortcutConfigurable(true);
toolsMenu->setShortcut( KShortcut(Qt::ALT + Qt::Key_T) );
-
+
toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Open)));
toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::SaveAs)));
toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Print)));
@@ -535,7 +536,7 @@ void MainWindow::setupPanels()
addDockWidget(Qt::BottomDockWidgetArea, m_webInspectorPanel);
m_webInspectorPanel->hide();
-
+
// STEP 4
// Setup Network analyzer panel
m_analyzerPanel = new NetworkAnalyzerPanel( i18n("Network Analyzer"), this);
@@ -572,7 +573,7 @@ void MainWindow::fileSaveAs()
srcUrl = w->url();
}
kDebug() << "URL to save: " << srcUrl;
-
+
QString name = srcUrl.fileName();
if (name.isNull())
{
@@ -609,7 +610,7 @@ void MainWindow::updateActions()
{
kDebug() << "updating actions..";
bool rekonqPage = currentTab()->page()->isOnRekonqPage();
-
+
QAction *historyBackAction = actionByName(KStandardAction::name(KStandardAction::Back));
if( rekonqPage && currentTab()->view()->history()->count() > 0 )
historyBackAction->setEnabled(true);
@@ -825,7 +826,7 @@ void MainWindow::setWidgetsVisible(bool makeVisible)
KToolBar *mainBar = toolBar("mainToolBar");
KToolBar *bookBar = toolBar("bookmarksToolBar");
-
+
if (!makeVisible)
{
// save current state, if in windowed mode
@@ -873,10 +874,10 @@ void MainWindow::viewPageSource()
void MainWindow::homePage(Qt::MouseButtons mouseButtons, Qt::KeyboardModifiers keyboardModifiers)
{
- KUrl homeUrl = ReKonfig::useNewTabPage()
+ KUrl homeUrl = ReKonfig::useNewTabPage()
? KUrl( QL1S("about:home") )
: KUrl( ReKonfig::homePage() );
-
+
if (mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier)
Application::instance()->loadUrl( homeUrl, Rekonq::NewTab);
else
@@ -918,7 +919,7 @@ void MainWindow::openPrevious(Qt::MouseButtons mouseButtons, Qt::KeyboardModifie
{
QWebHistory *history = currentTab()->view()->history();
QWebHistoryItem *item = 0;
-
+
if (currentTab()->page()->isOnRekonqPage())
{
item = new QWebHistoryItem(history->currentItem());
@@ -934,7 +935,7 @@ void MainWindow::openPrevious(Qt::MouseButtons mouseButtons, Qt::KeyboardModifie
if(!item)
return;
-
+
if (mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier)
{
Application::instance()->loadUrl(item->url(), Rekonq::NewTab);
@@ -965,10 +966,10 @@ void MainWindow::openNext(Qt::MouseButtons mouseButtons, Qt::KeyboardModifiers k
item = new QWebHistoryItem(history->forwardItem());
}
}
-
+
if(!item)
return;
-
+
if (mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier)
{
Application::instance()->loadUrl(item->url(), Rekonq::NewTab);
@@ -977,7 +978,7 @@ void MainWindow::openNext(Qt::MouseButtons mouseButtons, Qt::KeyboardModifiers k
{
history->goToItem(*item);
}
-
+
updateActions();
}
@@ -1169,7 +1170,7 @@ void MainWindow::aboutToShowBackMenu()
offset = pivot - 8;
/*
- * Need a bug report upstream.
+ * Need a bug report upstream.
* Seems setHtml() do some garbage in history
* Here history->currentItem() have backItem url and currentItem (error page) title
*/
@@ -1183,7 +1184,7 @@ void MainWindow::aboutToShowBackMenu()
action->setText(item.title());
m_historyBackMenu->addAction(action);
}
-
+
for (int i = listCount - 1; i >= 0; --i)
{
QWebHistoryItem item = historyList.at(i);
@@ -1224,7 +1225,7 @@ void MainWindow::setEncoding(QAction *qa)
currentTab()->view()->reload();
return;
}
-
+
currentTab()->view()->settings()->setDefaultTextEncoding(currentCodec);
currentTab()->view()->reload();
}
@@ -1234,7 +1235,7 @@ void MainWindow::populateEncodingMenu()
{
QStringList codecs;
QList<int> mibs = QTextCodec::availableMibs();
- Q_FOREACH (const int &mib, mibs)
+ Q_FOREACH (const int &mib, mibs)
{
QString codec = QLatin1String(QTextCodec::codecForMib(mib)->name());
codecs.append(codec);
@@ -1249,13 +1250,13 @@ void MainWindow::populateEncodingMenu()
KMenu *isciiMenu = new KMenu( QL1S("ISCII"), m_encodingMenu);
KMenu *uniMenu = new KMenu( QL1S("Unicode"), m_encodingMenu);
KMenu *otherMenu = new KMenu( i18n("Other"), m_encodingMenu);
-
+
QAction *a;
bool isDefaultCodecUsed = true;
-
+
Q_FOREACH(const QString &codec, codecs)
{
-
+
if( codec.startsWith( QL1S("ISO"), Qt::CaseInsensitive ) )
a = isoMenu->addAction(codec);
else if( codec.startsWith( QL1S("win") ) )
@@ -1264,9 +1265,9 @@ void MainWindow::populateEncodingMenu()
a = isciiMenu->addAction(codec);
else if( codec.startsWith( QL1S("UT") ) )
a = uniMenu->addAction(codec);
- else
+ else
a = otherMenu->addAction(codec);
-
+
a->setCheckable(true);
if (currentCodec == codec)
{
@@ -1274,11 +1275,11 @@ void MainWindow::populateEncodingMenu()
isDefaultCodecUsed = false;
}
}
-
+
a = new QAction( i18nc("Default website encoding", "Default"), this);
a->setCheckable(true);
a->setChecked(isDefaultCodecUsed);
-
+
m_encodingMenu->addAction( a );
m_encodingMenu->addMenu( isoMenu );
m_encodingMenu->addMenu( winMenu );
@@ -1300,36 +1301,36 @@ bool MainWindow::queryClose()
// this should fux bug 240432
if(Application::instance()->sessionSaving())
return true;
-
- if (m_view->count() > 1)
+
+ if (m_view->count() > 1)
{
- int answer = KMessageBox::questionYesNoCancel(
- this,
+ int answer = KMessageBox::questionYesNoCancel(
+ this,
i18np("Are you sure you want to close the window?\n" "You have 1 tab open.",
- "Are you sure you want to close the window?\n" "You have %1 tabs open.",
+ "Are you sure you want to close the window?\n" "You have %1 tabs open.",
m_view->count()),
- i18n("Are you sure you want to close the window?"),
- KStandardGuiItem::quit(),
- KGuiItem(i18n("C&lose Current Tab"), KIcon("tab-close")),
- KStandardGuiItem::cancel(),
- "confirmClosingMultipleTabs"
- );
-
- switch (answer)
- {
- case KMessageBox::Yes:
- // Quit
- return true;
-
- case KMessageBox::No:
- // Close only the current tab
+ i18n("Are you sure you want to close the window?"),
+ KStandardGuiItem::quit(),
+ KGuiItem(i18n("C&lose Current Tab"), KIcon("tab-close")),
+ KStandardGuiItem::cancel(),
+ "confirmClosingMultipleTabs"
+ );
+
+ switch (answer)
+ {
+ case KMessageBox::Yes:
+ // Quit
+ return true;
+
+ case KMessageBox::No:
+ // Close only the current tab
m_view->closeTab();
-
- default:
- return false;
- }
- }
- return true;
+
+ default:
+ return false;
+ }
+ }
+ return true;
}
@@ -1343,16 +1344,16 @@ void MainWindow::saveNewToolbarConfig()
void MainWindow::setupBookmarksAndToolsShortcuts()
{
KToolBar *mainBar = toolBar("mainToolBar");
-
+
QToolButton *bookmarksButton = qobject_cast<QToolButton*>(mainBar->widgetForAction(actionByName( QL1S("bookmarksActionMenu") )));
if(bookmarksButton)
{
connect(actionByName(QL1S("bookmarksActionMenu")), SIGNAL(triggered()), bookmarksButton, SLOT(showMenu()));
}
-
+
QToolButton *toolsButton = qobject_cast<QToolButton*>(mainBar->widgetForAction(actionByName( QL1S("rekonq_tools") )));
if(toolsButton)
{
connect(actionByName(QL1S("rekonq_tools")), SIGNAL(triggered()), toolsButton, SLOT(showMenu()));
- }
+ }
}
diff --git a/src/urlbar/bookmarkwidget.cpp b/src/urlbar/bookmarkwidget.cpp
index 196c9df1..5a2e6434 100644
--- a/src/urlbar/bookmarkwidget.cpp
+++ b/src/urlbar/bookmarkwidget.cpp
@@ -31,6 +31,7 @@
// Local includes
#include "application.h"
#include "bookmarksmanager.h"
+#include "bookmarkowner.h"
// KDE Includes
#include <KLocalizedString>