diff options
Diffstat (limited to 'src/urlbar/urlresolver.cpp')
-rw-r--r-- | src/urlbar/urlresolver.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp index b6d7e598..7f6a7f4f 100644 --- a/src/urlbar/urlresolver.cpp +++ b/src/urlbar/urlresolver.cpp @@ -26,6 +26,7 @@ // Self Includes #include "urlresolver.h" +#include "urlresolver.moc" // Local Includes #include "application.h" @@ -59,14 +60,18 @@ // ------------------------------------------------------------------------ +KService::Ptr UrlResolver::_searchEngine; QRegExp UrlResolver::_browseRegexp; QRegExp UrlResolver::_searchEnginesRegexp; + UrlResolver::UrlResolver(const QString &typedUrl) : QObject() , _typedString(typedUrl.trimmed()) { + if (!_searchEngine ) _searchEngine = SearchEngine::defaultEngine(); + if ( _browseRegexp.isEmpty() ) { kDebug() << "browse regexp empty. Setting value.."; @@ -107,8 +112,6 @@ UrlResolver::UrlResolver(const QString &typedUrl) } _searchEnginesRegexp = QRegExp(reg); } - - computeSuggestions(); } @@ -330,7 +333,15 @@ void UrlResolver::computeQurlFromUserInput() //webSearches void UrlResolver::computeWebSearches() { - _webSearches = (UrlSearchList() << UrlSearchItem(UrlSearchItem::Search, QString(), QString())); + QString query = _typedString; + KService::Ptr engine = SearchEngine::fromString(_typedString); + if (engine) + { + query = query.remove(0, _typedString.indexOf(SearchEngine::delimiter()) + 1); + _searchEngine = engine; + } + + _webSearches = (UrlSearchList() << UrlSearchItem(UrlSearchItem::Search, SearchEngine::buildQuery(_searchEngine, query), _searchEngine->name())); } @@ -367,6 +378,15 @@ void UrlResolver::computeBookmarks() //opensearch suggestion void UrlResolver::computeSuggestions() { + // if a string startsWith /, it is probably a local path + // so, no need for suggestions... + if(_typedString.startsWith('/')) + { + UrlSearchList list; + emit suggestionsReady(list, _typedString); + return; + } + if (Application::opensearchManager()->isSuggestionAvailable()) { connect(Application::opensearchManager(), @@ -375,7 +395,7 @@ void UrlResolver::computeSuggestions() SLOT(suggestionsReceived(const QString &, const QStringList &))); Application::opensearchManager()->requestSuggestion(_typedString); - } + } } |