summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/searchengine.cpp16
-rw-r--r--src/searchengine.h2
-rw-r--r--src/urlbar/listitem.cpp7
-rw-r--r--src/urlbar/urlbar.cpp2
-rw-r--r--src/urlbar/urlsuggester.cpp3
-rw-r--r--src/urlresolver.cpp16
-rw-r--r--src/webtab/webview.cpp6
7 files changed, 26 insertions, 26 deletions
diff --git a/src/searchengine.cpp b/src/searchengine.cpp
index b4a96cd9..cfe84a69 100644
--- a/src/searchengine.cpp
+++ b/src/searchengine.cpp
@@ -31,7 +31,6 @@
//KDE includes
#include <KConfigGroup>
#include <KServiceTypeTrader>
-#include <KUriFilter>
#include <QStringList>
@@ -150,20 +149,11 @@ KService::Ptr SearchEngine::fromString(const QString &text)
}
-QString SearchEngine::buildQuery(const QString &text)
-{
- QString query = text;
- KUriFilter::self()->filterUri(query, QStringList());
-
- return query;
-}
-
-
QString SearchEngine::buildQuery(KService::Ptr engine, const QString &text)
{
if (!engine)
return QString();
-
- QString query = engine->property("Keys").toStringList().at(0) + SearchEngine::delimiter() + text;
- return buildQuery(query);
+ QString query = engine->property("Query").toString();
+ query = query.replace("\\{@}", KUrl::toPercentEncoding(text));
+ return query;
}
diff --git a/src/searchengine.h b/src/searchengine.h
index 9bc029a6..38808ae3 100644
--- a/src/searchengine.h
+++ b/src/searchengine.h
@@ -51,8 +51,6 @@ KService::List favorites();
KService::Ptr fromString(const QString &text);
-QString buildQuery(const QString &text);
-
QString buildQuery(KService::Ptr engine, const QString &text);
QString extractQuery(const QString &text);
diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp
index cc0bf253..580eea53 100644
--- a/src/urlbar/listitem.cpp
+++ b/src/urlbar/listitem.cpp
@@ -460,7 +460,12 @@ void SearchListItem::changeSearchEngine(KService::Ptr engine)
// NOTE: This to let rekonq loading text typed in the requested engine on click.
// There probably is a better way to do it. I just cannot see it now...
- QString text = m_text;
+ // remove the xx: part...
+ QString separator = SearchEngine::delimiter();
+
+ QString text = m_text.contains(separator)
+ ? m_text.section(separator, 1, 1)
+ : m_text;
// create a new item && load it...
UrlSuggestionItem item = UrlSuggestionItem(UrlSuggestionItem::Search, SearchEngine::buildQuery(engine, text), text);
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index c0277c20..6af68a3d 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -665,7 +665,7 @@ void UrlBar::pasteAndSearch()
{
KService::Ptr defaultEngine = SearchEngine::defaultEngine();
if (defaultEngine)
- loadRequestedUrl(KUrl(SearchEngine::buildQuery(QApplication::clipboard()->text().trimmed())));
+ loadRequestedUrl(KUrl(SearchEngine::buildQuery(defaultEngine, QApplication::clipboard()->text().trimmed())));
}
diff --git a/src/urlbar/urlsuggester.cpp b/src/urlbar/urlsuggester.cpp
index 9ca4e8f8..d6aaaf52 100644
--- a/src/urlbar/urlsuggester.cpp
+++ b/src/urlbar/urlsuggester.cpp
@@ -321,6 +321,7 @@ void UrlSuggester::computeWebSearches()
KService::Ptr engine = SearchEngine::fromString(_typedString);
if (engine)
{
+ query = query.remove(0, _typedString.indexOf(SearchEngine::delimiter()) + 1);
_isKDEShortUrl = true;
}
else
@@ -330,7 +331,7 @@ void UrlSuggester::computeWebSearches()
if (engine)
{
- UrlSuggestionItem item = UrlSuggestionItem(UrlSuggestionItem::Search, SearchEngine::buildQuery(query), query, engine->name());
+ UrlSuggestionItem item = UrlSuggestionItem(UrlSuggestionItem::Search, SearchEngine::buildQuery(engine, query), query, engine->name());
UrlSuggestionList list;
list << item;
_webSearches = list;
diff --git a/src/urlresolver.cpp b/src/urlresolver.cpp
index 3e764159..5e00c77a 100644
--- a/src/urlresolver.cpp
+++ b/src/urlresolver.cpp
@@ -49,11 +49,17 @@ KUrl UrlResolver::urlFromTextTyped(const QString &typedText)
QString typedString = typedText.trimmed();
// Url from KService
- QString urlString = SearchEngine::buildQuery(typedString);
- kDebug() << "Url from service: " << urlString;
- KUrl u(urlString);
- if (u.isValid())
- return u;
+ KService::Ptr engine = SearchEngine::fromString(typedString);
+ if (engine)
+ {
+ QString query = typedString;
+ query = query.remove(0, typedString.indexOf(SearchEngine::delimiter()) + 1);
+
+ QString url = SearchEngine::buildQuery(engine, query);
+
+ kDebug() << "Url from service: " << url;
+ return KUrl(url);
+ }
// Url from User Input
QUrl urlFromUserInput = QUrl::fromUserInput(typedString);
diff --git a/src/webtab/webview.cpp b/src/webtab/webview.cpp
index df91451f..ac46e9c4 100644
--- a/src/webtab/webview.cpp
+++ b/src/webtab/webview.cpp
@@ -515,7 +515,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
{
a = new KAction(i18nc("Search selected text with the default search engine", "Search with %1",
defaultEngine->name()), &menu);
- a->setIcon(IconManager::self()->iconForUrl(defaultEngine->property("Query").toUrl()));
+ a->setIcon(IconManager::self()->iconForUrl(SearchEngine::buildQuery(defaultEngine, "")));
a->setData(defaultEngine->entryPath());
connect(a, SIGNAL(triggered(bool)), this, SLOT(search()));
menu.addAction(a);
@@ -527,7 +527,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
Q_FOREACH(const KService::Ptr & engine, SearchEngine::favorites())
{
a = new KAction(i18nc("@item:inmenu Search, %1 = search engine", "With %1", engine->name()), &menu);
- a->setIcon(IconManager::self()->iconForUrl(engine->property("Query").toUrl()));
+ a->setIcon(IconManager::self()->iconForUrl(SearchEngine::buildQuery(engine, "")));
a->setData(engine->entryPath());
connect(a, SIGNAL(triggered(bool)), this, SLOT(search()));
searchMenu->addAction(a);
@@ -640,7 +640,7 @@ void WebView::mousePressEvent(QMouseEvent *event)
{
KService::Ptr defaultEngine = SearchEngine::defaultEngine();
if (defaultEngine) // check if a default engine is set
- load(KUrl(SearchEngine::buildQuery(clipboardContent)));
+ load(KUrl(SearchEngine::buildQuery(defaultEngine, clipboardContent)));
}
}
break;