diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2011-11-14 18:49:04 +0100 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2011-12-12 16:40:28 +0100 |
commit | b111a11cb46bfd572c2fed9c67d648bcff10a3ce (patch) | |
tree | a5a12a0ac980f6af2fe245d8cdd8575dd8e95601 /src/bookmarks | |
parent | let history, bookmarks and passwords sync on change (first bits) (diff) | |
download | rekonq-b111a11cb46bfd572c2fed9c67d648bcff10a3ce.tar.xz |
BookmarkProvider --> BookmarkManager
We have 7 managers and 1 provider... finally fixing this strange
thing!
Diffstat (limited to 'src/bookmarks')
-rw-r--r-- | src/bookmarks/bookmarkmanager.cpp (renamed from src/bookmarks/bookmarkprovider.cpp) | 76 | ||||
-rw-r--r-- | src/bookmarks/bookmarkmanager.h (renamed from src/bookmarks/bookmarkprovider.h) | 27 | ||||
-rw-r--r-- | src/bookmarks/bookmarkowner.cpp | 6 | ||||
-rw-r--r-- | src/bookmarks/bookmarkscontextmenu.cpp | 13 | ||||
-rw-r--r-- | src/bookmarks/bookmarkspanel.cpp | 8 | ||||
-rw-r--r-- | src/bookmarks/bookmarkstoolbar.cpp | 24 | ||||
-rw-r--r-- | src/bookmarks/bookmarkstreemodel.cpp | 15 |
7 files changed, 104 insertions, 65 deletions
diff --git a/src/bookmarks/bookmarkprovider.cpp b/src/bookmarks/bookmarkmanager.cpp index 262941d8..49c697a5 100644 --- a/src/bookmarks/bookmarkprovider.cpp +++ b/src/bookmarks/bookmarkmanager.cpp @@ -28,8 +28,8 @@ // Self Includes -#include "bookmarkprovider.h" -#include "bookmarkprovider.moc" +#include "bookmarkmanager.h" +#include "bookmarkmanager.moc" // Local Includes #include "application.h" @@ -48,7 +48,7 @@ #include <QtCore/QFile> -BookmarkProvider::BookmarkProvider(QObject *parent) +BookmarkManager::BookmarkManager(QObject *parent) : QObject(parent) , m_manager(0) , m_owner(0) @@ -70,25 +70,24 @@ BookmarkProvider::BookmarkProvider(QObject *parent) } 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); + KAction *a = KStandardAction::addBookmark(m_owner, SLOT(bookmarkCurrentPage()), this); m_actionCollection->addAction(QL1S("rekonq_add_bookmark"), a); } -BookmarkProvider::~BookmarkProvider() +BookmarkManager::~BookmarkManager() { delete m_manager; } -KActionMenu* BookmarkProvider::bookmarkActionMenu(QWidget *parent) +KActionMenu* BookmarkManager::bookmarkActionMenu(QWidget *parent) { KMenu *menu = new KMenu(parent); KActionMenu *bookmarkActionMenu = new KActionMenu(menu); @@ -101,7 +100,7 @@ KActionMenu* BookmarkProvider::bookmarkActionMenu(QWidget *parent) } -void BookmarkProvider::registerBookmarkBar(BookmarkToolBar *toolbar) +void BookmarkManager::registerBookmarkBar(BookmarkToolBar *toolbar) { if (m_bookmarkToolBars.contains(toolbar)) return; @@ -110,13 +109,13 @@ void BookmarkProvider::registerBookmarkBar(BookmarkToolBar *toolbar) } -void BookmarkProvider::removeBookmarkBar(BookmarkToolBar *toolbar) +void BookmarkManager::removeBookmarkBar(BookmarkToolBar *toolbar) { m_bookmarkToolBars.removeOne(toolbar); } -void BookmarkProvider::registerBookmarkPanel(BookmarksPanel *panel) +void BookmarkManager::registerBookmarkPanel(BookmarksPanel *panel) { if (panel && !m_bookmarkPanels.contains(panel)) { @@ -126,7 +125,7 @@ void BookmarkProvider::registerBookmarkPanel(BookmarksPanel *panel) } -void BookmarkProvider::removeBookmarkPanel(BookmarksPanel *panel) +void BookmarkManager::removeBookmarkPanel(BookmarksPanel *panel) { if (!panel) return; @@ -135,11 +134,11 @@ void BookmarkProvider::removeBookmarkPanel(BookmarksPanel *panel) panel->disconnect(this); if (m_bookmarkPanels.isEmpty()) - rApp->bookmarkProvider()->bookmarkManager()->emitChanged(); + emitChanged(); } -QAction* BookmarkProvider::actionByName(const QString &name) +QAction* BookmarkManager::actionByName(const QString &name) { QAction *action = m_actionCollection->action(name); if (action) @@ -148,17 +147,17 @@ QAction* BookmarkProvider::actionByName(const QString &name) } -KBookmarkGroup BookmarkProvider::rootGroup() +KBookmarkGroup BookmarkManager::rootGroup() { return m_manager->root(); } -QList<KBookmark> BookmarkProvider::find(const QString &text) +QList<KBookmark> BookmarkManager::find(const QString &text) { QList<KBookmark> list; - KBookmarkGroup root = rApp->bookmarkProvider()->rootGroup(); + KBookmarkGroup root = rootGroup(); if (!root.isNull()) for (KBookmark bookmark = root.first(); !bookmark.isNull(); bookmark = root.next(bookmark)) find(&list, bookmark, text); @@ -167,7 +166,7 @@ QList<KBookmark> BookmarkProvider::find(const QString &text) } -KBookmark BookmarkProvider::bookmarkForUrl(const KUrl &url) +KBookmark BookmarkManager::bookmarkForUrl(const KUrl &url) { KBookmarkGroup root = rootGroup(); if (root.isNull()) @@ -177,7 +176,7 @@ KBookmark BookmarkProvider::bookmarkForUrl(const KUrl &url) } -void BookmarkProvider::slotBookmarksChanged() +void BookmarkManager::slotBookmarksChanged() { Q_FOREACH(BookmarkToolBar * bookmarkToolBar, m_bookmarkToolBars) { @@ -195,7 +194,7 @@ void BookmarkProvider::slotBookmarksChanged() } -void BookmarkProvider::fillBookmarkBar(BookmarkToolBar *toolBar) +void BookmarkManager::fillBookmarkBar(BookmarkToolBar *toolBar) { KBookmarkGroup root = m_manager->toolbar(); if (root.isNull()) @@ -207,7 +206,7 @@ void BookmarkProvider::fillBookmarkBar(BookmarkToolBar *toolBar) { KBookmarkActionMenu *menuAction = new KBookmarkActionMenu(bookmark.toGroup(), this); menuAction->setDelayed(false); - BookmarkMenu *bMenu = new BookmarkMenu(bookmarkManager(), bookmarkOwner(), menuAction->menu(), bookmark.address()); + BookmarkMenu *bMenu = new BookmarkMenu(m_manager, m_owner, menuAction->menu(), bookmark.address()); bMenu->setParent(menuAction->menu()); connect(menuAction->menu(), SIGNAL(aboutToShow()), toolBar, SLOT(menuDisplayed())); @@ -232,19 +231,22 @@ void BookmarkProvider::fillBookmarkBar(BookmarkToolBar *toolBar) } -void BookmarkProvider::slotPanelChanged() +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")) + 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<KBookmark> *list, const KBookmark &bookmark, const QString &text) +void BookmarkManager::find(QList<KBookmark> *list, const KBookmark &bookmark, const QString &text) { if (bookmark.isGroup()) { @@ -271,7 +273,7 @@ void BookmarkProvider::find(QList<KBookmark> *list, const KBookmark &bookmark, c } -KBookmark BookmarkProvider::bookmarkForUrl(const KBookmark &bookmark, const KUrl &url) +KBookmark BookmarkManager::bookmarkForUrl(const KBookmark &bookmark, const KUrl &url) { KBookmark found; @@ -295,7 +297,7 @@ KBookmark BookmarkProvider::bookmarkForUrl(const KBookmark &bookmark, const KUrl } -void BookmarkProvider::copyBookmarkGroup(const KBookmarkGroup &groupToCopy, KBookmarkGroup destGroup) +void BookmarkManager::copyBookmarkGroup(const KBookmarkGroup &groupToCopy, KBookmarkGroup destGroup) { KBookmark bookmark = groupToCopy.first(); while (!bookmark.isNull()) @@ -321,3 +323,27 @@ void BookmarkProvider::copyBookmarkGroup(const KBookmarkGroup &groupToCopy, KBoo 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/bookmarkprovider.h b/src/bookmarks/bookmarkmanager.h index db7efe45..b00a4b0e 100644 --- a/src/bookmarks/bookmarkprovider.h +++ b/src/bookmarks/bookmarkmanager.h @@ -27,13 +27,16 @@ * ============================================================ */ -#ifndef BOOKMARKPROVIDER_H -#define BOOKMARKPROVIDER_H +#ifndef BOOKMARK_MANAGER_H +#define BOOKMARK_MANAGER_H // Rekonq Includes #include "rekonq_defines.h" +// KDE Includes +#include <KBookmark> + // Qt Includes #include <QObject> @@ -46,7 +49,6 @@ class BookmarkMenu; class KAction; class KActionCollection; class KActionMenu; -class KBookmark; class KBookmarkGroup; class KBookmarkManager; class KUrl; @@ -60,7 +62,7 @@ class QAction; * from this class. * So it implements code to have each one. */ -class BookmarkProvider : public QObject +class BookmarkManager : public QObject { Q_OBJECT @@ -71,8 +73,8 @@ public: * (actually konqueror's bookmarks). * @param parent The MainWindow to provide bookmarks objects. */ - BookmarkProvider(QObject *parent = 0); - ~BookmarkProvider(); + BookmarkManager(QObject *parent = 0); + ~BookmarkManager(); /** * @short Get the Bookmarks Menu Action @@ -106,12 +108,12 @@ public: */ KBookmarkGroup rootGroup(); - inline KBookmarkManager* bookmarkManager() + inline KBookmarkManager* manager() { return m_manager; } - inline BookmarkOwner* bookmarkOwner() + inline BookmarkOwner* owner() { return m_owner; } @@ -120,6 +122,10 @@ public: 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. @@ -132,6 +138,8 @@ public Q_SLOTS: void slotBookmarksChanged(); void fillBookmarkBar(BookmarkToolBar *toolBar); + void slotEditBookmarks(); + private Q_SLOTS: void slotPanelChanged(); @@ -140,7 +148,6 @@ 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<KBookmark> *list, const KBookmark &bookmark, const QString &text); @@ -155,4 +162,4 @@ private: }; -#endif // BOOKMARKPROVIDER_H +#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/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 <KBookmarkManager> -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<KBookmarkActionInterface*>(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<QDropEvent*>(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()); } |