summaryrefslogtreecommitdiff
path: root/src/opensearch
diff options
context:
space:
mode:
Diffstat (limited to 'src/opensearch')
-rw-r--r--src/opensearch/opensearchreader.cpp3
-rw-r--r--src/opensearch/searchengine.cpp17
-rw-r--r--src/opensearch/suggestionparser.cpp7
3 files changed, 12 insertions, 15 deletions
diff --git a/src/opensearch/opensearchreader.cpp b/src/opensearch/opensearchreader.cpp
index 1c106afa..aff9ff36 100644
--- a/src/opensearch/opensearchreader.cpp
+++ b/src/opensearch/opensearchreader.cpp
@@ -74,7 +74,8 @@ OpenSearchEngine *OpenSearchReader::read()
{
OpenSearchEngine *engine = new OpenSearchEngine();
- while (!isStartElement() && !atEnd()) {
+ while (!isStartElement() && !atEnd())
+ {
readNext();
}
diff --git a/src/opensearch/searchengine.cpp b/src/opensearch/searchengine.cpp
index 44e35e33..4378a26c 100644
--- a/src/opensearch/searchengine.cpp
+++ b/src/opensearch/searchengine.cpp
@@ -57,7 +57,7 @@ void SearchEngine::reload()
favoriteEngines = cg.readEntry("FavoriteSearchEngines", favoriteEngines);
KService::List favorites;
KService::Ptr service;
- foreach(const QString &engine, favoriteEngines)
+ Q_FOREACH(const QString &engine, favoriteEngines)
{
service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(engine));
if (service)
@@ -74,11 +74,6 @@ void SearchEngine::reload()
//load default engine
QString d = cg.readEntry("DefaultSearchEngine");
m_defaultEngine = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(d));
-// if (!m_defaultEngine)
-// {
-// d = QL1S("google");
-// m_defaultEngine = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(d));
-// }
m_loaded = true;
}
@@ -120,7 +115,7 @@ KService::Ptr SearchEngine::fromString(const QString &text)
while (!found && i < providers.size())
{
QStringList list = providers.at(i)->property("Keys").toStringList();
- foreach(const QString &key, list)
+ Q_FOREACH(const QString &key, list)
{
const QString searchPrefix = key + delimiter();
if (text.startsWith(searchPrefix))
@@ -141,18 +136,14 @@ QString SearchEngine::extractQuery(const QString &text)
QString query = text;
KService::Ptr engine = SearchEngine::fromString(text);
- // WARNING: this lets rekonq hangs on kde: urlbar typing..
-// if (engine)
-// {
-// query = query.remove(0, text.indexOf(SearchEngine::delimiter()) + 1);
-// }
-
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;
diff --git a/src/opensearch/suggestionparser.cpp b/src/opensearch/suggestionparser.cpp
index 98bb8a69..4ed13e16 100644
--- a/src/opensearch/suggestionparser.cpp
+++ b/src/opensearch/suggestionparser.cpp
@@ -55,7 +55,8 @@ ResponseList XMLParser::parse(const QByteArray &resp)
{
m_reader.readNext();
- if (m_reader.isStartDocument()) continue;
+ if (m_reader.isStartDocument())
+ continue;
if (m_reader.isStartElement() && m_reader.name() == QL1S("Item"))
{
@@ -105,6 +106,7 @@ ResponseList JSONParser::parse(const QByteArray &resp)
if (response.isEmpty())
{
+ kDebug() << "RESPONSE IS EMPTY";
return ResponseList();
}
@@ -112,12 +114,14 @@ ResponseList JSONParser::parse(const QByteArray &resp)
|| !response.endsWith(QL1C(']'))
)
{
+ kDebug() << "RESPONSE is NOT well FORMED";
return ResponseList();
}
// Evaluate the JSON response using QtScript.
if (!m_reader.canEvaluate(response))
{
+ kDebug() << "m_reader cannot evaluate the response";
return ResponseList();
}
@@ -125,6 +129,7 @@ ResponseList JSONParser::parse(const QByteArray &resp)
if (!responseParts.property(1).isArray())
{
+ kDebug() << "RESPONSE is not an array";
return ResponseList();
}