summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaarten De Meyer <de.meyer.maarten@gmail.com>2013-04-07 11:38:09 +0200
committerAndrea Diamantini <adjam7@gmail.com>2013-04-07 11:39:40 +0200
commit5d1a223145be0eb1bb5eed76cda7d4b889d986ed (patch)
tree1e81db324a50968f5484e073685a5bac61b2deeb
parentFix rekonq window title update (diff)
downloadrekonq-5d1a223145be0eb1bb5eed76cda7d4b889d986ed.tar.xz
Use kurifilter instead of custom rekonq code.
Now all web shortcuts work. BUG: 258639 REVIEWED BY: adjam
-rw-r--r--src/searchengine.cpp18
-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.cpp5
-rw-r--r--src/webtab/webview.cpp6
7 files changed, 24 insertions, 19 deletions
diff --git a/src/searchengine.cpp b/src/searchengine.cpp
index 19529d30..21a9f92d 100644
--- a/src/searchengine.cpp
+++ b/src/searchengine.cpp
@@ -31,6 +31,7 @@
//KDE includes
#include <KConfigGroup>
#include <KServiceTypeTrader>
+#include <KUriFilter>
struct SearchEnginePrivate
@@ -146,11 +147,22 @@ KService::Ptr SearchEngine::fromString(const QString &text)
}
+QString SearchEngine::buildQuery(const QString &text)
+{
+ QString query = text;
+ KUriFilter::self()->filterUri(query, QStringList("kurisearchfilter"));
+
+ //If the query did not change, use the default searchengine
+ if(query == text)
+ KUriFilter::self()->filterUri(query, QStringList("kuriikwsfilter"));
+
+ return query;
+}
QString SearchEngine::buildQuery(KService::Ptr engine, const QString &text)
{
if (!engine)
return QString();
- QString query = engine->property("Query").toString();
- query = query.replace("\\{@}", KUrl::toPercentEncoding(text));
- return query;
+
+ QString query = engine->property("Keys").toStringList().at(0) + SearchEngine::delimiter() + text;
+ return buildQuery(query);
}
diff --git a/src/searchengine.h b/src/searchengine.h
index 21678e9d..6d617250 100644
--- a/src/searchengine.h
+++ b/src/searchengine.h
@@ -51,6 +51,8 @@ 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 580eea53..cc0bf253 100644
--- a/src/urlbar/listitem.cpp
+++ b/src/urlbar/listitem.cpp
@@ -460,12 +460,7 @@ 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...
- // remove the xx: part...
- QString separator = SearchEngine::delimiter();
-
- QString text = m_text.contains(separator)
- ? m_text.section(separator, 1, 1)
- : m_text;
+ QString text = 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 17be6fa0..60f8f63d 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -675,7 +675,7 @@ void UrlBar::pasteAndSearch()
{
KService::Ptr defaultEngine = SearchEngine::defaultEngine();
if (defaultEngine)
- loadRequestedUrl(KUrl(SearchEngine::buildQuery(defaultEngine, QApplication::clipboard()->text().trimmed())));
+ loadRequestedUrl(KUrl(SearchEngine::buildQuery(QApplication::clipboard()->text().trimmed())));
}
diff --git a/src/urlbar/urlsuggester.cpp b/src/urlbar/urlsuggester.cpp
index d6aaaf52..9ca4e8f8 100644
--- a/src/urlbar/urlsuggester.cpp
+++ b/src/urlbar/urlsuggester.cpp
@@ -321,7 +321,6 @@ void UrlSuggester::computeWebSearches()
KService::Ptr engine = SearchEngine::fromString(_typedString);
if (engine)
{
- query = query.remove(0, _typedString.indexOf(SearchEngine::delimiter()) + 1);
_isKDEShortUrl = true;
}
else
@@ -331,7 +330,7 @@ void UrlSuggester::computeWebSearches()
if (engine)
{
- UrlSuggestionItem item = UrlSuggestionItem(UrlSuggestionItem::Search, SearchEngine::buildQuery(engine, query), query, engine->name());
+ UrlSuggestionItem item = UrlSuggestionItem(UrlSuggestionItem::Search, SearchEngine::buildQuery(query), query, engine->name());
UrlSuggestionList list;
list << item;
_webSearches = list;
diff --git a/src/urlresolver.cpp b/src/urlresolver.cpp
index 5e00c77a..6b245c0c 100644
--- a/src/urlresolver.cpp
+++ b/src/urlresolver.cpp
@@ -52,10 +52,7 @@ KUrl UrlResolver::urlFromTextTyped(const QString &typedText)
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);
+ QString url = SearchEngine::buildQuery(typedString);
kDebug() << "Url from service: " << url;
return KUrl(url);
diff --git a/src/webtab/webview.cpp b/src/webtab/webview.cpp
index 44a54156..2d8d0e77 100644
--- a/src/webtab/webview.cpp
+++ b/src/webtab/webview.cpp
@@ -517,7 +517,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(SearchEngine::buildQuery(defaultEngine, "")));
+ a->setIcon(IconManager::self()->iconForUrl(defaultEngine->property("Query").toUrl()));
a->setData(defaultEngine->entryPath());
connect(a, SIGNAL(triggered(bool)), this, SLOT(search()));
menu.addAction(a);
@@ -529,7 +529,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(SearchEngine::buildQuery(engine, "")));
+ a->setIcon(IconManager::self()->iconForUrl(engine->property("Query").toUrl()));
a->setData(engine->entryPath());
connect(a, SIGNAL(triggered(bool)), this, SLOT(search()));
searchMenu->addAction(a);
@@ -639,7 +639,7 @@ void WebView::mousePressEvent(QMouseEvent *event)
{
KService::Ptr defaultEngine = SearchEngine::defaultEngine();
if (defaultEngine) // check if a default engine is set
- load(KUrl(SearchEngine::buildQuery(defaultEngine, clipboardContent)));
+ load(KUrl(SearchEngine::buildQuery(clipboardContent)));
}
}
break;