From ab7549c7fe58b7375b527f10291dc3ca454dd9e0 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 31 Oct 2010 09:47:09 +0100 Subject: Fix merge code --- src/opensearch/opensearchengine.cpp | 6 ++++-- src/opensearch/opensearchengine.h | 5 +++-- src/opensearch/opensearchmanager.cpp | 2 +- src/opensearch/opensearchmanager.h | 6 +++--- src/opensearch/opensearchreader.cpp | 15 +++++++++++---- src/opensearch/opensearchwriter.cpp | 4 ---- src/opensearch/suggestionparser.cpp | 18 +++++++++--------- src/opensearch/suggestionparser.h | 22 ++++++++++++++-------- 8 files changed, 45 insertions(+), 33 deletions(-) (limited to 'src') 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 -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 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 + // Qt Includes #include @@ -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 - // Qt Includes #include - 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 // Qt Includes #include #include + 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 -#include +#include #include +#include + class Response { @@ -80,6 +81,10 @@ public: {}; }; + +// ----------------------------------------------------------------- + + typedef QList 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 -- cgit v1.2.1