From b111a11cb46bfd572c2fed9c67d648bcff10a3ce Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 14 Nov 2011 18:49:04 +0100 Subject: BookmarkProvider --> BookmarkManager We have 7 managers and 1 provider... finally fixing this strange thing! --- src/CMakeLists.txt | 2 +- src/application.cpp | 20 +- src/application.h | 6 +- src/bookmarks/bookmarkmanager.cpp | 349 +++++++++++++++++++++++++++++++++ src/bookmarks/bookmarkmanager.h | 165 ++++++++++++++++ src/bookmarks/bookmarkowner.cpp | 6 +- src/bookmarks/bookmarkprovider.cpp | 323 ------------------------------ src/bookmarks/bookmarkprovider.h | 158 --------------- src/bookmarks/bookmarkscontextmenu.cpp | 13 +- src/bookmarks/bookmarkspanel.cpp | 8 +- src/bookmarks/bookmarkstoolbar.cpp | 24 +-- src/bookmarks/bookmarkstreemodel.cpp | 15 +- src/mainwindow.cpp | 12 +- src/newtabpage.cpp | 6 +- src/sync/syncmanager.cpp | 8 +- src/urlbar/bookmarkwidget.cpp | 6 +- src/urlbar/favoritewidget.cpp | 2 +- src/urlbar/urlbar.cpp | 10 +- src/urlbar/urlresolver.cpp | 4 +- src/webview.cpp | 13 +- 20 files changed, 595 insertions(+), 555 deletions(-) create mode 100644 src/bookmarks/bookmarkmanager.cpp create mode 100644 src/bookmarks/bookmarkmanager.h delete mode 100644 src/bookmarks/bookmarkprovider.cpp delete mode 100644 src/bookmarks/bookmarkprovider.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f8a6124a..11f079a6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -52,7 +52,7 @@ SET( rekonq_KDEINIT_SRCS settings/webkitwidget.cpp settings/networkwidget.cpp #---------------------------------------- - bookmarks/bookmarkprovider.cpp + bookmarks/bookmarkmanager.cpp bookmarks/bookmarkspanel.cpp bookmarks/bookmarkstreemodel.cpp bookmarks/bookmarkscontextmenu.cpp diff --git a/src/application.cpp b/src/application.cpp index 768f25a2..5c6e9659 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -38,7 +38,7 @@ // Local Includes #include "adblockmanager.h" -#include "bookmarkprovider.h" +#include "bookmarkmanager.h" #include "downloadmanager.h" #include "filterurljob.h" #include "historymanager.h" @@ -109,11 +109,11 @@ Application::~Application() m_historyManager.clear(); } - if (!m_bookmarkProvider.isNull()) + if (!m_bookmarkManager.isNull()) { - kDebug() << "deleting bookmark Provider"; - delete m_bookmarkProvider.data(); - m_bookmarkProvider.clear(); + kDebug() << "deleting bookmark Manager"; + delete m_bookmarkManager.data(); + m_bookmarkManager.clear(); } if (!m_sessionManager.isNull()) @@ -293,7 +293,7 @@ int Application::newInstance() historyManager(); // bookmarks loading - connect(bookmarkProvider(), SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType&)), + connect(bookmarkManager(), SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType&)), instance(), SLOT(loadUrl(const KUrl&, const Rekonq::OpenType&))); // crash recovering @@ -351,13 +351,13 @@ HistoryManager *Application::historyManager() } -BookmarkProvider *Application::bookmarkProvider() +BookmarkManager *Application::bookmarkManager() { - if (m_bookmarkProvider.isNull()) + if (m_bookmarkManager.isNull()) { - m_bookmarkProvider = new BookmarkProvider; + m_bookmarkManager = new BookmarkManager; } - return m_bookmarkProvider.data(); + return m_bookmarkManager.data(); } diff --git a/src/application.h b/src/application.h index 6a67ca61..ee1a6430 100644 --- a/src/application.h +++ b/src/application.h @@ -45,7 +45,7 @@ // Forward Declarations class AdBlockManager; -class BookmarkProvider; +class BookmarkManager; class DownloadManager; class HistoryManager; class IconManager; @@ -90,7 +90,7 @@ public: MainWindowList mainWindowList(); HistoryManager *historyManager(); - BookmarkProvider *bookmarkProvider(); + BookmarkManager *bookmarkManager(); SessionManager *sessionManager(); AdBlockManager *adblockManager(); OpenSearchManager *opensearchManager(); @@ -137,7 +137,7 @@ private Q_SLOTS: private: QWeakPointer m_historyManager; - QWeakPointer m_bookmarkProvider; + QWeakPointer m_bookmarkManager; QWeakPointer m_sessionManager; QWeakPointer m_adblockManager; QWeakPointer m_opensearchManager; diff --git a/src/bookmarks/bookmarkmanager.cpp b/src/bookmarks/bookmarkmanager.cpp new file mode 100644 index 00000000..49c697a5 --- /dev/null +++ b/src/bookmarks/bookmarkmanager.cpp @@ -0,0 +1,349 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2008-2011 by Andrea Diamantini +* Copyright (C) 2009 by Paweł Prażak +* Copyright (C) 2009-2010 by Lionel Chauvin +* Copyright (C) 2010 by Yoann Laissus +* +* +* 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 . +* +* ============================================================ */ + + +// Self Includes +#include "bookmarkmanager.h" +#include "bookmarkmanager.moc" + +// Local Includes +#include "application.h" +#include "bookmarkspanel.h" +#include "bookmarkstoolbar.h" +#include "bookmarkowner.h" +#include "iconmanager.h" +#include "mainwindow.h" +#include "webtab.h" + +// KDE Includes +#include +#include + +// Qt Includes +#include + + +BookmarkManager::BookmarkManager(QObject *parent) + : QObject(parent) + , m_manager(0) + , m_owner(0) + , m_actionCollection(new KActionCollection(this)) +{ + m_manager = KBookmarkManager::userBookmarksManager(); + const QString bookmarksFile = KStandardDirs::locateLocal("data", QString::fromLatin1("konqueror/bookmarks.xml")); + + if (!QFile::exists(bookmarksFile)) + { + kDebug() << "copying of defaultbookmarks.xbel ..."; + + QString bookmarksDefaultPath = KStandardDirs::locate("appdata" , "defaultbookmarks.xbel"); + KBookmarkManager *tempManager = KBookmarkManager::managerForExternalFile(bookmarksDefaultPath); + + copyBookmarkGroup(tempManager->root(), rootGroup()); + m_manager->emitChanged(); + delete tempManager; + } + + connect(m_manager, SIGNAL(changed(const QString &, const QString &)), this, SLOT(slotBookmarksChanged())); + + // setup menu + m_owner = new BookmarkOwner(m_manager, this); + connect(m_owner, SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType&)), + this, SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType&))); + + KAction *a = KStandardAction::addBookmark(m_owner, SLOT(bookmarkCurrentPage()), this); + m_actionCollection->addAction(QL1S("rekonq_add_bookmark"), a); +} + + +BookmarkManager::~BookmarkManager() +{ + delete m_manager; +} + + +KActionMenu* BookmarkManager::bookmarkActionMenu(QWidget *parent) +{ + KMenu *menu = new KMenu(parent); + KActionMenu *bookmarkActionMenu = new KActionMenu(menu); + bookmarkActionMenu->setMenu(menu); + bookmarkActionMenu->setText(i18n("&Bookmarks")); + BookmarkMenu *bMenu = new BookmarkMenu(m_manager, m_owner, menu, m_actionCollection); + bMenu->setParent(menu); + + return bookmarkActionMenu; +} + + +void BookmarkManager::registerBookmarkBar(BookmarkToolBar *toolbar) +{ + if (m_bookmarkToolBars.contains(toolbar)) + return; + + m_bookmarkToolBars.append(toolbar); +} + + +void BookmarkManager::removeBookmarkBar(BookmarkToolBar *toolbar) +{ + m_bookmarkToolBars.removeOne(toolbar); +} + + +void BookmarkManager::registerBookmarkPanel(BookmarksPanel *panel) +{ + if (panel && !m_bookmarkPanels.contains(panel)) + { + m_bookmarkPanels.append(panel); + connect(panel, SIGNAL(expansionChanged()), this, SLOT(slotPanelChanged())); + } +} + + +void BookmarkManager::removeBookmarkPanel(BookmarksPanel *panel) +{ + if (!panel) + return; + + m_bookmarkPanels.removeOne(panel); + panel->disconnect(this); + + if (m_bookmarkPanels.isEmpty()) + emitChanged(); +} + + +QAction* BookmarkManager::actionByName(const QString &name) +{ + QAction *action = m_actionCollection->action(name); + if (action) + return action; + return new QAction(this); +} + + +KBookmarkGroup BookmarkManager::rootGroup() +{ + return m_manager->root(); +} + + +QList BookmarkManager::find(const QString &text) +{ + QList list; + + KBookmarkGroup root = rootGroup(); + if (!root.isNull()) + for (KBookmark bookmark = root.first(); !bookmark.isNull(); bookmark = root.next(bookmark)) + find(&list, bookmark, text); + + return list; +} + + +KBookmark BookmarkManager::bookmarkForUrl(const KUrl &url) +{ + KBookmarkGroup root = rootGroup(); + if (root.isNull()) + return KBookmark(); + + return bookmarkForUrl(root, url); +} + + +void BookmarkManager::slotBookmarksChanged() +{ + Q_FOREACH(BookmarkToolBar * bookmarkToolBar, m_bookmarkToolBars) + { + if (bookmarkToolBar) + { + bookmarkToolBar->toolBar()->clear(); + fillBookmarkBar(bookmarkToolBar); + } + } + if (rApp->mainWindow() + && rApp->mainWindow()->currentTab() + && rApp->mainWindow()->currentTab()->url().toMimeDataString().contains("about:bookmarks") + ) + rApp->loadUrl(KUrl("about:bookmarks"), Rekonq::CurrentTab); +} + + +void BookmarkManager::fillBookmarkBar(BookmarkToolBar *toolBar) +{ + KBookmarkGroup root = m_manager->toolbar(); + if (root.isNull()) + return; + + for (KBookmark bookmark = root.first(); !bookmark.isNull(); bookmark = root.next(bookmark)) + { + if (bookmark.isGroup()) + { + KBookmarkActionMenu *menuAction = new KBookmarkActionMenu(bookmark.toGroup(), this); + menuAction->setDelayed(false); + BookmarkMenu *bMenu = new BookmarkMenu(m_manager, m_owner, menuAction->menu(), bookmark.address()); + bMenu->setParent(menuAction->menu()); + + connect(menuAction->menu(), SIGNAL(aboutToShow()), toolBar, SLOT(menuDisplayed())); + connect(menuAction->menu(), SIGNAL(aboutToHide()), toolBar, SLOT(menuHidden())); + + toolBar->toolBar()->addAction(menuAction); + toolBar->toolBar()->widgetForAction(menuAction)->installEventFilter(toolBar); + } + else if (bookmark.isSeparator()) + { + toolBar->toolBar()->addSeparator(); + } + else + { + KBookmarkAction *action = new KBookmarkAction(bookmark, m_owner, this); + action->setIcon(rApp->iconManager()->iconForUrl(KUrl(bookmark.url()))); + connect(action, SIGNAL(hovered()), toolBar, SLOT(actionHovered())); + toolBar->toolBar()->addAction(action); + toolBar->toolBar()->widgetForAction(action)->installEventFilter(toolBar); + } + } +} + + +void BookmarkManager::slotPanelChanged() +{ + Q_FOREACH(BookmarksPanel * panel, m_bookmarkPanels) + { + if (panel && panel != sender()) + panel->loadFoldedState(); + } + if (rApp->mainWindow() + && rApp->mainWindow()->currentTab() + && rApp->mainWindow()->currentTab()->url().toMimeDataString().contains("about:bookmarks") + ) + rApp->loadUrl(KUrl("about:bookmarks"), Rekonq::CurrentTab); +} + + +void BookmarkManager::find(QList *list, const KBookmark &bookmark, const QString &text) +{ + if (bookmark.isGroup()) + { + KBookmarkGroup group = bookmark.toGroup(); + for (KBookmark bm = group.first(); !bm.isNull(); bm = group.next(bm)) + find(list, bm, text); + } + else + { + QStringList words = text.split(' '); + bool matches = true; + Q_FOREACH(const QString & word, words) + { + if (!bookmark.url().url().contains(word, Qt::CaseInsensitive) + && !bookmark.fullText().contains(word, Qt::CaseInsensitive)) + { + matches = false; + break; + } + } + if (matches) + *list << bookmark; + } +} + + +KBookmark BookmarkManager::bookmarkForUrl(const KBookmark &bookmark, const KUrl &url) +{ + KBookmark found; + + if (bookmark.isGroup()) + { + KBookmarkGroup group = bookmark.toGroup(); + KBookmark bookmark = group.first(); + + while (!bookmark.isNull() && found.isNull()) + { + found = bookmarkForUrl(bookmark, url); + bookmark = group.next(bookmark); + } + } + else if (!bookmark.isSeparator() && bookmark.url() == url) + { + found = bookmark; + } + + return found; +} + + +void BookmarkManager::copyBookmarkGroup(const KBookmarkGroup &groupToCopy, KBookmarkGroup destGroup) +{ + KBookmark bookmark = groupToCopy.first(); + while (!bookmark.isNull()) + { + if (bookmark.isGroup()) + { + KBookmarkGroup newDestGroup = destGroup.createNewFolder(bookmark.text()); + if (bookmark.toGroup().isToolbarGroup()) + { + newDestGroup.internalElement().setAttribute("toolbar", "yes"); + newDestGroup.setIcon("bookmark-toolbar"); + } + copyBookmarkGroup(bookmark.toGroup(), newDestGroup); + } + else if (bookmark.isSeparator()) + { + destGroup.createNewSeparator(); + } + else + { + destGroup.addBookmark(bookmark.text(), bookmark.url()); + } + bookmark = groupToCopy.next(bookmark); + } +} + + +void BookmarkManager::slotEditBookmarks() +{ + m_manager->slotEditBookmarks(); +} + + +KBookmark BookmarkManager::findByAddress(const QString &address) +{ + return m_manager->findByAddress(address); +} + + +void BookmarkManager::openFolderinTabs(const KBookmarkGroup &bm) +{ + m_owner->openFolderinTabs(bm); +} + + +void BookmarkManager::emitChanged() +{ + m_manager->emitChanged(); +} diff --git a/src/bookmarks/bookmarkmanager.h b/src/bookmarks/bookmarkmanager.h new file mode 100644 index 00000000..b00a4b0e --- /dev/null +++ b/src/bookmarks/bookmarkmanager.h @@ -0,0 +1,165 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2008-2011 by Andrea Diamantini +* Copyright (C) 2009 by Paweł Prażak +* Copyright (C) 2009-2010 by Lionel Chauvin +* Copyright (C) 2010 by Yoann Laissus +* +* +* 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 . +* +* ============================================================ */ + + +#ifndef BOOKMARK_MANAGER_H +#define BOOKMARK_MANAGER_H + + +// Rekonq Includes +#include "rekonq_defines.h" + +// KDE Includes +#include + +// Qt Includes +#include + +// Forward Declarations +class BookmarksPanel; +class BookmarkToolBar; +class BookmarkOwner; +class BookmarkMenu; + +class KAction; +class KActionCollection; +class KActionMenu; +class KBookmarkGroup; +class KBookmarkManager; +class KUrl; + +class QAction; + + +/** + * This class represent the interface to rekonq bookmarks system. + * All rekonq needs (Bookmarks Menu, Bookmarks Toolbar) is provided + * from this class. + * So it implements code to have each one. + */ +class BookmarkManager : public QObject +{ + Q_OBJECT + +public: + /** + * @short Class constructor. + * Connect BookmarksProvider with bookmarks source + * (actually konqueror's bookmarks). + * @param parent The MainWindow to provide bookmarks objects. + */ + BookmarkManager(QObject *parent = 0); + ~BookmarkManager(); + + /** + * @short Get the Bookmarks Menu Action + * @param the parent widget + * @return the Bookmarks Menu + */ + KActionMenu* bookmarkActionMenu(QWidget *parent); + + /** + * @short set the Bookmarks Toolbar Action + */ + void registerBookmarkBar(BookmarkToolBar *toolbar); + void removeBookmarkBar(BookmarkToolBar *toolbar); + + void registerBookmarkPanel(BookmarksPanel *panel); + void removeBookmarkPanel(BookmarksPanel *panel); + + /** + * @short Get action by name + * This method returns poiner bookmark action of given name. + * @pre m_actionCollection != NULL + * @param name Name of action you want to get + * @return It returns actions if one exists or empty object + */ + QAction* actionByName(const QString &name); + + /** + * returns Bookmark Manager root group + * + * @return the root bookmark group + */ + KBookmarkGroup rootGroup(); + + inline KBookmarkManager* manager() + { + return m_manager; + } + + inline BookmarkOwner* owner() + { + return m_owner; + } + + QList find(const QString &text); + + KBookmark bookmarkForUrl(const KUrl &url); + + KBookmark findByAddress(const QString &); + void openFolderinTabs(const KBookmarkGroup &bm); + void emitChanged(); + +public Q_SLOTS: + /** + * @short Waits for signal that the group with the address has been modified by the caller. + * Waits for signal that the group (or any of its children) with the address + * @p groupAddress (e.g. "/4/5") has been modified by the caller @p caller. + * @param groupAddress bookmark group address + * @param caller caller that modified the bookmarks + * @see KBookmarkManager::changed + */ + void slotBookmarksChanged(); + void fillBookmarkBar(BookmarkToolBar *toolBar); + + void slotEditBookmarks(); + +private Q_SLOTS: + void slotPanelChanged(); + +Q_SIGNALS: + /** + * @short This signal is emitted when an url has to be loaded + */ + void openUrl(const KUrl &, const Rekonq::OpenType &); + +private: + void find(QList *list, const KBookmark &bookmark, const QString &text); + KBookmark bookmarkForUrl(const KBookmark &bookmark, const KUrl &url); + void copyBookmarkGroup(const KBookmarkGroup &groupToCopy, KBookmarkGroup destGroup); + + KBookmarkManager *m_manager; + BookmarkOwner *m_owner; + KActionCollection *m_actionCollection; + QList m_bookmarkToolBars; + QList m_bookmarkPanels; +}; + + +#endif // BOOKMARK_MANAGER_H diff --git a/src/bookmarks/bookmarkowner.cpp b/src/bookmarks/bookmarkowner.cpp index 40b070dd..0d3894e5 100644 --- a/src/bookmarks/bookmarkowner.cpp +++ b/src/bookmarks/bookmarkowner.cpp @@ -33,7 +33,7 @@ // Local Includes #include "application.h" -#include "bookmarkprovider.h" +#include "bookmarkmanager.h" #include "mainview.h" #include "mainwindow.h" #include "webtab.h" @@ -204,7 +204,7 @@ KBookmark BookmarkOwner::bookmarkCurrentPage(const KBookmark &bookmark) } else { - parent = rApp->bookmarkProvider()->rootGroup(); + parent = rApp->bookmarkManager()->rootGroup(); } KBookmark newBk = parent.addBookmark(currentTitle(), KUrl(currentUrl())); @@ -267,7 +267,7 @@ KBookmark BookmarkOwner::newSeparator(const KBookmark &bookmark) } else { - newBk = rApp->bookmarkProvider()->rootGroup().createNewSeparator(); + newBk = rApp->bookmarkManager()->rootGroup().createNewSeparator(); } newBk.setIcon("edit-clear"); diff --git a/src/bookmarks/bookmarkprovider.cpp b/src/bookmarks/bookmarkprovider.cpp deleted file mode 100644 index 262941d8..00000000 --- a/src/bookmarks/bookmarkprovider.cpp +++ /dev/null @@ -1,323 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2008-2011 by Andrea Diamantini -* Copyright (C) 2009 by Paweł Prażak -* Copyright (C) 2009-2010 by Lionel Chauvin -* Copyright (C) 2010 by Yoann Laissus -* -* -* 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 . -* -* ============================================================ */ - - -// Self Includes -#include "bookmarkprovider.h" -#include "bookmarkprovider.moc" - -// Local Includes -#include "application.h" -#include "bookmarkspanel.h" -#include "bookmarkstoolbar.h" -#include "bookmarkowner.h" -#include "iconmanager.h" -#include "mainwindow.h" -#include "webtab.h" - -// KDE Includes -#include -#include - -// Qt Includes -#include - - -BookmarkProvider::BookmarkProvider(QObject *parent) - : QObject(parent) - , m_manager(0) - , m_owner(0) - , m_actionCollection(new KActionCollection(this)) -{ - m_manager = KBookmarkManager::userBookmarksManager(); - const QString bookmarksFile = KStandardDirs::locateLocal("data", QString::fromLatin1("konqueror/bookmarks.xml")); - - if (!QFile::exists(bookmarksFile)) - { - kDebug() << "copying of defaultbookmarks.xbel ..."; - - QString bookmarksDefaultPath = KStandardDirs::locate("appdata" , "defaultbookmarks.xbel"); - KBookmarkManager *tempManager = KBookmarkManager::managerForExternalFile(bookmarksDefaultPath); - - copyBookmarkGroup(tempManager->root(), rootGroup()); - m_manager->emitChanged(); - delete tempManager; - } - - connect(m_manager, SIGNAL(changed(const QString &, const QString &)), this, SLOT(slotBookmarksChanged())); - connect(m_manager, SIGNAL(changed(const QString &, const QString &)), this, SIGNAL(changed())); - - // setup menu - m_owner = new BookmarkOwner(m_manager, this); - connect(m_owner, SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType&)), - this, SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType&))); - - KAction *a = KStandardAction::addBookmark(bookmarkOwner(), SLOT(bookmarkCurrentPage()), this); - m_actionCollection->addAction(QL1S("rekonq_add_bookmark"), a); -} - - -BookmarkProvider::~BookmarkProvider() -{ - delete m_manager; -} - - -KActionMenu* BookmarkProvider::bookmarkActionMenu(QWidget *parent) -{ - KMenu *menu = new KMenu(parent); - KActionMenu *bookmarkActionMenu = new KActionMenu(menu); - bookmarkActionMenu->setMenu(menu); - bookmarkActionMenu->setText(i18n("&Bookmarks")); - BookmarkMenu *bMenu = new BookmarkMenu(m_manager, m_owner, menu, m_actionCollection); - bMenu->setParent(menu); - - return bookmarkActionMenu; -} - - -void BookmarkProvider::registerBookmarkBar(BookmarkToolBar *toolbar) -{ - if (m_bookmarkToolBars.contains(toolbar)) - return; - - m_bookmarkToolBars.append(toolbar); -} - - -void BookmarkProvider::removeBookmarkBar(BookmarkToolBar *toolbar) -{ - m_bookmarkToolBars.removeOne(toolbar); -} - - -void BookmarkProvider::registerBookmarkPanel(BookmarksPanel *panel) -{ - if (panel && !m_bookmarkPanels.contains(panel)) - { - m_bookmarkPanels.append(panel); - connect(panel, SIGNAL(expansionChanged()), this, SLOT(slotPanelChanged())); - } -} - - -void BookmarkProvider::removeBookmarkPanel(BookmarksPanel *panel) -{ - if (!panel) - return; - - m_bookmarkPanels.removeOne(panel); - panel->disconnect(this); - - if (m_bookmarkPanels.isEmpty()) - rApp->bookmarkProvider()->bookmarkManager()->emitChanged(); -} - - -QAction* BookmarkProvider::actionByName(const QString &name) -{ - QAction *action = m_actionCollection->action(name); - if (action) - return action; - return new QAction(this); -} - - -KBookmarkGroup BookmarkProvider::rootGroup() -{ - return m_manager->root(); -} - - -QList BookmarkProvider::find(const QString &text) -{ - QList list; - - KBookmarkGroup root = rApp->bookmarkProvider()->rootGroup(); - if (!root.isNull()) - for (KBookmark bookmark = root.first(); !bookmark.isNull(); bookmark = root.next(bookmark)) - find(&list, bookmark, text); - - return list; -} - - -KBookmark BookmarkProvider::bookmarkForUrl(const KUrl &url) -{ - KBookmarkGroup root = rootGroup(); - if (root.isNull()) - return KBookmark(); - - return bookmarkForUrl(root, url); -} - - -void BookmarkProvider::slotBookmarksChanged() -{ - Q_FOREACH(BookmarkToolBar * bookmarkToolBar, m_bookmarkToolBars) - { - if (bookmarkToolBar) - { - bookmarkToolBar->toolBar()->clear(); - fillBookmarkBar(bookmarkToolBar); - } - } - if (rApp->mainWindow() - && rApp->mainWindow()->currentTab() - && rApp->mainWindow()->currentTab()->url().toMimeDataString().contains("about:bookmarks") - ) - rApp->loadUrl(KUrl("about:bookmarks"), Rekonq::CurrentTab); -} - - -void BookmarkProvider::fillBookmarkBar(BookmarkToolBar *toolBar) -{ - KBookmarkGroup root = m_manager->toolbar(); - if (root.isNull()) - return; - - for (KBookmark bookmark = root.first(); !bookmark.isNull(); bookmark = root.next(bookmark)) - { - if (bookmark.isGroup()) - { - KBookmarkActionMenu *menuAction = new KBookmarkActionMenu(bookmark.toGroup(), this); - menuAction->setDelayed(false); - BookmarkMenu *bMenu = new BookmarkMenu(bookmarkManager(), bookmarkOwner(), menuAction->menu(), bookmark.address()); - bMenu->setParent(menuAction->menu()); - - connect(menuAction->menu(), SIGNAL(aboutToShow()), toolBar, SLOT(menuDisplayed())); - connect(menuAction->menu(), SIGNAL(aboutToHide()), toolBar, SLOT(menuHidden())); - - toolBar->toolBar()->addAction(menuAction); - toolBar->toolBar()->widgetForAction(menuAction)->installEventFilter(toolBar); - } - else if (bookmark.isSeparator()) - { - toolBar->toolBar()->addSeparator(); - } - else - { - KBookmarkAction *action = new KBookmarkAction(bookmark, m_owner, this); - action->setIcon(rApp->iconManager()->iconForUrl(KUrl(bookmark.url()))); - connect(action, SIGNAL(hovered()), toolBar, SLOT(actionHovered())); - toolBar->toolBar()->addAction(action); - toolBar->toolBar()->widgetForAction(action)->installEventFilter(toolBar); - } - } -} - - -void BookmarkProvider::slotPanelChanged() -{ - Q_FOREACH(BookmarksPanel * panel, m_bookmarkPanels) - { - if (panel && panel != sender()) - panel->loadFoldedState(); - } - if (rApp->mainWindow() && rApp->mainWindow()->currentTab() && rApp->mainWindow()->currentTab()->url().toMimeDataString().contains("about:bookmarks")) - rApp->loadUrl(KUrl("about:bookmarks"), Rekonq::CurrentTab); -} - - -void BookmarkProvider::find(QList *list, const KBookmark &bookmark, const QString &text) -{ - if (bookmark.isGroup()) - { - KBookmarkGroup group = bookmark.toGroup(); - for (KBookmark bm = group.first(); !bm.isNull(); bm = group.next(bm)) - find(list, bm, text); - } - else - { - QStringList words = text.split(' '); - bool matches = true; - Q_FOREACH(const QString & word, words) - { - if (!bookmark.url().url().contains(word, Qt::CaseInsensitive) - && !bookmark.fullText().contains(word, Qt::CaseInsensitive)) - { - matches = false; - break; - } - } - if (matches) - *list << bookmark; - } -} - - -KBookmark BookmarkProvider::bookmarkForUrl(const KBookmark &bookmark, const KUrl &url) -{ - KBookmark found; - - if (bookmark.isGroup()) - { - KBookmarkGroup group = bookmark.toGroup(); - KBookmark bookmark = group.first(); - - while (!bookmark.isNull() && found.isNull()) - { - found = bookmarkForUrl(bookmark, url); - bookmark = group.next(bookmark); - } - } - else if (!bookmark.isSeparator() && bookmark.url() == url) - { - found = bookmark; - } - - return found; -} - - -void BookmarkProvider::copyBookmarkGroup(const KBookmarkGroup &groupToCopy, KBookmarkGroup destGroup) -{ - KBookmark bookmark = groupToCopy.first(); - while (!bookmark.isNull()) - { - if (bookmark.isGroup()) - { - KBookmarkGroup newDestGroup = destGroup.createNewFolder(bookmark.text()); - if (bookmark.toGroup().isToolbarGroup()) - { - newDestGroup.internalElement().setAttribute("toolbar", "yes"); - newDestGroup.setIcon("bookmark-toolbar"); - } - copyBookmarkGroup(bookmark.toGroup(), newDestGroup); - } - else if (bookmark.isSeparator()) - { - destGroup.createNewSeparator(); - } - else - { - destGroup.addBookmark(bookmark.text(), bookmark.url()); - } - bookmark = groupToCopy.next(bookmark); - } -} diff --git a/src/bookmarks/bookmarkprovider.h b/src/bookmarks/bookmarkprovider.h deleted file mode 100644 index db7efe45..00000000 --- a/src/bookmarks/bookmarkprovider.h +++ /dev/null @@ -1,158 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2008-2011 by Andrea Diamantini -* Copyright (C) 2009 by Paweł Prażak -* Copyright (C) 2009-2010 by Lionel Chauvin -* Copyright (C) 2010 by Yoann Laissus -* -* -* 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 . -* -* ============================================================ */ - - -#ifndef BOOKMARKPROVIDER_H -#define BOOKMARKPROVIDER_H - - -// Rekonq Includes -#include "rekonq_defines.h" - -// Qt Includes -#include - -// Forward Declarations -class BookmarksPanel; -class BookmarkToolBar; -class BookmarkOwner; -class BookmarkMenu; - -class KAction; -class KActionCollection; -class KActionMenu; -class KBookmark; -class KBookmarkGroup; -class KBookmarkManager; -class KUrl; - -class QAction; - - -/** - * This class represent the interface to rekonq bookmarks system. - * All rekonq needs (Bookmarks Menu, Bookmarks Toolbar) is provided - * from this class. - * So it implements code to have each one. - */ -class BookmarkProvider : public QObject -{ - Q_OBJECT - -public: - /** - * @short Class constructor. - * Connect BookmarksProvider with bookmarks source - * (actually konqueror's bookmarks). - * @param parent The MainWindow to provide bookmarks objects. - */ - BookmarkProvider(QObject *parent = 0); - ~BookmarkProvider(); - - /** - * @short Get the Bookmarks Menu Action - * @param the parent widget - * @return the Bookmarks Menu - */ - KActionMenu* bookmarkActionMenu(QWidget *parent); - - /** - * @short set the Bookmarks Toolbar Action - */ - void registerBookmarkBar(BookmarkToolBar *toolbar); - void removeBookmarkBar(BookmarkToolBar *toolbar); - - void registerBookmarkPanel(BookmarksPanel *panel); - void removeBookmarkPanel(BookmarksPanel *panel); - - /** - * @short Get action by name - * This method returns poiner bookmark action of given name. - * @pre m_actionCollection != NULL - * @param name Name of action you want to get - * @return It returns actions if one exists or empty object - */ - QAction* actionByName(const QString &name); - - /** - * returns Bookmark Manager root group - * - * @return the root bookmark group - */ - KBookmarkGroup rootGroup(); - - inline KBookmarkManager* bookmarkManager() - { - return m_manager; - } - - inline BookmarkOwner* bookmarkOwner() - { - return m_owner; - } - - QList find(const QString &text); - - KBookmark bookmarkForUrl(const KUrl &url); - -public Q_SLOTS: - /** - * @short Waits for signal that the group with the address has been modified by the caller. - * Waits for signal that the group (or any of its children) with the address - * @p groupAddress (e.g. "/4/5") has been modified by the caller @p caller. - * @param groupAddress bookmark group address - * @param caller caller that modified the bookmarks - * @see KBookmarkManager::changed - */ - void slotBookmarksChanged(); - void fillBookmarkBar(BookmarkToolBar *toolBar); - -private Q_SLOTS: - void slotPanelChanged(); - -Q_SIGNALS: - /** - * @short This signal is emitted when an url has to be loaded - */ - void openUrl(const KUrl &, const Rekonq::OpenType &); - void emitChanged(); - -private: - void find(QList *list, const KBookmark &bookmark, const QString &text); - KBookmark bookmarkForUrl(const KBookmark &bookmark, const KUrl &url); - void copyBookmarkGroup(const KBookmarkGroup &groupToCopy, KBookmarkGroup destGroup); - - KBookmarkManager *m_manager; - BookmarkOwner *m_owner; - KActionCollection *m_actionCollection; - QList m_bookmarkToolBars; - QList m_bookmarkPanels; -}; - - -#endif // BOOKMARKPROVIDER_H diff --git a/src/bookmarks/bookmarkscontextmenu.cpp b/src/bookmarks/bookmarkscontextmenu.cpp index 735e3412..355a6d7f 100644 --- a/src/bookmarks/bookmarkscontextmenu.cpp +++ b/src/bookmarks/bookmarkscontextmenu.cpp @@ -29,14 +29,19 @@ // Local Includes #include "bookmarkowner.h" -#include "bookmarkprovider.h" +#include "bookmarkmanager.h" #include "application.h" // KDE Includes #include -BookmarksContextMenu::BookmarksContextMenu(const KBookmark &bookmark, KBookmarkManager *manager, BookmarkOwner *owner, bool nullForced, QWidget *parent) +BookmarksContextMenu::BookmarksContextMenu(const KBookmark &bookmark, + KBookmarkManager *manager, + BookmarkOwner *owner, + bool nullForced, + QWidget *parent + ) : KBookmarkContextMenu(bookmark, manager, owner, parent) , m_bmOwner(owner) , m_nullForced(nullForced) @@ -120,8 +125,8 @@ void BookmarksContextMenu::addSeparatorActions() void BookmarksContextMenu::addNullActions() { - KBookmarkManager *manager = rApp->bookmarkProvider()->bookmarkManager(); - if (manager->toolbar().hasParent()) + KBookmarkManager *mngr = rApp->bookmarkManager()->manager(); + if (mngr->toolbar().hasParent()) { addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::UNSET_TOOLBAR_FOLDER)); } diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp index eb46119e..85d75402 100644 --- a/src/bookmarks/bookmarkspanel.cpp +++ b/src/bookmarks/bookmarkspanel.cpp @@ -34,7 +34,7 @@ // Local Includes #include "application.h" -#include "bookmarkprovider.h" +#include "bookmarkmanager.h" #include "bookmarkstreemodel.h" #include "bookmarkscontextmenu.h" #include "bookmarkowner.h" @@ -75,8 +75,8 @@ void BookmarksPanel::contextMenu(const QPoint &pos) return; BookmarksContextMenu menu(bookmarkForIndex(panelTreeView()->indexAt(pos)), - rApp->bookmarkProvider()->bookmarkManager(), - rApp->bookmarkProvider()->bookmarkOwner() + rApp->bookmarkManager()->manager(), + rApp->bookmarkManager()->owner() ); menu.exec(panelTreeView()->mapToGlobal(pos)); @@ -89,7 +89,7 @@ void BookmarksPanel::deleteBookmark() if (_loadingState || !index.isValid()) return; - rApp->bookmarkProvider()->bookmarkOwner()->deleteBookmark(bookmarkForIndex(index)); + rApp->bookmarkManager()->owner()->deleteBookmark(bookmarkForIndex(index)); } diff --git a/src/bookmarks/bookmarkstoolbar.cpp b/src/bookmarks/bookmarkstoolbar.cpp index 5fc76561..56793248 100644 --- a/src/bookmarks/bookmarkstoolbar.cpp +++ b/src/bookmarks/bookmarkstoolbar.cpp @@ -34,7 +34,7 @@ #include "bookmarkscontextmenu.h" #include "mainwindow.h" #include "application.h" -#include "bookmarkprovider.h" +#include "bookmarkmanager.h" #include "bookmarkowner.h" #include "webtab.h" @@ -136,7 +136,7 @@ void BookmarkMenu::addOpenFolderInTabs() if (!bookmark.isNull()) { - parentMenu()->addAction(rApp->bookmarkProvider()->bookmarkOwner()->createAction(group, BookmarkOwner::OPEN_FOLDER)); + parentMenu()->addAction(rApp->bookmarkManager()->owner()->createAction(group, BookmarkOwner::OPEN_FOLDER)); } } } @@ -164,14 +164,14 @@ BookmarkToolBar::BookmarkToolBar(KToolBar *toolBar, QObject *parent) { toolBar->setContextMenuPolicy(Qt::CustomContextMenu); connect(toolBar, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenu(const QPoint &))); - connect(rApp->bookmarkProvider()->bookmarkManager(), SIGNAL(changed(QString, QString)), this, SLOT(hideMenu())); + connect(rApp->bookmarkManager()->manager(), SIGNAL(changed(QString, QString)), this, SLOT(hideMenu())); toolBar->setAcceptDrops(true); toolBar->installEventFilter(this); toolBar->setShortcutEnabled(false); if (toolBar->isVisible()) { - rApp->bookmarkProvider()->fillBookmarkBar(this); + rApp->bookmarkManager()->fillBookmarkBar(this); m_filled = true; } } @@ -186,7 +186,7 @@ KToolBar* BookmarkToolBar::toolBar() void BookmarkToolBar::contextMenu(const QPoint &point) { KBookmarkActionInterface *action = dynamic_cast(toolBar()->actionAt(point)); - KBookmark bookmark = rApp->bookmarkProvider()->bookmarkManager()->toolbar(); + KBookmark bookmark = rApp->bookmarkManager()->manager()->toolbar(); bool nullAction = true; if (action) { @@ -195,8 +195,8 @@ void BookmarkToolBar::contextMenu(const QPoint &point) } BookmarksContextMenu menu(bookmark, - rApp->bookmarkProvider()->bookmarkManager(), - rApp->bookmarkProvider()->bookmarkOwner(), + rApp->bookmarkManager()->manager(), + rApp->bookmarkManager()->owner(), nullAction); menu.exec(toolBar()->mapToGlobal(point)); } @@ -252,7 +252,7 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) { if (!m_filled) { - rApp->bookmarkProvider()->fillBookmarkBar(this); + rApp->bookmarkManager()->fillBookmarkBar(this); m_filled = true; } } @@ -388,7 +388,7 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) { QDropEvent *dropEvent = static_cast(event); KBookmark bookmark; - KBookmarkGroup root = rApp->bookmarkProvider()->bookmarkManager()->toolbar(); + KBookmarkGroup root = rApp->bookmarkManager()->manager()->toolbar(); if (m_checkedAction) { @@ -399,7 +399,7 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) if (dropEvent->mimeData()->hasFormat("application/rekonq-bookmark")) { QByteArray addresses = dropEvent->mimeData()->data("application/rekonq-bookmark"); - bookmark = rApp->bookmarkProvider()->bookmarkManager()->findByAddress(QString::fromLatin1(addresses.data())); + bookmark = rApp->bookmarkManager()->findByAddress(QString::fromLatin1(addresses.data())); if (bookmark.isNull()) return false; } @@ -481,7 +481,7 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) } - rApp->bookmarkProvider()->bookmarkManager()->emitChanged(); + rApp->bookmarkManager()->emitChanged(); } } else @@ -493,7 +493,7 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) root.moveBookmark(bookmark, KBookmark()); } - rApp->bookmarkProvider()->bookmarkManager()->emitChanged(); + rApp->bookmarkManager()->emitChanged(); } dropEvent->accept(); } diff --git a/src/bookmarks/bookmarkstreemodel.cpp b/src/bookmarks/bookmarkstreemodel.cpp index 8e6104a4..56cab7bf 100644 --- a/src/bookmarks/bookmarkstreemodel.cpp +++ b/src/bookmarks/bookmarkstreemodel.cpp @@ -31,7 +31,7 @@ // Local Includes #include "application.h" -#include "bookmarkprovider.h" +#include "bookmarkmanager.h" #include "iconmanager.h" // KDE Includes @@ -167,7 +167,8 @@ BookmarksTreeModel::BookmarksTreeModel(QObject *parent) , m_root(0) { resetModel(); - connect(rApp->bookmarkProvider()->bookmarkManager(), SIGNAL(changed(const QString &, const QString &)), this, SLOT(bookmarksChanged(const QString &))); + connect(rApp->bookmarkManager()->manager(), SIGNAL(changed(const QString &, const QString &)), + this, SLOT(bookmarksChanged(const QString &))); } @@ -285,13 +286,13 @@ bool BookmarksTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction acti return false; QByteArray addresses = data->data("application/rekonq-bookmark"); - KBookmark bookmark = rApp->bookmarkProvider()->bookmarkManager()->findByAddress(QString::fromLatin1(addresses.data())); + KBookmark bookmark = rApp->bookmarkManager()->findByAddress(QString::fromLatin1(addresses.data())); KBookmarkGroup root; if (parent.isValid()) root = bookmarkForIndex(parent).toGroup(); else - root = rApp->bookmarkProvider()->rootGroup(); + root = rApp->bookmarkManager()->rootGroup(); QModelIndex destIndex = index(row, column, parent); @@ -305,7 +306,7 @@ bool BookmarksTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction acti root.addBookmark(bookmark); } - rApp->bookmarkProvider()->bookmarkManager()->emitChanged(); + rApp->bookmarkManager()->emitChanged(); return true; } @@ -356,7 +357,7 @@ void BookmarksTreeModel::bookmarksChanged(const QString &groupAddress) node = node->child(i); nodeIndex = index(i, 0, nodeIndex); } - populate(node, rApp->bookmarkProvider()->bookmarkManager()->findByAddress(groupAddress).toGroup()); + populate(node, rApp->bookmarkManager()->findByAddress(groupAddress).toGroup()); endResetModel(); } @@ -366,7 +367,7 @@ void BookmarksTreeModel::bookmarksChanged(const QString &groupAddress) void BookmarksTreeModel::resetModel() { - setRoot(rApp->bookmarkProvider()->rootGroup()); + setRoot(rApp->bookmarkManager()->rootGroup()); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c46fbc68..b1556ed5 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -38,7 +38,7 @@ #include "adblockmanager.h" #include "analyzerpanel.h" #include "application.h" -#include "bookmarkprovider.h" +#include "bookmarkmanager.h" #include "bookmarkspanel.h" #include "bookmarkstoolbar.h" #include "downloadmanager.h" @@ -226,8 +226,8 @@ MainWindow::~MainWindow() { m_hidePopupTimer->stop(); - rApp->bookmarkProvider()->removeBookmarkBar(m_bookmarksBar); - rApp->bookmarkProvider()->removeBookmarkPanel(m_bookmarksPanel); + rApp->bookmarkManager()->removeBookmarkBar(m_bookmarksBar); + rApp->bookmarkManager()->removeBookmarkPanel(m_bookmarksPanel); rApp->removeMainWindow(this); } @@ -255,7 +255,7 @@ void MainWindow::initBookmarkBar() if (m_bookmarksBar) { - rApp->bookmarkProvider()->removeBookmarkBar(m_bookmarksBar); + rApp->bookmarkManager()->removeBookmarkBar(m_bookmarksBar); delete m_bookmarksBar; } m_bookmarksBar = new BookmarkToolBar(XMLGUIBkBar, this); @@ -495,7 +495,7 @@ void MainWindow::setupActions() connect(a, SIGNAL(triggered(bool)), m_view->tabBar(), SLOT(detachTab())); // Bookmark Menu - KActionMenu *bmMenu = rApp->bookmarkProvider()->bookmarkActionMenu(this); + KActionMenu *bmMenu = rApp->bookmarkManager()->bookmarkActionMenu(this); bmMenu->setIcon(KIcon("bookmarks")); bmMenu->setDelayed(false); bmMenu->setShortcutConfigurable(true); @@ -582,7 +582,7 @@ void MainWindow::setupPanels() addDockWidget(Qt::LeftDockWidgetArea, m_bookmarksPanel); - rApp->bookmarkProvider()->registerBookmarkPanel(m_bookmarksPanel); + rApp->bookmarkManager()->registerBookmarkPanel(m_bookmarksPanel); // setup bookmarks panel action a = (KAction *) m_bookmarksPanel->toggleViewAction(); diff --git a/src/newtabpage.cpp b/src/newtabpage.cpp index 4929c9be..52b83bbd 100644 --- a/src/newtabpage.cpp +++ b/src/newtabpage.cpp @@ -34,7 +34,7 @@ // Local Includes #include "application.h" -#include "bookmarkprovider.h" +#include "bookmarkmanager.h" #include "downloadmanager.h" #include "historymodels.h" #include "mainview.h" @@ -124,7 +124,7 @@ void NewTabPage::generate(const KUrl &url) } if (url == KUrl("about:bookmarks/edit")) { - rApp->bookmarkProvider()->bookmarkManager()->slotEditBookmarks(); + rApp->bookmarkManager()->slotEditBookmarks(); return; } @@ -464,7 +464,7 @@ void NewTabPage::bookmarksPage() KIconLoader::Toolbar); m_root.document().findFirst(QL1S("#actions")).appendInside(editBookmarks); - KBookmarkGroup bookGroup = rApp->bookmarkProvider()->rootGroup(); + KBookmarkGroup bookGroup = rApp->bookmarkManager()->rootGroup(); if (bookGroup.isNull()) { m_root.addClass(QL1S("empty")); diff --git a/src/sync/syncmanager.cpp b/src/sync/syncmanager.cpp index f4a2fdf4..fe4ffc43 100644 --- a/src/sync/syncmanager.cpp +++ b/src/sync/syncmanager.cpp @@ -33,7 +33,7 @@ // Local Includes #include "application.h" -#include "bookmarkprovider.h" +#include "bookmarkmanager.h" #include "historymanager.h" #include "syncwidget.h" @@ -68,8 +68,8 @@ void SyncManager::loadSettings() // bookmarks ReKonfig::syncBookmarks() - ? connect(rApp->bookmarkProvider(), SIGNAL(changed()), this, SLOT(syncBookmarks())) - : disconnect(rApp->bookmarkProvider(), SIGNAL(changed()), this, SLOT(syncBookmarks())) + ? connect(rApp->bookmarkManager(), SIGNAL(changed()), this, SLOT(syncBookmarks())) + : disconnect(rApp->bookmarkManager(), SIGNAL(changed()), this, SLOT(syncBookmarks())) ; // history @@ -81,7 +81,7 @@ void SyncManager::loadSettings() else { // bookmarks - disconnect(rApp->bookmarkProvider(), SIGNAL(changed()), this, SLOT(syncBookmarks())); + disconnect(rApp->bookmarkManager(), SIGNAL(changed()), this, SLOT(syncBookmarks())); // history disconnect(rApp->historyManager(), SIGNAL(historySaved()), this, SLOT(syncHistory())); diff --git a/src/urlbar/bookmarkwidget.cpp b/src/urlbar/bookmarkwidget.cpp index 5beecb4c..c144b8d0 100644 --- a/src/urlbar/bookmarkwidget.cpp +++ b/src/urlbar/bookmarkwidget.cpp @@ -30,7 +30,7 @@ // Local includes #include "application.h" -#include "bookmarkprovider.h" +#include "bookmarkmanager.h" #include "bookmarkowner.h" // KDE Includes @@ -119,7 +119,7 @@ void BookmarkWidget::accept() if (!m_bookmark->isNull() && m_name->text() != m_bookmark->fullText()) { m_bookmark->setFullText(m_name->text()); - rApp->bookmarkProvider()->bookmarkManager()->emitChanged(); + rApp->bookmarkManager()->emitChanged(); } close(); } @@ -127,7 +127,7 @@ void BookmarkWidget::accept() void BookmarkWidget::removeBookmark() { - rApp->bookmarkProvider()->bookmarkOwner()->deleteBookmark(*m_bookmark); + rApp->bookmarkManager()->owner()->deleteBookmark(*m_bookmark); close(); emit updateIcon(); diff --git a/src/urlbar/favoritewidget.cpp b/src/urlbar/favoritewidget.cpp index da94410d..f72deace 100644 --- a/src/urlbar/favoritewidget.cpp +++ b/src/urlbar/favoritewidget.cpp @@ -33,7 +33,7 @@ // Local includes #include "application.h" -#include "bookmarkprovider.h" +#include "bookmarkmanager.h" #include "bookmarkowner.h" // KDE Includes diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp index 9460cf8a..e95c5c33 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -41,7 +41,7 @@ #include "webpage.h" #include "webview.h" #include "completionwidget.h" -#include "bookmarkprovider.h" +#include "bookmarkmanager.h" #include "bookmarkowner.h" #include "bookmarkwidget.h" #include "iconmanager.h" @@ -397,11 +397,11 @@ void UrlBar::showBookmarkInfo(QPoint pos) if (_tab->url().scheme() == QL1S("about")) return; - KBookmark bookmark = rApp->bookmarkProvider()->bookmarkForUrl(_tab->url()); + KBookmark bookmark = rApp->bookmarkManager()->bookmarkForUrl(_tab->url()); if (bookmark.isNull()) { - bookmark = rApp->bookmarkProvider()->bookmarkOwner()->bookmarkCurrentPage(); + bookmark = rApp->bookmarkManager()->owner()->bookmarkCurrentPage(); updateRightIcons(); } else @@ -549,7 +549,7 @@ IconButton *UrlBar::addRightIcon(UrlBar::icon ic) rightIcon->setToolTip(i18n("Show SSL Info")); break; case UrlBar::BK: - if (rApp->bookmarkProvider()->bookmarkForUrl(_tab->url()).isNull()) + if (rApp->bookmarkManager()->bookmarkForUrl(_tab->url()).isNull()) { rightIcon->setIcon(KIcon("bookmarks").pixmap(32, 32, QIcon::Disabled)); rightIcon->setToolTip(i18n("Bookmark this page")); @@ -678,7 +678,7 @@ void UrlBar::bookmarkContextMenu(QPoint pos) KMenu menu(this); QAction *qa; - if (!rApp->bookmarkProvider()->bookmarkForUrl(_tab->url()).isNull()) + if (!rApp->bookmarkManager()->bookmarkForUrl(_tab->url()).isNull()) { qa = new KAction(KIcon("bookmarks"), i18n("Edit Bookmark"), this); connect(qa, SIGNAL(triggered(bool)), this, SLOT(showBookmarkDialog())); diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp index 073cc728..425f233f 100644 --- a/src/urlbar/urlresolver.cpp +++ b/src/urlbar/urlresolver.cpp @@ -30,7 +30,7 @@ // Local Includes #include "historymanager.h" -#include "bookmarkprovider.h" +#include "bookmarkmanager.h" #include "searchengine.h" // KDE Includes @@ -352,7 +352,7 @@ void UrlResolver::computeHistory() // bookmarks void UrlResolver::computeBookmarks() { - QList found = rApp->bookmarkProvider()->find(_typedString); + QList found = rApp->bookmarkManager()->find(_typedString); Q_FOREACH(const KBookmark & b, found) { UrlSearchItem gItem(UrlSearchItem::Bookmark, b.url().url(), b.fullText()); diff --git a/src/webview.cpp b/src/webview.cpp index e524ae24..012f77eb 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -34,8 +34,7 @@ // Local Includes #include "application.h" -#include "bookmarkprovider.h" -#include "bookmarkowner.h" +#include "bookmarkmanager.h" #include "iconmanager.h" #include "mainview.h" #include "mainwindow.h" @@ -117,6 +116,7 @@ WebView::~WebView() preview.save(path); } + void WebView::changeWindowIcon() { if (ReKonfig::useFavicon()) @@ -130,6 +130,7 @@ void WebView::changeWindowIcon() } } + WebPage *WebView::page() { WebPage *const page = qobject_cast(KWebView::page()); @@ -483,10 +484,10 @@ void WebView::dropEvent(QDropEvent *event) if (event->mimeData()->hasFormat("application/rekonq-bookmark")) { QByteArray addresses = event->mimeData()->data("application/rekonq-bookmark"); - KBookmark bookmark = rApp->bookmarkProvider()->bookmarkManager()->findByAddress(QString::fromLatin1(addresses.data())); + KBookmark bookmark = rApp->bookmarkManager()->findByAddress(QString::fromLatin1(addresses.data())); if (bookmark.isGroup()) { - rApp->bookmarkProvider()->bookmarkOwner()->openFolderinTabs(bookmark.toGroup()); + rApp->bookmarkManager()->openFolderinTabs(bookmark.toGroup()); } else { @@ -603,8 +604,8 @@ void WebView::bookmarkLink() KAction *a = qobject_cast(sender()); KUrl url(a->data().toUrl()); - rApp->bookmarkProvider()->rootGroup().addBookmark(url.prettyUrl(), url); - rApp->bookmarkProvider()->bookmarkManager()->emitChanged(); + rApp->bookmarkManager()->rootGroup().addBookmark(url.prettyUrl(), url); + rApp->bookmarkManager()->emitChanged(); } -- cgit v1.2.1