summaryrefslogtreecommitdiff
path: root/src/urlbar
diff options
context:
space:
mode:
Diffstat (limited to 'src/urlbar')
-rw-r--r--src/urlbar/urlsuggester.cpp41
-rw-r--r--src/urlbar/urlsuggester.h2
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;