summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/opensearch/opensearchengine.cpp6
-rw-r--r--src/opensearch/opensearchengine.h5
-rw-r--r--src/opensearch/opensearchmanager.cpp2
-rw-r--r--src/opensearch/opensearchmanager.h6
-rw-r--r--src/opensearch/opensearchreader.cpp15
-rw-r--r--src/opensearch/opensearchwriter.cpp4
-rw-r--r--src/opensearch/suggestionparser.cpp18
-rw-r--r--src/opensearch/suggestionparser.h22
8 files changed, 45 insertions, 33 deletions
diff --git a/src/opensearch/opensearchengine.cpp b/src/opensearch/opensearchengine.cpp
index f100bb60..9d5e866f 100644
--- a/src/opensearch/opensearchengine.cpp
+++ b/src/opensearch/opensearchengine.cpp
@@ -35,8 +35,10 @@
// Qt Includes
#include <QtCore/QRegExp>
-OpenSearchEngine::OpenSearchEngine(QObject *)
- : m_parser(0)
+
+OpenSearchEngine::OpenSearchEngine(QObject *parent)
+ : QObject(parent)
+ , m_parser(0)
{
}
diff --git a/src/opensearch/opensearchengine.h b/src/opensearch/opensearchengine.h
index 03be1212..b3965ecb 100644
--- a/src/opensearch/opensearchengine.h
+++ b/src/opensearch/opensearchengine.h
@@ -47,11 +47,12 @@
class QNetworkAccessManager;
class QNetworkReply;
-class OpenSearchEngine
+
+class OpenSearchEngine : public QObject
{
public:
typedef QPair<QString, QString> Parameter;
-
+
OpenSearchEngine(QObject *parent = 0);
~OpenSearchEngine();
diff --git a/src/opensearch/opensearchmanager.cpp b/src/opensearch/opensearchmanager.cpp
index ed8c5fc5..e5afc144 100644
--- a/src/opensearch/opensearchmanager.cpp
+++ b/src/opensearch/opensearchmanager.cpp
@@ -168,7 +168,7 @@ void OpenSearchManager::jobFinished(KJob *job)
{
const ResponseList suggestionsList = m_activeEngine->parseSuggestion(m_jobData);
kDebug() << "Received suggestions in "<< _typedText << " from " << m_activeEngine->name() << ": ";
- foreach(Response r, suggestionsList)
+ Q_FOREACH(const Response &r, suggestionsList)
{
kDebug() << r.title;
}
diff --git a/src/opensearch/opensearchmanager.h b/src/opensearch/opensearchmanager.h
index 43f11640..f935a6d7 100644
--- a/src/opensearch/opensearchmanager.h
+++ b/src/opensearch/opensearchmanager.h
@@ -79,7 +79,7 @@ public:
void addOpenSearchEngine(const KUrl &url, const QString &title);
-public slots:
+public Q_SLOTS:
/**
* Ask the specific suggestion engine to request for suggestion for the search text
*
@@ -87,11 +87,11 @@ public slots:
*/
void requestSuggestion(const QString &searchText);
-private slots:
+private Q_SLOTS:
void dataReceived(KIO::Job *job, const QByteArray &data);
void jobFinished(KJob *job);
-signals:
+Q_SIGNALS:
void suggestionReceived(const QString &text, const ResponseList &suggestion);
void openSearchEngineAdded(const QString &name, const QString &searchUrl, const QString &fileName);
diff --git a/src/opensearch/opensearchreader.cpp b/src/opensearch/opensearchreader.cpp
index ebca7877..1c106afa 100644
--- a/src/opensearch/opensearchreader.cpp
+++ b/src/opensearch/opensearchreader.cpp
@@ -34,6 +34,9 @@
#include "opensearchengine.h"
#include "suggestionparser.h"
+// KDE Includes
+#include <KLocalizedString>
+
// Qt Includes
#include <QtCore/QIODevice>
@@ -79,7 +82,7 @@ OpenSearchEngine *OpenSearchReader::read()
|| namespaceUri() != QL1S("http://a9.com/-/spec/opensearch/1.1/")
)
{
- raiseError(QObject::tr("The file is not an OpenSearch 1.1 file."));
+ raiseError(i18n("The file is not an OpenSearch 1.1 file."));
return engine;
}
@@ -119,7 +122,10 @@ OpenSearchEngine *OpenSearchReader::read()
while (!(isEndElement() && name() == QL1S("Url")))
{
- if (!isStartElement() || (name() != QL1S("Param") && name() != QL1S("Parameter"))) {
+ if (!isStartElement()
+ || (name() != QL1S("Param")
+ && name() != QL1S("Parameter")))
+ {
readNext();
continue;
}
@@ -138,14 +144,15 @@ OpenSearchEngine *OpenSearchReader::read()
}
}
- if (type == QLatin1String("text/html"))
+ if (type == QL1S("text/html"))
{
engine->setSearchUrlTemplate(url);
engine->setSearchParameters(parameters);
}
else
{
- if (engine->suggestionsUrlTemplate().isEmpty() && type == QL1S("application/x-suggestions+json")) //note: xml is prefered
+ if (engine->suggestionsUrlTemplate().isEmpty()
+ && type == QL1S("application/x-suggestions+json")) //note: xml is prefered
{
engine->setSuggestionsUrlTemplate(url);
engine->setSuggestionsParameters(parameters);
diff --git a/src/opensearch/opensearchwriter.cpp b/src/opensearch/opensearchwriter.cpp
index 00a2f0cd..1b34939f 100644
--- a/src/opensearch/opensearchwriter.cpp
+++ b/src/opensearch/opensearchwriter.cpp
@@ -32,14 +32,10 @@
// Local Includes
#include "opensearchengine.h"
-// KDE Includes
-#include <KDebug>
-
// Qt Includes
#include <QtCore/QIODevice>
-
OpenSearchWriter::OpenSearchWriter()
: QXmlStreamWriter()
{
diff --git a/src/opensearch/suggestionparser.cpp b/src/opensearch/suggestionparser.cpp
index 3b656a3f..98bb8a69 100644
--- a/src/opensearch/suggestionparser.cpp
+++ b/src/opensearch/suggestionparser.cpp
@@ -24,18 +24,15 @@
*
* ============================================================ */
-#define QL1C(x) QLatin1Char(x)
-#define QL1S(x) QLatin1String(x)
// Self Includes
#include "suggestionparser.h"
-// Local Includes
-#include<KDebug>
// Qt Includes
#include<QByteArray>
#include<QStringList>
+
ResponseList SuggestionParser::parse(const QByteArray &)
{
return ResponseList();
@@ -71,19 +68,22 @@ ResponseList XMLParser::parse(const QByteArray &resp)
m_reader.readNext();
- while(!(m_reader.isEndElement() && m_reader.name() == "Item"))
+ while( !(m_reader.isEndElement() && m_reader.name() == QL1S("Item")) )
{
if(m_reader.isStartElement())
{
- if (m_reader.name() == QL1S("Text")) title = m_reader.readElementText();
- if (m_reader.name() == QL1S("Url")) url = m_reader.readElementText();
+ if (m_reader.name() == QL1S("Text"))
+ title = m_reader.readElementText();
+ if (m_reader.name() == QL1S("Url"))
+ url = m_reader.readElementText();
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")) description = m_reader.readElementText();
+ if (m_reader.name() == QL1S("Description"))
+ description = m_reader.readElementText();
}
m_reader.readNext();
@@ -132,7 +132,7 @@ ResponseList JSONParser::parse(const QByteArray &resp)
QStringList responsePartsList;
qScriptValueToSequence(responseParts.property(1), responsePartsList);
- foreach(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 3b72c5d3..158da51f 100644
--- a/src/opensearch/suggestionparser.h
+++ b/src/opensearch/suggestionparser.h
@@ -24,19 +24,20 @@
*
* ============================================================ */
+
#ifndef SUGGESTIONPARSER_H
#define SUGGESTIONPARSER_H
-// Self Includes
-
-// Local Includes
+// Rekonq Includes
+#include "rekonq_defines.h"
// Qt Includes
-#include <QList>
-#include <QtScript/QScriptEngine>
+#include <QtCore/QList>
#include <QtCore/QXmlStreamReader>
+#include <QtScript/QScriptEngine>
+
class Response
{
@@ -80,6 +81,10 @@ public:
{};
};
+
+// -----------------------------------------------------------------
+
+
typedef QList <Response> ResponseList;
@@ -88,7 +93,7 @@ class SuggestionParser
public:
virtual ~SuggestionParser();
virtual ResponseList parse(const QByteArray &resp);
- virtual QString type(){ return ""; }
+ virtual QString type() = 0;
};
@@ -99,9 +104,10 @@ protected:
public:
ResponseList parse(const QByteArray &resp);
- QString type(){ return "application/x-suggestions+xml"; }
+ inline QString type() { return QL1S("application/x-suggestions+xml"); }
};
+
class JSONParser : public SuggestionParser
{
private:
@@ -109,7 +115,7 @@ private:
public:
ResponseList parse(const QByteArray &resp);
- QString type(){ return "application/x-suggestions+json"; }
+ inline QString type() { return QL1S("application/x-suggestions+json"); }
};
#endif //SUGGESTIONPARSER_H