diff options
Diffstat (limited to 'src/urlbar')
-rw-r--r-- | src/urlbar/listitem.cpp | 36 | ||||
-rw-r--r-- | src/urlbar/listitem.h | 20 | ||||
-rw-r--r-- | src/urlbar/urlresolver.cpp | 4 |
3 files changed, 58 insertions, 2 deletions
diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp index 374d9cca..219c7072 100644 --- a/src/urlbar/listitem.cpp +++ b/src/urlbar/listitem.cpp @@ -42,6 +42,8 @@ // KDE Includes #include <KIcon> #include <KAction> +#include <kio/jobclasses.h> +#include <kio/scheduler.h> // Qt Includes #include <QActionGroup> @@ -329,6 +331,36 @@ PreviewLabel::PreviewLabel(const QString &url, int width, int height, QWidget *p } } +// --------------------------------------------------------------- + + +ImageLabel::ImageLabel(const QString &url, int width, int height, QWidget *parent) + : QLabel(parent), + m_width(width), + m_height(height) +{ + setFixedSize(width, height); + KIO::TransferJob *job = KIO::get(KUrl(url), KIO::NoReload, KIO::HideProgressInfo); + connect(job, SIGNAL(data(KIO::Job *, const QByteArray &)), + this, SLOT(slotData(KIO::Job*, const QByteArray&))); + connect(job, SIGNAL(result(KJob *)), + this, SLOT(slotResult(KJob *))); +} + + +void ImageLabel::slotData(KIO::Job *job, const QByteArray &data) +{ + Q_UNUSED(job); + m_data.append(data); +} + +void ImageLabel::slotResult(KJob *job) +{ + QPixmap pix; + if (!pix.loadFromData(m_data)) + kDebug() << "error while loading image: "; + setPixmap(pix.scaled(m_width, m_height, Qt::KeepAspectRatio, Qt::SmoothTransformation)); +} // --------------------------------------------------------------- @@ -491,7 +523,7 @@ VisualSuggestionListItem::VisualSuggestionListItem(const UrlSearchItem &item, co QLabel *previewLabelIcon = new QLabel(this); previewLabelIcon->setFixedSize(45, 33); - new PreviewLabel(item.image, 38, 29, previewLabelIcon); + new ImageLabel(item.image, 38, 29, previewLabelIcon); IconLabel* icon = new IconLabel(item.url, previewLabelIcon); icon->move(27, 16); hLayout->addWidget(previewLabelIcon); @@ -501,7 +533,7 @@ VisualSuggestionListItem::VisualSuggestionListItem(const UrlSearchItem &item, co QString query = SearchEngine::extractQuery(text); vLayout->addWidget(new TextLabel(item.title, query, this)); - vLayout->addWidget(new TextLabel("aaa aa", query, this)); + vLayout->addWidget(new TextLabel("<i>"+item.description+"</i>", query, this)); hLayout->addLayout(vLayout); diff --git a/src/urlbar/listitem.h b/src/urlbar/listitem.h index c662bc24..ab12917a 100644 --- a/src/urlbar/listitem.h +++ b/src/urlbar/listitem.h @@ -234,6 +234,26 @@ public: // ------------------------------------------------------------------------- +class ImageLabel : public QLabel +{ + Q_OBJECT + +public: + ImageLabel(const QString &url, int width, int height, QWidget *parent); + +private: + int m_width; + int m_height; + QByteArray m_data; + +private slots: + void slotData(KIO::Job* job, const QByteArray& data); + void slotResult(KJob* job); +}; + + +// ------------------------------------------------------------------------- + class BrowseListItem : public ListItem { diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp index a7c63969..7429adce 100644 --- a/src/urlbar/urlresolver.cpp +++ b/src/urlbar/urlresolver.cpp @@ -409,10 +409,14 @@ void UrlResolver::suggestionsReceived(const QString &text, const ResponseList &s Q_FOREACH(const Response &i, suggestions) { <<<<<<< HEAD +<<<<<<< HEAD UrlSearchItem gItem(UrlSearchItem::Suggestion, SearchEngine::buildQuery(UrlResolver::searchEngine(), s), s); ======= UrlSearchItem gItem(UrlSearchItem::Suggestion, i.title, i.title); >>>>>>> add an xml parser to the opensearch engine. +======= + UrlSearchItem gItem(UrlSearchItem::Suggestion, i.url, i.title, i.image, i.description); +>>>>>>> Images in visual suggestion are now displayed !! sugList << gItem; } emit suggestionsReady(sugList, _typedString); |