summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormegabigbug <megabigbug@arrakis.(none)>2010-07-21 17:13:17 +0200
committermegabigbug <megabigbug@arrakis.(none)>2010-07-21 17:13:17 +0200
commit29222348be2aea93de9d9fc937996d0b7474308d (patch)
treece2f602c81bee4f4b737ee71468368ca6114de3e
parentremove useless bookmarkPath attribute of UrlSearchItem (diff)
downloadrekonq-29222348be2aea93de9d9fc937996d0b7474308d.tar.xz
reintroduce bookmark suggestions
-rw-r--r--src/bookmarks/bookmarksmanager.cpp27
-rw-r--r--src/bookmarks/bookmarksmanager.h4
-rw-r--r--src/urlbar/urlresolver.cpp9
-rw-r--r--src/urlbar/urlresolver.h2
4 files changed, 23 insertions, 19 deletions
diff --git a/src/bookmarks/bookmarksmanager.cpp b/src/bookmarks/bookmarksmanager.cpp
index b5c90616..d0062ae1 100644
--- a/src/bookmarks/bookmarksmanager.cpp
+++ b/src/bookmarks/bookmarksmanager.cpp
@@ -418,45 +418,44 @@ KBookmarkGroup BookmarkProvider::rootGroup()
}
-QString BookmarkProvider::titleForBookmarkUrl(QString url)
+QList<KBookmark> BookmarkProvider::find(QString text)
{
- QString title = "";
+ QList<KBookmark> list;
KBookmarkGroup bookGroup = Application::bookmarkProvider()->rootGroup();
if (bookGroup.isNull())
{
- return title;
+ return list;
}
- KBookmark bookmark = bookGroup.first();
- while (!bookmark.isNull() && title.isEmpty())
+ KBookmark bookmark = bookGroup.first();
+ while (!bookmark.isNull())
{
- title = titleForBookmarkUrl(bookmark, url);
+ list = find(list, bookmark, text);
bookmark = bookGroup.next(bookmark);
}
- return title;
+ return list;
}
-QString BookmarkProvider::titleForBookmarkUrl(const KBookmark &bookmark, QString url)
+QList<KBookmark> BookmarkProvider::find(QList<KBookmark> list, const KBookmark &bookmark, QString text)
{
- QString title = "";
if (bookmark.isGroup())
{
KBookmarkGroup group = bookmark.toGroup();
KBookmark bm = group.first();
- while (!bm.isNull() && title.isEmpty())
+ while (!bm.isNull())
{
- title = titleForBookmarkUrl(bm, url); // it is .bookfolder
+ list = find(list, bm, text); // it is .bookfolder
bm = group.next(bm);
}
}
- else if (!bookmark.isSeparator() && bookmark.url() == url)
+ else if (bookmark.url().url().contains(text) || bookmark.fullText().contains(text))
{
- title = bookmark.fullText();
+ list << bookmark;
}
- return title;
+ return list;
}
diff --git a/src/bookmarks/bookmarksmanager.h b/src/bookmarks/bookmarksmanager.h
index d2465e77..64945eab 100644
--- a/src/bookmarks/bookmarksmanager.h
+++ b/src/bookmarks/bookmarksmanager.h
@@ -228,7 +228,7 @@ public:
inline BookmarkOwner *bookmarkOwner() { return m_owner; }
- QString titleForBookmarkUrl(QString url);
+ QList<KBookmark> find(QString text);
void registerBookmarkPanel(BookmarksPanel *panel);
void removeBookmarkPanel(BookmarksPanel *panel);
@@ -266,7 +266,7 @@ private slots:
private:
void fillBookmarkBar(KToolBar *toolBar);
- QString titleForBookmarkUrl(const KBookmark &bookmark, QString url);
+ QList<KBookmark> find(QList<KBookmark> list, const KBookmark &bookmark, QString text);
KBookmarkManager *m_manager;
BookmarkOwner *m_owner;
diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp
index 115f0295..753dd002 100644
--- a/src/urlbar/urlresolver.cpp
+++ b/src/urlbar/urlresolver.cpp
@@ -315,7 +315,7 @@ UrlSearchList UrlResolver::historyResolution()
{
QList<HistoryHashItem> found = Application::historyManager()->find(_typedString);
qSort(found);
-
+
UrlSearchList list;
foreach (HistoryHashItem i, found)
{
@@ -333,7 +333,12 @@ UrlSearchList UrlResolver::historyResolution()
UrlSearchList UrlResolver::bookmarksResolution()
{
UrlSearchList list;
- //AwesomeUrlCompletion *bookmarkCompletion = Application::bookmarkProvider()->completionObject();
+ QList<KBookmark> found = Application::bookmarkProvider()->find(_typedString);
+ foreach (KBookmark b, found)
+ {
+ UrlSearchItem gItem(UrlSearchItem::History, b.url().url(), b.fullText());
+ list << gItem;
+ }
return list;
}
diff --git a/src/urlbar/urlresolver.h b/src/urlbar/urlresolver.h
index 190064eb..c79ce184 100644
--- a/src/urlbar/urlresolver.h
+++ b/src/urlbar/urlresolver.h
@@ -84,7 +84,7 @@ public:
inline bool operator==(const UrlSearchItem &i) const
{
return i.url == url;//TODO && i.title == title;
- }
+ }
};
typedef QList <UrlSearchItem> UrlSearchList;