From 89772b99957eff256f87d822b7741bb3e8f62276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Ander=20Pe=C3=B1alba?= Date: Fri, 20 Aug 2010 22:29:56 +0200 Subject: Minor changes in BookmarkProvider. Searching for bookmarks should be a bit faster --- src/bookmarks/bookmarkprovider.cpp | 45 ++++++++++++-------------------------- src/bookmarks/bookmarkprovider.h | 6 ++--- 2 files changed, 17 insertions(+), 34 deletions(-) (limited to 'src/bookmarks') diff --git a/src/bookmarks/bookmarkprovider.cpp b/src/bookmarks/bookmarkprovider.cpp index 0cd0d3eb..ac08e76e 100644 --- a/src/bookmarks/bookmarkprovider.cpp +++ b/src/bookmarks/bookmarkprovider.cpp @@ -69,7 +69,8 @@ BookmarkProvider::BookmarkProvider(QObject *parent) // 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 &))); + connect(m_owner, SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType&)), + this, SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType&))); KAction *a = KStandardAction::addBookmark(this, SLOT(slotAddBookmark()), this); m_actionCollection->addAction(QL1S("rekonq_add_bookmark"), a); @@ -93,7 +94,7 @@ void BookmarkProvider::registerBookmarkBar(BookmarkToolBar *toolbar) m_bookmarkToolBars.append(toolbar); toolbar->toolBar()->setContextMenuPolicy(Qt::CustomContextMenu); - connect(toolbar->toolBar(), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenu(const QPoint &))); + connect(toolbar->toolBar(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(contextMenu(const QPoint&))); kDebug() << "new bookmark bar... DONE!"; } @@ -105,7 +106,7 @@ void BookmarkProvider::removeToolBar(BookmarkToolBar *toolbar) } -void BookmarkProvider::slotBookmarksChanged(const QString& /*group*/, const QString& /*caller*/) +void BookmarkProvider::slotBookmarksChanged(const QString& /*groupAddress*/, const QString& /*caller*/) { foreach(BookmarkToolBar *bookmarkToolBar, m_bookmarkToolBars) { @@ -123,7 +124,7 @@ QAction* BookmarkProvider::actionByName(const QString &name) QAction *action = m_actionCollection->action(name); if (action) return action; - return new QAction(this); // return empty object instead of NULL pointer + return new QAction(this); } @@ -205,41 +206,28 @@ KBookmarkGroup BookmarkProvider::rootGroup() QList BookmarkProvider::find(const QString &text) { QList list; - KBookmarkGroup bookGroup = Application::bookmarkProvider()->rootGroup(); - if (bookGroup.isNull()) - { - return list; - } - KBookmark bookmark = bookGroup.first(); - while (!bookmark.isNull()) - { - list = find(list, bookmark, text); - bookmark = bookGroup.next(bookmark); - } + 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; } -QList BookmarkProvider::find(QList list, const KBookmark &bookmark, const QString &text) +void BookmarkProvider::find(QList *list, const KBookmark &bookmark, const QString &text) { if (bookmark.isGroup()) { KBookmarkGroup group = bookmark.toGroup(); - KBookmark bm = group.first(); - while (!bm.isNull()) - { - list = find(list, bm, text); - bm = group.next(bm); - } + for (KBookmark bm = group.first(); !bm.isNull(); bm = group.next(bm)) + find(list, bm, text); } else if (bookmark.url().url().contains(text) || bookmark.fullText().contains(text)) { - list << bookmark; + *list << bookmark; } - - return list; } @@ -269,9 +257,7 @@ void BookmarkProvider::removeBookmarkPanel(BookmarksPanel *panel) panel->disconnect(this); if (m_bookmarkPanels.isEmpty()) - { Application::bookmarkProvider()->bookmarkManager()->emitChanged(); - } } @@ -289,10 +275,7 @@ KBookmark BookmarkProvider::bookmarkForUrl(const KUrl &url) { KBookmarkGroup root = rootGroup(); if (root.isNull()) - { - KBookmark found; - return found; - } + return KBookmark(); return bookmarkForUrl(root, url); } diff --git a/src/bookmarks/bookmarkprovider.h b/src/bookmarks/bookmarkprovider.h index 61b5d12d..6036011e 100644 --- a/src/bookmarks/bookmarkprovider.h +++ b/src/bookmarks/bookmarkprovider.h @@ -132,11 +132,11 @@ public 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 group bookmark group address + * @param groupAddress bookmark group address * @param caller caller that modified the bookmarks * @see KBookmarkManager::changed */ - void slotBookmarksChanged(const QString &group, const QString &caller); + void slotBookmarksChanged(const QString &groupAddress, const QString &caller); void fillBookmarkBar(BookmarkToolBar *toolBar); private slots: @@ -144,7 +144,7 @@ private slots: void slotPanelChanged(); private: - QList find(QList list, const KBookmark &bookmark, const QString &text); + void find(QList *list, const KBookmark &bookmark, const QString &text); QString titleForBookmarkUrl(const KBookmark &bookmark, const QString &url); KBookmark bookmarkForUrl(const KBookmark &bookmark, const KUrl &url); -- cgit v1.2.1