diff options
author | megabigbug <megabigbug@arrakis.(none)> | 2010-07-20 23:12:45 +0200 |
---|---|---|
committer | megabigbug <megabigbug@arrakis.(none)> | 2010-07-20 23:12:45 +0200 |
commit | dadd2ac929daa925bf7c91379e064427241afc1f (patch) | |
tree | e14c08812e3c5384c7600de5c1932ecaf1da7006 /src/urlbar/urlresolver.cpp | |
parent | history review: (diff) | |
download | rekonq-dadd2ac929daa925bf7c91379e064427241afc1f.tar.xz |
remove useless bookmarkPath attribute of UrlSearchItem
add a regexp for detect url of search engines
remove url that are detected from history suggestions
Diffstat (limited to 'src/urlbar/urlresolver.cpp')
-rw-r--r-- | src/urlbar/urlresolver.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp index 50f1692f..115f0295 100644 --- a/src/urlbar/urlresolver.cpp +++ b/src/urlbar/urlresolver.cpp @@ -31,6 +31,7 @@ #include "application.h" #include "historymanager.h" #include "bookmarksmanager.h" +#include "searchengine.h" // KDE Includes #include <KUriFilter> @@ -59,7 +60,7 @@ QRegExp UrlResolver::_browseRegexp; - +QRegExp UrlResolver::_searchEnginesRegexp; UrlResolver::UrlResolver(const QString &typedUrl) : _typedString(typedUrl.trimmed()) @@ -90,6 +91,18 @@ UrlResolver::UrlResolver(const QString &typedUrl) _browseRegexp = QRegExp('(' + protocol + ")|(" + localhost + ")|(" + local + ")|(" + address + ")|(" + ipv6 + ")|(" + ipv4 +')'); } + if ( _searchEnginesRegexp.isEmpty() ) + { + QString reg; + QString engineUrl; + foreach(KService::Ptr s, SearchEngine::favorites()) + { + engineUrl = QRegExp::escape(s->property("Query").toString()).replace("\\\\\\{@\\}","[\\d\\w-.]+"); + if (reg.isEmpty()) reg = "(" + engineUrl + ")"; + else reg = reg + "|(" + engineUrl + ")"; + } + _searchEnginesRegexp = QRegExp(reg); + } } @@ -300,12 +313,17 @@ UrlSearchList UrlResolver::webSearchesResolution() // STEP 3 = history completion UrlSearchList UrlResolver::historyResolution() { - QList<HistoryHashItem> mostVisited = Application::historyManager()->findMostVisited(_typedString); + QList<HistoryHashItem> found = Application::historyManager()->find(_typedString); + qSort(found); + UrlSearchList list; - foreach (HistoryHashItem i, mostVisited) + foreach (HistoryHashItem i, found) { - UrlSearchItem gItem(UrlSearchItem::History, i.url, i.title); - list << gItem; + if (_searchEnginesRegexp.indexIn(i.url) == -1) //filter all urls that are search engine results + { + UrlSearchItem gItem(UrlSearchItem::History, i.url, i.title); + list << gItem; + } } return list; } |