summaryrefslogtreecommitdiff
path: root/src/opensearch
diff options
context:
space:
mode:
authorLionel Chauvin <megabigbug@yahoo.fr>2010-10-10 19:59:11 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-10-30 11:43:03 +0200
commitd3718562fa556d67f715f542034a5870eccb8c3f (patch)
tree6f6328208e1f866ff96d4f174b08d63bbc7eff32 /src/opensearch
parentImages in visual suggestion are now displayed !! (diff)
downloadrekonq-d3718562fa556d67f715f542034a5870eccb8c3f.tar.xz
improve layout of visual suggestions
Diffstat (limited to 'src/opensearch')
-rw-r--r--src/opensearch/suggestionparser.cpp15
-rw-r--r--src/opensearch/suggestionparser.h42
2 files changed, 38 insertions, 19 deletions
diff --git a/src/opensearch/suggestionparser.cpp b/src/opensearch/suggestionparser.cpp
index 02f99644..8f0e7ba2 100644
--- a/src/opensearch/suggestionparser.cpp
+++ b/src/opensearch/suggestionparser.cpp
@@ -63,9 +63,11 @@ ResponseList XMLParser::parse(const QByteArray &resp)
if (m_reader.isStartElement() && m_reader.name() == QL1S("Item"))
{
QString title;
+ QString description;
QString url;
QString image;
- QString description;
+ int image_width=0;
+ int image_height=0;
m_reader.readNext();
@@ -75,13 +77,18 @@ ResponseList XMLParser::parse(const QByteArray &resp)
{
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("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();
}
m_reader.readNext();
}
- rlist << Response(url, title, image, description);
+ rlist << Response(title, description, url, image, image_width, image_height);
}
m_reader.readNext();
@@ -127,7 +134,7 @@ ResponseList JSONParser::parse(const QByteArray &resp)
foreach(QString s, responsePartsList)
{
- rlist << Response(QString(), s, QString());
+ rlist << Response(s);
}
return rlist;
diff --git a/src/opensearch/suggestionparser.h b/src/opensearch/suggestionparser.h
index e59a092c..59c788b1 100644
--- a/src/opensearch/suggestionparser.h
+++ b/src/opensearch/suggestionparser.h
@@ -41,30 +41,42 @@
class Response
{
public:
- QString url;
QString title;
- QString image;
QString description;
-
- Response(const Response &item) : url(item.url),
- title(item.title),
+ QString url;
+ QString image;
+ int image_width;
+ int image_height;
+
+ Response(const Response &item) : title(item.title),
+ description(item.description),
+ url(item.url),
image(item.image),
- description(item.description)
+ image_width(item.image_width),
+ image_height(item.image_height)
+
{};
- Response() : url(QString()),
- title(QString()),
+ Response() : title(QString()),
+ description(QString()),
+ url(QString()),
image(QString()),
- description(QString())
+ image_width(0),
+ image_height(0)
+
{};
- Response(const QString &_url,
- const QString &_title = QString(),
+ Response(const QString &_title = QString(),
+ const QString &_description = QString(),
+ const QString &_url = QString(),
const QString &_image = QString(),
- const QString &description = QString()) : url(_url),
- title(_title),
- image(_image),
- description(description)
+ 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)
{};
};