summaryrefslogtreecommitdiff
path: root/src/search
diff options
context:
space:
mode:
Diffstat (limited to 'src/search')
-rw-r--r--src/search/opensearchmanager.cpp4
-rw-r--r--src/search/searchengine.cpp20
-rw-r--r--src/search/searchengine.h7
3 files changed, 22 insertions, 9 deletions
diff --git a/src/search/opensearchmanager.cpp b/src/search/opensearchmanager.cpp
index 9670a6a2..c2ac1ddb 100644
--- a/src/search/opensearchmanager.cpp
+++ b/src/search/opensearchmanager.cpp
@@ -114,6 +114,7 @@ void OpenSearchManager::addOpenSearchEngine(const KUrl &url, const QString &titl
{
disconnect(m_currentJob);
m_currentJob->kill();
+ delete m_currentJob;
}
m_jobData.clear();
@@ -149,7 +150,8 @@ void OpenSearchManager::requestSuggestion(const QString &searchText)
if (m_currentJob)
{
disconnect(m_currentJob);
- m_currentJob->kill();
+ m_currentJob->kill();
+ delete m_currentJob;
}
m_jobData.clear();
diff --git a/src/search/searchengine.cpp b/src/search/searchengine.cpp
index 38f063a4..89e62dee 100644
--- a/src/search/searchengine.cpp
+++ b/src/search/searchengine.cpp
@@ -111,7 +111,7 @@ KService::Ptr SearchEngine::defaultEngine()
}
-KService::Ptr SearchEngine::fromString(QString text)
+KService::Ptr SearchEngine::fromString(const QString &text)
{
KService::List providers = KServiceTypeTrader::self()->query("SearchProvider");
int i = 0;
@@ -136,12 +136,22 @@ KService::Ptr SearchEngine::fromString(QString text)
}
-QString SearchEngine::buildQuery(KService::Ptr engine, QString text)
+QString SearchEngine::extractQuery(const QString &text)
{
- QString query = engine->property("Query").toString();
- query = query.replace("\\{@}", KUrl::toPercentEncoding(text));
+ QString query = text;
+ KService::Ptr engine = SearchEngine::fromString(text);
+ if (engine)
+ {
+ query = query.remove(0, text.indexOf(SearchEngine::delimiter()) + 1);
+ }
+
return query;
}
-
+QString SearchEngine::buildQuery(KService::Ptr engine, const QString &text)
+{
+ QString query = engine->property("Query").toString();
+ query = query.replace("\\{@}", KUrl::toPercentEncoding(text));
+ return query;
+}
diff --git a/src/search/searchengine.h b/src/search/searchengine.h
index e57b1a5c..d813666b 100644
--- a/src/search/searchengine.h
+++ b/src/search/searchengine.h
@@ -45,9 +45,10 @@ public:
static QString delimiter();
static KService::Ptr defaultEngine();
static KService::List favorites();
- static KService::Ptr fromString(QString text);
- static QString buildQuery(KService::Ptr engine, QString text);
-
+ static KService::Ptr fromString(const QString &text);
+ static QString buildQuery(KService::Ptr engine, const QString &text);
+ static QString extractQuery(const QString &text);
+
private:
static bool m_loaded;
static QString m_delimiter;