summaryrefslogtreecommitdiff
path: root/src/opensearch
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2011-07-17 16:46:24 +0200
committerAndrea Diamantini <adjam7@gmail.com>2011-07-17 16:46:24 +0200
commit82167d2422a4b6e3071dca68cf65a66e1da41ab4 (patch)
tree03c1f95a2aa60c48822a463cc3812b5c3415991e /src/opensearch
parentImproving tab previews (diff)
downloadrekonq-82167d2422a4b6e3071dca68cf65a66e1da41ab4.tar.xz
A round of the "new" astyle 2.01...
Diffstat (limited to 'src/opensearch')
-rw-r--r--src/opensearch/opensearchengine.cpp26
-rw-r--r--src/opensearch/opensearchmanager.cpp58
-rw-r--r--src/opensearch/opensearchreader.cpp42
-rw-r--r--src/opensearch/opensearchwriter.cpp24
-rw-r--r--src/opensearch/searchengine.cpp18
-rw-r--r--src/opensearch/suggestionparser.cpp30
-rw-r--r--src/opensearch/suggestionparser.h30
7 files changed, 114 insertions, 114 deletions
diff --git a/src/opensearch/opensearchengine.cpp b/src/opensearch/opensearchengine.cpp
index 80eb308f..f48118ca 100644
--- a/src/opensearch/opensearchengine.cpp
+++ b/src/opensearch/opensearchengine.cpp
@@ -43,15 +43,15 @@
OpenSearchEngine::OpenSearchEngine(QObject *parent)
- : QObject(parent)
- , m_parser(0)
+ : QObject(parent)
+ , m_parser(0)
{
}
OpenSearchEngine::~OpenSearchEngine()
{
- if (m_parser)
+ if(m_parser)
{
delete m_parser;
}
@@ -66,7 +66,7 @@ QString OpenSearchEngine::parseTemplate(const QString &searchTerm, const QString
QString country = language;
country = (country.remove(0, country.indexOf(QL1C('-')) + 1)).toLower();
const int firstDashPosition = country.indexOf(QL1C('-'));
- if (firstDashPosition >= 0)
+ if(firstDashPosition >= 0)
country = country.mid(firstDashPosition + 1);
QString result = searchTemplate;
@@ -121,7 +121,7 @@ void OpenSearchEngine::setSearchUrlTemplate(const QString &searchUrlTemplate)
KUrl OpenSearchEngine::searchUrl(const QString &searchTerm) const
{
- if (m_searchUrlTemplate.isEmpty())
+ if(m_searchUrlTemplate.isEmpty())
{
return KUrl();
}
@@ -129,7 +129,7 @@ KUrl OpenSearchEngine::searchUrl(const QString &searchTerm) const
KUrl retVal = KUrl::fromEncoded(parseTemplate(searchTerm, m_searchUrlTemplate).toUtf8());
QList<Parameter>::const_iterator i;
- for (i = m_searchParameters.constBegin(); i != m_searchParameters.constEnd(); ++i)
+ for(i = m_searchParameters.constBegin(); i != m_searchParameters.constEnd(); ++i)
{
retVal.addQueryItem(i->first, parseTemplate(searchTerm, i->second));
}
@@ -158,7 +158,7 @@ void OpenSearchEngine::setSuggestionsUrlTemplate(const QString &suggestionsUrlTe
KUrl OpenSearchEngine::suggestionsUrl(const QString &searchTerm) const
{
- if (m_suggestionsUrlTemplate.isEmpty())
+ if(m_suggestionsUrlTemplate.isEmpty())
{
return KUrl();
}
@@ -166,7 +166,7 @@ KUrl OpenSearchEngine::suggestionsUrl(const QString &searchTerm) const
KUrl retVal = KUrl::fromEncoded(parseTemplate(searchTerm, m_suggestionsUrlTemplate).toUtf8());
QList<Parameter>::const_iterator i;
- for (i = m_suggestionsParameters.constBegin(); i != m_suggestionsParameters.constEnd(); ++i)
+ for(i = m_suggestionsParameters.constBegin(); i != m_suggestionsParameters.constEnd(); ++i)
{
retVal.addQueryItem(i->first, parseTemplate(searchTerm, i->second));
}
@@ -255,7 +255,7 @@ bool OpenSearchEngine::operator<(const OpenSearchEngine &other) const
ResponseList OpenSearchEngine::parseSuggestion(const QString &searchTerm, const QByteArray &resp)
{
QFile file(suggestionPathFor(searchTerm));
- if (file.open(QIODevice::WriteOnly | QIODevice::Text))
+ if(file.open(QIODevice::WriteOnly | QIODevice::Text))
{
file.write(resp, resp.size());
file.close();
@@ -267,12 +267,12 @@ ResponseList OpenSearchEngine::parseSuggestion(const QString &searchTerm, const
ResponseList OpenSearchEngine::parseSuggestion(const QByteArray &resp)
{
- if (!m_parser)
+ if(!m_parser)
return ResponseList();
if(resp.isEmpty())
return ResponseList();
-
+
return m_parser->parse(resp);
}
@@ -299,11 +299,11 @@ bool OpenSearchEngine::hasCachedSuggestionsFor(const QString &searchTerm)
ResponseList OpenSearchEngine::cachedSuggestionsFor(const QString &searchTerm)
{
QFile file(suggestionPathFor(searchTerm));
- if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
+ if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
return ResponseList();
QByteArray resp;
- while (!file.atEnd())
+ while(!file.atEnd())
{
resp += file.readLine();
}
diff --git a/src/opensearch/opensearchmanager.cpp b/src/opensearch/opensearchmanager.cpp
index 591a4acb..35716d9a 100644
--- a/src/opensearch/opensearchmanager.cpp
+++ b/src/opensearch/opensearchmanager.cpp
@@ -54,9 +54,9 @@
#include <QDBusConnection>
OpenSearchManager::OpenSearchManager(QObject *parent)
- : QObject(parent)
- , m_activeEngine(0)
- , m_currentJob(0)
+ : QObject(parent)
+ , m_activeEngine(0)
+ , m_currentJob(0)
{
m_state = IDLE;
loadEngines();
@@ -75,18 +75,18 @@ void OpenSearchManager::setSearchProvider(const QString &searchProvider)
{
m_activeEngine = 0;
- if (!m_engineCache.contains(searchProvider))
+ if(!m_engineCache.contains(searchProvider))
{
const QString fileName = KGlobal::dirs()->findResource("data", "rekonq/opensearch/" + trimmedEngineName(searchProvider) + ".xml");
kDebug() << searchProvider << " trimmed name: " << trimmedEngineName(searchProvider) << " file name path: " << fileName;
- if (fileName.isEmpty())
+ if(fileName.isEmpty())
{
kDebug() << "OpenSearch file name empty";
return;
}
QFile file(fileName);
- if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
+ if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
kDebug() << "Cannot open opensearch description file: " + fileName;
return;
@@ -95,7 +95,7 @@ void OpenSearchManager::setSearchProvider(const QString &searchProvider)
OpenSearchReader reader;
OpenSearchEngine *engine = reader.read(&file);
- if (engine)
+ if(engine)
{
m_engineCache.insert(searchProvider, engine);
}
@@ -121,7 +121,7 @@ void OpenSearchManager::addOpenSearchEngine(const KUrl &url, const QString &titl
m_shortcut = shortcut;
- if (m_state != IDLE)
+ if(m_state != IDLE)
{
idleJob();
}
@@ -135,10 +135,10 @@ void OpenSearchManager::addOpenSearchEngine(const KUrl &url, const QString &titl
void OpenSearchManager::requestSuggestion(const QString &searchText)
{
- if (!m_activeEngine)
+ if(!m_activeEngine)
return;
- if (m_state != IDLE)
+ if(m_state != IDLE)
{
// NOTE:
// changing OpenSearchManager behavior
@@ -147,7 +147,7 @@ void OpenSearchManager::requestSuggestion(const QString &searchText)
idleJob();
}
- if (m_activeEngine->hasCachedSuggestionsFor(searchText))
+ if(m_activeEngine->hasCachedSuggestionsFor(searchText))
{
emit suggestionsReceived(searchText, m_activeEngine->cachedSuggestionsFor(searchText));
}
@@ -174,18 +174,18 @@ void OpenSearchManager::dataReceived(KIO::Job *job, const QByteArray &data)
void OpenSearchManager::jobFinished(KJob *job)
{
// Do NOT parse if job had same errors or the typed string is empty
- if (job->error() || _typedText.isEmpty())
+ if(job->error() || _typedText.isEmpty())
{
emit suggestionsReceived(_typedText, ResponseList());
m_state = IDLE;
return; // just silently return
}
- if (m_state == REQ_SUGGESTION)
+ if(m_state == REQ_SUGGESTION)
{
const ResponseList suggestionsList = m_activeEngine->parseSuggestion(_typedText, m_jobData);
kDebug() << "Received suggestions in " << _typedText << " from " << m_activeEngine->name() << ": ";
- Q_FOREACH(const Response &r, suggestionsList)
+ Q_FOREACH(const Response & r, suggestionsList)
{
kDebug() << r.title;
}
@@ -194,18 +194,18 @@ void OpenSearchManager::jobFinished(KJob *job)
return;
}
- if (m_state == REQ_DESCRIPTION)
+ if(m_state == REQ_DESCRIPTION)
{
OpenSearchReader reader;
OpenSearchEngine *engine = reader.read(m_jobData);
- if (engine)
+ if(engine)
{
m_engineCache.insert(engine->name(), engine);
m_engines.insert(m_jobUrl, trimmedEngineName(engine->name()));
saveEngines();
QString path;
- if (engine->providesSuggestions()) //save opensearch description only if it provides suggestions
+ if(engine->providesSuggestions()) //save opensearch description only if it provides suggestions
{
OpenSearchWriter writer;
path = KGlobal::dirs()->findResource("data", "rekonq/opensearch/");
@@ -249,7 +249,7 @@ void OpenSearchManager::jobFinished(KJob *job)
void OpenSearchManager::loadEngines()
{
QFile file(KStandardDirs::locate("appdata", "opensearch/db_opensearch.json"));
- if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
+ if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
kDebug() << "opensearch db cannot be read";
return;
@@ -257,7 +257,7 @@ void OpenSearchManager::loadEngines()
QString fileContent = QString::fromUtf8(file.readAll());
QScriptEngine reader;
- if (!reader.canEvaluate(fileContent))
+ if(!reader.canEvaluate(fileContent))
{
kDebug() << "opensearch db cannot be read";
return;
@@ -267,7 +267,7 @@ void OpenSearchManager::loadEngines()
QVariantList list;
qScriptValueToSequence(responseParts, list);
QStringList l;
- Q_FOREACH(const QVariant &e, list)
+ Q_FOREACH(const QVariant & e, list)
{
l = e.toStringList();
m_engines.insert(KUrl(l.first()), l.last());
@@ -279,7 +279,7 @@ void OpenSearchManager::loadEngines()
void OpenSearchManager::saveEngines()
{
QFile file(KStandardDirs::locateLocal("appdata", "opensearch/db_opensearch.json"));
- if (!file.open(QIODevice::WriteOnly))
+ if(!file.open(QIODevice::WriteOnly))
{
kDebug() << "opensearch db cannot be writen";
return;
@@ -288,11 +288,11 @@ void OpenSearchManager::saveEngines()
out << "[";
int i = 0;
QList<KUrl> urls = m_engines.keys();
- Q_FOREACH(const KUrl &url, urls)
+ Q_FOREACH(const KUrl & url, urls)
{
out << "[\"" << url.url() << "\",\"" << m_engines.value(url) << "\"]";
i++;
- if (i != urls.size())
+ if(i != urls.size())
{
out << ",\n";
}
@@ -305,10 +305,10 @@ void OpenSearchManager::saveEngines()
void OpenSearchManager::removeDeletedEngines()
{
KService::Ptr service;
- Q_FOREACH(const KUrl &url, m_engines.keys())
+ Q_FOREACH(const KUrl & url, m_engines.keys())
{
service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(m_engines.value(url)));
- if (!service)
+ if(!service)
{
QString path = KStandardDirs::locateLocal("appdata", "opensearch/" + trimmedEngineName(m_engines.value(url)) + ".xml");
QFile::remove(path + trimmedEngineName(m_engines.value(url)) + ".xml");
@@ -329,15 +329,15 @@ QString OpenSearchManager::trimmedEngineName(const QString &engineName) const
{
QString trimmed;
QString::ConstIterator constIter = engineName.constBegin();
- while (constIter != engineName.constEnd())
+ while(constIter != engineName.constEnd())
{
- if (constIter->isSpace())
+ if(constIter->isSpace())
{
trimmed.append('_');
}
else
{
- if (*constIter != '.')
+ if(*constIter != '.')
{
trimmed.append(constIter->toLower());
}
@@ -351,7 +351,7 @@ QString OpenSearchManager::trimmedEngineName(const QString &engineName) const
void OpenSearchManager::idleJob()
{
- if (m_currentJob)
+ if(m_currentJob)
{
disconnect(m_currentJob);
m_currentJob->kill();
diff --git a/src/opensearch/opensearchreader.cpp b/src/opensearch/opensearchreader.cpp
index 2076338b..a789c413 100644
--- a/src/opensearch/opensearchreader.cpp
+++ b/src/opensearch/opensearchreader.cpp
@@ -42,7 +42,7 @@
OpenSearchReader::OpenSearchReader()
- : QXmlStreamReader()
+ : QXmlStreamReader()
{
}
@@ -60,7 +60,7 @@ OpenSearchEngine *OpenSearchReader::read(QIODevice *device)
{
clear();
- if (!device->isOpen())
+ if(!device->isOpen())
{
device->open(QIODevice::ReadOnly);
}
@@ -74,56 +74,56 @@ OpenSearchEngine *OpenSearchReader::read()
{
OpenSearchEngine *engine = new OpenSearchEngine();
- while (!isStartElement() && !atEnd())
+ while(!isStartElement() && !atEnd())
{
readNext();
}
- if (name() != QL1S("OpenSearchDescription")
+ if(name() != QL1S("OpenSearchDescription")
|| namespaceUri() != QL1S("http://a9.com/-/spec/opensearch/1.1/")
- )
+ )
{
raiseError(i18n("The file is not an OpenSearch 1.1 file."));
return engine;
}
- while (!(isEndElement() && name() == QL1S("OpenSearchDescription")) && !atEnd())
+ while(!(isEndElement() && name() == QL1S("OpenSearchDescription")) && !atEnd())
{
readNext();
- if (!isStartElement())
+ if(!isStartElement())
continue;
// ShortName
- if (name() == QL1S("ShortName"))
+ if(name() == QL1S("ShortName"))
{
engine->setName(readElementText());
continue;
}
// Description
- if (name() == QL1S("Description"))
+ if(name() == QL1S("Description"))
{
engine->setDescription(readElementText());
continue;
}
// Url
- if (name() == QL1S("Url"))
+ if(name() == QL1S("Url"))
{
QString type = attributes().value(QL1S("type")).toString();
QString url = attributes().value(QL1S("template")).toString();
- if (url.isEmpty())
+ if(url.isEmpty())
continue;
QList<OpenSearchEngine::Parameter> parameters;
readNext();
- while (!(isEndElement() && name() == QL1S("Url")))
+ while(!(isEndElement() && name() == QL1S("Url")))
{
- if (!isStartElement()
+ if(!isStartElement()
|| (name() != QL1S("Param")
&& name() != QL1S("Parameter")))
{
@@ -134,32 +134,32 @@ OpenSearchEngine *OpenSearchReader::read()
QString key = attributes().value(QL1S("name")).toString();
QString value = attributes().value(QL1S("value")).toString();
- if (!key.isEmpty() && !value.isEmpty())
+ if(!key.isEmpty() && !value.isEmpty())
{
parameters.append(OpenSearchEngine::Parameter(key, value));
}
- while (!isEndElement())
+ while(!isEndElement())
{
readNext();
}
}
- if (type == QL1S("text/html"))
+ if(type == QL1S("text/html"))
{
engine->setSearchUrlTemplate(url);
engine->setSearchParameters(parameters);
}
else
{
- if (engine->suggestionsUrlTemplate().isEmpty()
+ if(engine->suggestionsUrlTemplate().isEmpty()
&& type == QL1S("application/x-suggestions+json")) //note: xml is preferred
{
engine->setSuggestionsUrlTemplate(url);
engine->setSuggestionsParameters(parameters);
engine->setSuggestionParser(new JSONParser());
}
- else if (type == QL1S("application/x-suggestions+xml"))
+ else if(type == QL1S("application/x-suggestions+xml"))
{
engine->setSuggestionsUrlTemplate(url);
engine->setSuggestionsParameters(parameters);
@@ -171,19 +171,19 @@ OpenSearchEngine *OpenSearchReader::read()
}
// Image
- if (name() == QL1S("Image"))
+ if(name() == QL1S("Image"))
{
engine->setImageUrl(readElementText());
continue;
}
// Engine check
- if (!engine->name().isEmpty()
+ if(!engine->name().isEmpty()
&& !engine->description().isEmpty()
&& !engine->suggestionsUrlTemplate().isEmpty()
&& !engine->searchUrlTemplate().isEmpty()
&& !engine->imageUrl().isEmpty()
- )
+ )
{
break;
}
diff --git a/src/opensearch/opensearchwriter.cpp b/src/opensearch/opensearchwriter.cpp
index d1464275..d6a34f54 100644
--- a/src/opensearch/opensearchwriter.cpp
+++ b/src/opensearch/opensearchwriter.cpp
@@ -37,7 +37,7 @@
OpenSearchWriter::OpenSearchWriter()
- : QXmlStreamWriter()
+ : QXmlStreamWriter()
{
setAutoFormatting(true);
}
@@ -45,10 +45,10 @@ OpenSearchWriter::OpenSearchWriter()
bool OpenSearchWriter::write(QIODevice *device, OpenSearchEngine *engine)
{
- if (!engine)
+ if(!engine)
return false;
- if (!device->isOpen())
+ if(!device->isOpen())
device->open(QIODevice::WriteOnly);
setDevice(device);
@@ -63,29 +63,29 @@ void OpenSearchWriter::write(OpenSearchEngine *engine)
writeStartElement(QL1S("OpenSearchDescription"));
writeDefaultNamespace(QL1S("http://a9.com/-/spec/opensearch/1.1/"));
- if (!engine->name().isEmpty())
+ if(!engine->name().isEmpty())
{
writeTextElement(QL1S("ShortName"), engine->name());
}
- if (!engine->description().isEmpty())
+ if(!engine->description().isEmpty())
{
writeTextElement(QL1S("Description"), engine->description());
}
- if (!engine->searchUrlTemplate().isEmpty())
+ if(!engine->searchUrlTemplate().isEmpty())
{
writeStartElement(QL1S("Url"));
writeAttribute(QL1S("method"), QL1S("get"));
writeAttribute(QL1S("template"), engine->searchUrlTemplate());
- if (!engine->searchParameters().empty())
+ if(!engine->searchParameters().empty())
{
writeNamespace(QL1S("http://a9.com/-/spec/opensearch/extensions/parameters/1.0/"), QL1S("p"));
QList<OpenSearchEngine::Parameter>::const_iterator end = engine->searchParameters().constEnd();
QList<OpenSearchEngine::Parameter>::const_iterator i = engine->searchParameters().constBegin();
- for (; i != end; ++i)
+ for(; i != end; ++i)
{
writeStartElement(QL1S("p:Parameter"));
writeAttribute(QL1S("name"), i->first);
@@ -97,20 +97,20 @@ void OpenSearchWriter::write(OpenSearchEngine *engine)
writeEndElement();
}
- if (!engine->suggestionsUrlTemplate().isEmpty())
+ if(!engine->suggestionsUrlTemplate().isEmpty())
{
writeStartElement(QL1S("Url"));
writeAttribute(QL1S("method"), QL1S("get"));
writeAttribute(QL1S("type"), engine->type());
writeAttribute(QL1S("template"), engine->suggestionsUrlTemplate());
- if (!engine->suggestionsParameters().empty())
+ if(!engine->suggestionsParameters().empty())
{
writeNamespace(QL1S("http://a9.com/-/spec/opensearch/extensions/parameters/1.0/"), QL1S("p"));
QList<OpenSearchEngine::Parameter>::const_iterator end = engine->suggestionsParameters().constEnd();
QList<OpenSearchEngine::Parameter>::const_iterator i = engine->suggestionsParameters().constBegin();
- for (; i != end; ++i)
+ for(; i != end; ++i)
{
writeStartElement(QL1S("p:Parameter"));
writeAttribute(QL1S("name"), i->first);
@@ -122,7 +122,7 @@ void OpenSearchWriter::write(OpenSearchEngine *engine)
writeEndElement();
}
- if (!engine->imageUrl().isEmpty())
+ if(!engine->imageUrl().isEmpty())
writeTextElement(QL1S("Image"), engine->imageUrl());
writeEndElement();
diff --git a/src/opensearch/searchengine.cpp b/src/opensearch/searchengine.cpp
index 974bcc77..09eb5891 100644
--- a/src/opensearch/searchengine.cpp
+++ b/src/opensearch/searchengine.cpp
@@ -61,10 +61,10 @@ void SearchEngine::reload()
favoriteEngines = cg.readEntry("FavoriteSearchEngines", favoriteEngines);
KService::List favorites;
KService::Ptr service;
- Q_FOREACH(const QString &engine, favoriteEngines)
+ Q_FOREACH(const QString & engine, favoriteEngines)
{
service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(engine));
- if (service)
+ if(service)
{
QUrl url = service->property("Query").toUrl();
kDebug() << "ENGINE URL: " << url;
@@ -85,7 +85,7 @@ void SearchEngine::reload()
QString SearchEngine::delimiter()
{
- if (!d->isLoaded)
+ if(!d->isLoaded)
reload();
return d->delimiter;
@@ -94,7 +94,7 @@ QString SearchEngine::delimiter()
KService::List SearchEngine::favorites()
{
- if (!d->isLoaded)
+ if(!d->isLoaded)
reload();
return d->favorites;
@@ -103,7 +103,7 @@ KService::List SearchEngine::favorites()
KService::Ptr SearchEngine::defaultEngine()
{
- if (!d->isLoaded)
+ if(!d->isLoaded)
reload();
return d->defaultEngine;
@@ -116,13 +116,13 @@ KService::Ptr SearchEngine::fromString(const QString &text)
int i = 0;
bool found = false;
KService::Ptr service;
- while (!found && i < providers.size())
+ while(!found && i < providers.size())
{
QStringList list = providers.at(i)->property("Keys").toStringList();
- Q_FOREACH(const QString &key, list)
+ Q_FOREACH(const QString & key, list)
{
const QString searchPrefix = key + delimiter();
- if (text.startsWith(searchPrefix))
+ if(text.startsWith(searchPrefix))
{
service = providers.at(i);
found = true;
@@ -137,7 +137,7 @@ KService::Ptr SearchEngine::fromString(const QString &text)
QString SearchEngine::buildQuery(KService::Ptr engine, const QString &text)
{
- if (!engine)
+ if(!engine)
return QString();
QString query = engine->property("Query").toString();
query = query.replace("\\{@}", KUrl::toPercentEncoding(text));
diff --git a/src/opensearch/suggestionparser.cpp b/src/opensearch/suggestionparser.cpp
index a6619441..0e390d99 100644
--- a/src/opensearch/suggestionparser.cpp
+++ b/src/opensearch/suggestionparser.cpp
@@ -51,14 +51,14 @@ ResponseList XMLParser::parse(const QByteArray &resp)
m_reader.clear();
m_reader.addData(resp);
- while (!m_reader.atEnd() && !m_reader.hasError())
+ while(!m_reader.atEnd() && !m_reader.hasError())
{
m_reader.readNext();
- if (m_reader.isStartDocument())
+ if(m_reader.isStartDocument())
continue;
- if (m_reader.isStartElement() && m_reader.name() == QL1S("Item"))
+ if(m_reader.isStartElement() && m_reader.name() == QL1S("Item"))
{
QString title;
QString description;
@@ -69,24 +69,24 @@ ResponseList XMLParser::parse(const QByteArray &resp)
m_reader.readNext();
- while (!(m_reader.isEndElement() && m_reader.name() == QL1S("Item")))
+ while(!(m_reader.isEndElement() && m_reader.name() == QL1S("Item")))
{
- if (m_reader.isStartElement())
+ if(m_reader.isStartElement())
{
- if (m_reader.name() == QL1S("Text"))
+ if(m_reader.name() == QL1S("Text"))
title = m_reader.readElementText();
- if (m_reader.name() == QL1S("Url"))
+ if(m_reader.name() == QL1S("Url"))
url = m_reader.readElementText();
- if (m_reader.name() == QL1S("Image"))
+ if(m_reader.name() == QL1S("Image"))
{
image = m_reader.attributes().value("source").toString();
image_width = m_reader.attributes().value("width").toString().toInt();
image_height = m_reader.attributes().value("height").toString().toInt();
}
- if (m_reader.name() == QL1S("Description"))
+ if(m_reader.name() == QL1S("Description"))
description = m_reader.readElementText();
}
@@ -105,22 +105,22 @@ ResponseList JSONParser::parse(const QByteArray &resp)
QString response = QString::fromLocal8Bit(resp);
response = response.trimmed();
- if (response.isEmpty())
+ if(response.isEmpty())
{
kDebug() << "RESPONSE IS EMPTY";
return ResponseList();
}
- if (!response.startsWith(QL1C('['))
+ if(!response.startsWith(QL1C('['))
|| !response.endsWith(QL1C(']'))
- )
+ )
{
kDebug() << "RESPONSE is NOT well FORMED";
return ResponseList();
}
// Evaluate the JSON response using QtScript.
- if (!m_reader.canEvaluate(response))
+ if(!m_reader.canEvaluate(response))
{
kDebug() << "m_reader cannot evaluate the response";
return ResponseList();
@@ -128,7 +128,7 @@ ResponseList JSONParser::parse(const QByteArray &resp)
QScriptValue responseParts = m_reader.evaluate(response);
- if (!responseParts.property(1).isArray())
+ if(!responseParts.property(1).isArray())
{
kDebug() << "RESPONSE is not an array";
return ResponseList();
@@ -138,7 +138,7 @@ ResponseList JSONParser::parse(const QByteArray &resp)
QStringList responsePartsList;
qScriptValueToSequence(responseParts.property(1), responsePartsList);
- Q_FOREACH(const QString &s, responsePartsList)
+ Q_FOREACH(const QString & s, responsePartsList)
{
rlist << Response(s);
}
diff --git a/src/opensearch/suggestionparser.h b/src/opensearch/suggestionparser.h
index f96061c7..523a4e6f 100644
--- a/src/opensearch/suggestionparser.h
+++ b/src/opensearch/suggestionparser.h
@@ -50,20 +50,20 @@ public:
int image_height;
Response(const Response &item) : title(item.title),
- description(item.description),
- url(item.url),
- image(item.image),
- image_width(item.image_width),
- image_height(item.image_height)
+ description(item.description),
+ url(item.url),
+ image(item.image),
+ image_width(item.image_width),
+ image_height(item.image_height)
{};
Response() : title(QString()),
- description(QString()),
- url(QString()),
- image(QString()),
- image_width(0),
- image_height(0)
+ description(QString()),
+ url(QString()),
+ image(QString()),
+ image_width(0),
+ image_height(0)
{};
@@ -73,11 +73,11 @@ public:
const QString &_image = QString(),
const int &_image_width = 0,
const int &_image_height = 0) : title(_title),
- description(_description),
- url(_url),
- image(_image),
- image_width(_image_width),
- image_height(_image_height)
+ description(_description),
+ url(_url),
+ image(_image),
+ image_width(_image_width),
+ image_height(_image_height)
{};
};