summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJon Ander Peñalba <jonan88@gmail.com>2010-08-20 22:36:11 +0200
committerJon Ander Peñalba <jonan88@gmail.com>2010-08-20 22:36:11 +0200
commitd564d3b50c83f55ebc66fd9019891251ac072bd9 (patch)
treeb9b503ab044d0d2559668984f89224c6c1afe1bc /src
parentMinor changes in BookmarkProvider. Searching for bookmarks should be a bit fa... (diff)
downloadrekonq-d564d3b50c83f55ebc66fd9019891251ac072bd9.tar.xz
BookmarkProvider's code reordered
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/bookmarkprovider.cpp162
-rw-r--r--src/bookmarks/bookmarkprovider.h9
-rw-r--r--src/mainwindow.cpp4
3 files changed, 87 insertions, 88 deletions
diff --git a/src/bookmarks/bookmarkprovider.cpp b/src/bookmarks/bookmarkprovider.cpp
index ac08e76e..41704f58 100644
--- a/src/bookmarks/bookmarkprovider.cpp
+++ b/src/bookmarks/bookmarkprovider.cpp
@@ -85,6 +85,22 @@ BookmarkProvider::~BookmarkProvider()
}
+KActionMenu* BookmarkProvider::bookmarkActionMenu(QWidget *parent)
+{
+ kDebug() << "new Bookmarks menu...";
+
+ KMenu *menu = new KMenu(parent);
+ KActionMenu *bookmarkActionMenu = new KActionMenu(menu);
+ bookmarkActionMenu->setMenu(menu);
+ bookmarkActionMenu->setText(i18n("&Bookmarks"));
+ new BookmarkMenu(m_manager, m_owner, menu, m_actionCollection);
+
+ kDebug() << "new Bookmarks menu... DONE";
+
+ return bookmarkActionMenu;
+}
+
+
void BookmarkProvider::registerBookmarkBar(BookmarkToolBar *toolbar)
{
if (m_bookmarkToolBars.contains(toolbar))
@@ -100,25 +116,35 @@ void BookmarkProvider::registerBookmarkBar(BookmarkToolBar *toolbar)
}
-void BookmarkProvider::removeToolBar(BookmarkToolBar *toolbar)
+void BookmarkProvider::removeBookmarkBar(BookmarkToolBar *toolbar)
{
m_bookmarkToolBars.removeOne(toolbar);
}
-void BookmarkProvider::slotBookmarksChanged(const QString& /*groupAddress*/, const QString& /*caller*/)
+void BookmarkProvider::registerBookmarkPanel(BookmarksPanel *panel)
{
- foreach(BookmarkToolBar *bookmarkToolBar, m_bookmarkToolBars)
+ if (panel && !m_bookmarkPanels.contains(panel))
{
- if (bookmarkToolBar)
- {
- bookmarkToolBar->toolBar()->clear();
- fillBookmarkBar(bookmarkToolBar);
- }
+ 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())
+ Application::bookmarkProvider()->bookmarkManager()->emitChanged();
+}
+
+
QAction* BookmarkProvider::actionByName(const QString &name)
{
QAction *action = m_actionCollection->action(name);
@@ -128,6 +154,35 @@ QAction* BookmarkProvider::actionByName(const QString &name)
}
+KBookmarkGroup BookmarkProvider::rootGroup()
+{
+ return m_manager->root();
+}
+
+
+QList<KBookmark> BookmarkProvider::find(const QString &text)
+{
+ QList<KBookmark> list;
+
+ KBookmarkGroup root = Application::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::contextMenu(const QPoint &point)
{
if (m_bookmarkToolBars.isEmpty())
@@ -146,19 +201,16 @@ void BookmarkProvider::contextMenu(const QPoint &point)
}
-KActionMenu* BookmarkProvider::bookmarkActionMenu(QWidget *parent)
+void BookmarkProvider::slotBookmarksChanged(const QString& /*groupAddress*/, const QString& /*caller*/)
{
- kDebug() << "new Bookmarks menu...";
-
- KMenu *menu = new KMenu(parent);
- KActionMenu *bookmarkActionMenu = new KActionMenu(menu);
- bookmarkActionMenu->setMenu(menu);
- bookmarkActionMenu->setText(i18n("&Bookmarks"));
- new BookmarkMenu(m_manager, m_owner, menu, m_actionCollection);
-
- kDebug() << "new Bookmarks menu... DONE";
-
- return bookmarkActionMenu;
+ foreach(BookmarkToolBar *bookmarkToolBar, m_bookmarkToolBars)
+ {
+ if (bookmarkToolBar)
+ {
+ bookmarkToolBar->toolBar()->clear();
+ fillBookmarkBar(bookmarkToolBar);
+ }
+ }
}
@@ -197,22 +249,20 @@ void BookmarkProvider::fillBookmarkBar(BookmarkToolBar *toolBar)
}
-KBookmarkGroup BookmarkProvider::rootGroup()
+void BookmarkProvider::slotAddBookmark()
{
- return m_manager->root();
+ rootGroup().addBookmark(bookmarkOwner()->currentTitle(), bookmarkOwner()->currentUrl());
+ bookmarkManager()->emitChanged();
}
-QList<KBookmark> BookmarkProvider::find(const QString &text)
+void BookmarkProvider::slotPanelChanged()
{
- QList<KBookmark> list;
-
- KBookmarkGroup root = Application::bookmarkProvider()->rootGroup();
- if (!root.isNull())
- for (KBookmark bookmark = root.first(); !bookmark.isNull(); bookmark = root.next(bookmark))
- find(&list, bookmark, text);
-
- return list;
+ foreach (BookmarksPanel *panel, m_bookmarkPanels)
+ {
+ if (panel && panel != sender())
+ panel->startLoadFoldedState();
+ }
}
@@ -231,56 +281,6 @@ void BookmarkProvider::find(QList<KBookmark> *list, const KBookmark &bookmark, c
}
-void BookmarkProvider::slotAddBookmark()
-{
- rootGroup().addBookmark(bookmarkOwner()->currentTitle(), bookmarkOwner()->currentUrl());
- bookmarkManager()->emitChanged();
-}
-
-
-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())
- Application::bookmarkProvider()->bookmarkManager()->emitChanged();
-}
-
-
-void BookmarkProvider::slotPanelChanged()
-{
- foreach (BookmarksPanel *panel, m_bookmarkPanels)
- {
- if (panel && panel != sender())
- panel->startLoadFoldedState();
- }
-}
-
-
-KBookmark BookmarkProvider::bookmarkForUrl(const KUrl &url)
-{
- KBookmarkGroup root = rootGroup();
- if (root.isNull())
- return KBookmark();
-
- return bookmarkForUrl(root, url);
-}
-
-
KBookmark BookmarkProvider::bookmarkForUrl(const KBookmark &bookmark, const KUrl &url)
{
KBookmark found;
diff --git a/src/bookmarks/bookmarkprovider.h b/src/bookmarks/bookmarkprovider.h
index 6036011e..e21bd227 100644
--- a/src/bookmarks/bookmarkprovider.h
+++ b/src/bookmarks/bookmarkprovider.h
@@ -85,7 +85,10 @@ public:
* @short set the Bookmarks Toolbar Action
*/
void registerBookmarkBar(BookmarkToolBar *toolbar);
- void removeToolBar(BookmarkToolBar *toolbar);
+ void removeBookmarkBar(BookmarkToolBar *toolbar);
+
+ void registerBookmarkPanel(BookmarksPanel *panel);
+ void removeBookmarkPanel(BookmarksPanel *panel);
/**
* @short Get action by name
@@ -109,9 +112,6 @@ public:
QList<KBookmark> find(const QString &text);
- void registerBookmarkPanel(BookmarksPanel *panel);
- void removeBookmarkPanel(BookmarksPanel *panel);
-
KBookmark bookmarkForUrl(const KUrl &url);
signals:
@@ -146,7 +146,6 @@ private slots:
private:
void find(QList<KBookmark> *list, const KBookmark &bookmark, const QString &text);
- QString titleForBookmarkUrl(const KBookmark &bookmark, const QString &url);
KBookmark bookmarkForUrl(const KBookmark &bookmark, const KUrl &url);
KBookmarkManager *m_manager;
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 262714e1..4927ce4e 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -163,7 +163,7 @@ MainWindow::MainWindow()
MainWindow::~MainWindow()
{
- Application::bookmarkProvider()->removeToolBar(m_bookmarksBar);
+ Application::bookmarkProvider()->removeBookmarkBar(m_bookmarksBar);
Application::bookmarkProvider()->removeBookmarkPanel(m_bookmarksPanel);
Application::instance()->removeMainWindow(this);
@@ -211,7 +211,7 @@ void MainWindow::initBookmarkBar()
if (m_bookmarksBar)
{
- Application::bookmarkProvider()->removeToolBar(m_bookmarksBar);
+ Application::bookmarkProvider()->removeBookmarkBar(m_bookmarksBar);
delete m_bookmarksBar;
}
m_bookmarksBar = new BookmarkToolBar(XMLGUIBkBar, this);