summaryrefslogtreecommitdiff
path: root/src/opensearch/suggestionparser.cpp
diff options
context:
space:
mode:
authorLionel Chauvin <megabigbug@yahoo.fr>2010-10-10 11:47:14 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-10-30 11:41:25 +0200
commit7160eeb650855a207b271d8399e6f7ede96a5011 (patch)
treebb9e6aa69870b281d50d522ce6329435fa2177a4 /src/opensearch/suggestionparser.cpp
parentintroduce visual suggestion listitem (diff)
downloadrekonq-7160eeb650855a207b271d8399e6f7ede96a5011.tar.xz
Images in visual suggestion are now displayed !!
Diffstat (limited to 'src/opensearch/suggestionparser.cpp')
-rw-r--r--src/opensearch/suggestionparser.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/opensearch/suggestionparser.cpp b/src/opensearch/suggestionparser.cpp
index 01581bf9..02f99644 100644
--- a/src/opensearch/suggestionparser.cpp
+++ b/src/opensearch/suggestionparser.cpp
@@ -53,38 +53,38 @@ ResponseList XMLParser::parse(const QByteArray &resp)
m_reader.clear();
m_reader.addData(resp);
-
- while (!m_reader.isStartElement() && !m_reader.atEnd())
- {
- m_reader.readNext();
- }
- while (!(m_reader.isEndElement() && m_reader.name() == QL1S("SearchSuggestion")) && !m_reader.atEnd())
+ while (!m_reader.atEnd() && !m_reader.hasError())
{
- m_reader.readNext();
-
- if (!m_reader.isStartElement())
- continue;
+ QXmlStreamReader::TokenType token = m_reader.readNext();
+
+ if (m_reader.isStartDocument()) continue;
- if (m_reader.name() == QL1S("Item"))
+ if (m_reader.isStartElement() && m_reader.name() == QL1S("Item"))
{
QString title;
QString url;
QString image;
QString description;
- while (!m_reader.isEndElement() && !m_reader.atEnd())
+ m_reader.readNext();
+
+ while(!(m_reader.isEndElement() && m_reader.name() == "Item"))
{
- m_reader.readNext();
+ 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("Image")) image = m_reader.attributes().value("source").toString();
+ if (m_reader.name() == QL1S("Description")) description = 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.readElementText();
- if (m_reader.name() == QL1S("Description")) description = m_reader.readElementText();
+ m_reader.readNext();
}
-
rlist << Response(url, title, image, description);
}
+
+ m_reader.readNext();
}
return rlist;
@@ -124,7 +124,7 @@ ResponseList JSONParser::parse(const QByteArray &resp)
ResponseList rlist;
QStringList responsePartsList;
qScriptValueToSequence(responseParts.property(1), responsePartsList);
-
+
foreach(QString s, responsePartsList)
{
rlist << Response(QString(), s, QString());