diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2012-10-01 18:51:30 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2012-12-10 02:48:05 +0100 |
commit | 3d8626554e801dcdd68344e0dcdfc26684fad441 (patch) | |
tree | 9f3736abc13273b3d3a4811fc3d9965c513bf0ff /src/urlbar | |
parent | New Private Browsing mode :D (diff) | |
download | rekonq-3d8626554e801dcdd68344e0dcdfc26684fad441.tar.xz |
Fix url suggestions
1) typed "kde" --> web search + urlFromUserInput
2) typed "kde.org --> urlFromUserInput + web search
3) typed "gg:kde" --> web search
Diffstat (limited to 'src/urlbar')
-rw-r--r-- | src/urlbar/urlsuggester.cpp | 41 | ||||
-rw-r--r-- | src/urlbar/urlsuggester.h | 2 |
2 files changed, 26 insertions, 17 deletions
diff --git a/src/urlbar/urlsuggester.cpp b/src/urlbar/urlsuggester.cpp index 90ff2320..bc0ad280 100644 --- a/src/urlbar/urlsuggester.cpp +++ b/src/urlbar/urlsuggester.cpp @@ -73,7 +73,7 @@ QRegExp UrlSuggester::_searchEnginesRegexp; UrlSuggester::UrlSuggester(const QString &typedUrl) : QObject() , _typedString(typedUrl.trimmed()) - , _webSearchFirst(false) + , _isKDEShortUrl(false) { if (_browseRegexp.isEmpty()) { @@ -132,13 +132,14 @@ UrlSuggestionList UrlSuggester::orderedSearchItems() aboutUrlList << QL1S("about:home") << QL1S("about:favorites") - << QL1S("about:closedTabs") +// << QL1S("about:closedTabs") << QL1S("about:bookmarks") << QL1S("about:history") << QL1S("about:downloads") - << QL1S("about:tabs") - << QL1S("about:info"); - +// << QL1S("about:tabs") +// << QL1S("about:info") + ; + QStringList aboutUrlResults = aboutUrlList.filter(_typedString, Qt::CaseInsensitive); UrlSuggestionList list; @@ -182,13 +183,21 @@ UrlSuggestionList UrlSuggester::orderLists() // Browse & Search results UrlSuggestionList browseSearch; QString lowerTypedString = _typedString.toLower(); - if (_webSearchFirst || _browseRegexp.indexIn(lowerTypedString) != -1) + + if (_isKDEShortUrl) { - _webSearchFirst = true; + // KDE short url case (typed gg:kde): we need just the web search + browseSearch << _webSearches; + } + else if (_browseRegexp.indexIn(lowerTypedString) != -1) + { + // browse url case (typed kde.org): show resolved url before + browseSearch << _qurlFromUserInput; browseSearch << _webSearches; } else { + // NON url case: propose web search before browseSearch << _webSearches; browseSearch << _qurlFromUserInput; } @@ -255,9 +264,6 @@ UrlSuggestionList UrlSuggester::orderLists() // and finally, results UrlSuggestionList list; - -// if (_webSearchFirst) -// list << _qurlFromUserInput; list += relevant + browseSearch + _history + _bookmarks; return list; } @@ -298,18 +304,21 @@ void UrlSuggester::computeWebSearches() KService::Ptr engine = SearchEngine::fromString(_typedString); if (engine) { - _webSearchFirst = true; query = query.remove(0, _typedString.indexOf(SearchEngine::delimiter()) + 1); + _isKDEShortUrl = true; } else { engine = SearchEngine::defaultEngine(); } - - UrlSuggestionItem item = UrlSuggestionItem(UrlSuggestionItem::Search, SearchEngine::buildQuery(engine, query), query, engine->name()); - UrlSuggestionList list; - list << item; - _webSearches = list; + + if (engine) + { + UrlSuggestionItem item = UrlSuggestionItem(UrlSuggestionItem::Search, SearchEngine::buildQuery(engine, query), query, engine->name()); + UrlSuggestionList list; + list << item; + _webSearches = list; + } } diff --git a/src/urlbar/urlsuggester.h b/src/urlbar/urlsuggester.h index edbe116a..6c77d8dc 100644 --- a/src/urlbar/urlsuggester.h +++ b/src/urlbar/urlsuggester.h @@ -146,7 +146,7 @@ private: UrlSuggestionList _bookmarks; UrlSuggestionList _suggestions; - bool _webSearchFirst; + bool _isKDEShortUrl; static QRegExp _browseRegexp; static QRegExp _searchEnginesRegexp; |