diff options
author | Lionel Chauvin <megabigbug@yahoo.fr> | 2010-10-10 11:47:14 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2010-10-30 11:41:25 +0200 |
commit | 7160eeb650855a207b271d8399e6f7ede96a5011 (patch) | |
tree | bb9e6aa69870b281d50d522ce6329435fa2177a4 /src/opensearch/suggestionparser.cpp | |
parent | introduce visual suggestion listitem (diff) | |
download | rekonq-7160eeb650855a207b271d8399e6f7ede96a5011.tar.xz |
Images in visual suggestion are now displayed !!
Diffstat (limited to 'src/opensearch/suggestionparser.cpp')
-rw-r--r-- | src/opensearch/suggestionparser.cpp | 38 |
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()); |