summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-11-25 12:23:54 +0100
committerAndrea Diamantini <adjam7@gmail.com>2012-12-10 02:48:06 +0100
commitf9781fb4b7d4c09b71188b43848095a1415a4f1e (patch)
tree8297e264124281da8a24353890e5284f218e9876
parentImprove suggestions, step 1 (diff)
downloadrekonq-f9781fb4b7d4c09b71188b43848095a1415a4f1e.tar.xz
Improve suggestions, step 2
Every change here is given to trade-off suggestions performance (p) and relevancy (r). - just check bookmarks for relevance if no history entries found (p) - remove bookmarks item duplicates from history (r) - just do it is user typed more than 1 char (p) - order history entries just if user typed more than 1 char (p) - (reverse) order by visit count (most visited first) (r)
-rw-r--r--src/history/historymanager.h3
-rw-r--r--src/urlbar/urlsuggester.cpp53
-rw-r--r--src/urlbar/urlsuggester.h2
3 files changed, 46 insertions, 12 deletions
diff --git a/src/history/historymanager.h b/src/history/historymanager.h
index 96de8ab8..a0c3a5eb 100644
--- a/src/history/historymanager.h
+++ b/src/history/historymanager.h
@@ -86,7 +86,8 @@ public:
// history is sorted in reverse
inline bool operator <(const HistoryItem &other) const
{
- return lastDateTimeVisit > other.lastDateTimeVisit;
+ return visitCount > other.visitCount;
+// return lastDateTimeVisit > other.lastDateTimeVisit;
}
QString title;
diff --git a/src/urlbar/urlsuggester.cpp b/src/urlbar/urlsuggester.cpp
index efa0249b..7fbb2204 100644
--- a/src/urlbar/urlsuggester.cpp
+++ b/src/urlbar/urlsuggester.cpp
@@ -225,17 +225,22 @@ UrlSuggestionList UrlSuggester::orderLists()
}
}
- // bookmarks
- Q_FOREACH(const UrlSuggestionItem & item, _bookmarks)
+ // just add this is relevant is Null
+
+ if (relevant.count() == 0)
{
- QString hst = KUrl(item.url).host();
- if (item.url.startsWith(_typedString)
- || hst.startsWith(_typedString)
- || hst.remove("www.").startsWith(_typedString))
+ // bookmarks
+ Q_FOREACH(const UrlSuggestionItem & item, _bookmarks)
{
- relevant << item;
- _bookmarks.removeOne(item);
- break;
+ QString hst = KUrl(item.url).host();
+ if (item.url.startsWith(_typedString)
+ || hst.startsWith(_typedString)
+ || hst.remove("www.").startsWith(_typedString))
+ {
+ relevant << item;
+ _bookmarks.removeOne(item);
+ break;
+ }
}
}
@@ -267,6 +272,9 @@ UrlSuggestionList UrlSuggester::orderLists()
}
}
+ if (_typedString.count() > 1)
+ removeBookmarksDuplicates();
+
// and finally, results
UrlSuggestionList list;
if (textIsUrl)
@@ -337,8 +345,9 @@ void UrlSuggester::computeHistory()
QList<HistoryItem> found = HistoryManager::self()->find(_typedString);
// FIXME: profiling computeHistory, this seems too much expensive (around 1 second for)
- // Can we live without (q)sort results???
- // qSort(found.begin(), found.end(), isHistoryItemRelevant);
+ // doing it just from second time...
+ if (_typedString.count() > 1)
+ qSort(found.begin(), found.end(), isHistoryItemRelevant);
Q_FOREACH(const HistoryItem & i, found)
{
@@ -423,3 +432,25 @@ void UrlSuggester::computeSuggestions()
// emit suggestionsReady(sugList, _typedString);
// this->deleteLater();
// }
+
+
+//////////////////////////////////////////////////////////////////////////
+
+
+// WARNING: this seems A LOT expensive and has to be done just
+// when the two groups (history & bookmarks) have just been "restricted"..
+void UrlSuggester::removeBookmarksDuplicates()
+{
+ Q_FOREACH(const UrlSuggestionItem & item, _history)
+ {
+ QString hu = item.url;
+ Q_FOREACH(const UrlSuggestionItem & item, _bookmarks)
+ {
+ if (hu == item.url)
+ {
+ _bookmarks.removeOne(item);
+ break;
+ }
+ }
+ }
+}
diff --git a/src/urlbar/urlsuggester.h b/src/urlbar/urlsuggester.h
index 6c77d8dc..f3732d91 100644
--- a/src/urlbar/urlsuggester.h
+++ b/src/urlbar/urlsuggester.h
@@ -136,6 +136,8 @@ private:
void computeQurlFromUserInput();
void computeBookmarks();
+ void removeBookmarksDuplicates();
+
UrlSuggestionList orderLists();
QString _typedString;