summaryrefslogtreecommitdiff
path: root/src/urlbar/listitem.cpp
diff options
context:
space:
mode:
authorlionelc <lionelc@lionelc.(none)>2010-04-01 19:53:18 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-04-02 22:01:33 +0200
commitb18f2e5dfcc17615d73fdbd20cb4e312ea83dfaf (patch)
tree00fb0c3437445658a7eec270b0d5c24ff8e1e22a /src/urlbar/listitem.cpp
parentmanage common item of bookmarks and history (diff)
downloadrekonq-b18f2e5dfcc17615d73fdbd20cb4e312ea83dfaf.tar.xz
multiple icons for type of items
display icon of website
Diffstat (limited to 'src/urlbar/listitem.cpp')
-rw-r--r--src/urlbar/listitem.cpp80
1 files changed, 60 insertions, 20 deletions
diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp
index ee63a156..959db360 100644
--- a/src/urlbar/listitem.cpp
+++ b/src/urlbar/listitem.cpp
@@ -45,32 +45,52 @@
#include <QStylePainter>
#include <QFile>
#include <QMouseEvent>
+#include <QWebSettings>
ListItem::ListItem(const UrlSearchItem &item, QWidget *parent)
: QWidget(parent)
, m_option()
{
+ //preview and icon
+
QHBoxLayout *hLayout = new QHBoxLayout;
- QVBoxLayout *vLayout = new QVBoxLayout;
+
+ QLabel *previewLabelIcon = new QLabel;
+ previewLabelIcon->setFixedSize(45,33);
+ hLayout->addWidget(previewLabelIcon);
- QLabel *previewLabel = new QLabel;
- previewLabel->setFixedSize(40,30);
- QPixmap preview;
+ QPixmap pixmapIcon = KIcon(QWebSettings::iconForUrl(item.url)).pixmap(16);
QString path = KStandardDirs::locateLocal("cache", QString("thumbs/") + guessNameFromUrl(item.url) + ".png", true);
if(QFile::exists(path))
{
+ QLabel *previewLabel = new QLabel(previewLabelIcon);
+ previewLabel->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
+ QPixmap preview;
preview.load(path);
- previewLabel->setPixmap(preview.scaled(40,30));
- }
- else
+ if (!pixmapIcon.isNull())
+ {
+ previewLabel->setFixedSize(38,29);
+ previewLabel->setPixmap(preview.scaled(38,29, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
+ }
+ else
+ {
+ previewLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ previewLabel->setFixedSize(45,33);
+ previewLabel->setPixmap(preview.scaled(45,33, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
+ }
+ }
+
+ if (!pixmapIcon.isNull())
{
- if(item.icon.startsWith( QLatin1String("http://") ) )
- preview = Application::icon( item.icon ).pixmap(22);
+ QLabel *iconLabel = new QLabel(previewLabelIcon);
+ iconLabel->setPixmap(pixmapIcon);
+ iconLabel->move(27, 16);
}
- previewLabel->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
- hLayout->addWidget(previewLabel);
+ //title and url
+
+ QVBoxLayout *vLayout = new QVBoxLayout;
hLayout->addLayout(vLayout);
QLabel *titleLabel = new QLabel("<b>" + item.title + "</b>");
@@ -82,17 +102,27 @@ ListItem::ListItem(const UrlSearchItem &item, QWidget *parent)
vLayout->addWidget(titleLabel);
vLayout->addWidget(urlLabel);
+ //type icon
- QLabel *iconLabel = new QLabel;
- QPixmap pixmap;
- if(item.icon.startsWith( QLatin1String("http://") ) )
- pixmap = Application::icon( item.icon ).pixmap(18);
- else
- pixmap = KIcon(item.icon).pixmap(18);
+ if (item.type & UrlSearchItem::Browse)
+ {
+ insertIcon(hLayout, "applications-internet");
+ }
+
+ if (item.type & UrlSearchItem::Search)
+ {
+ insertIcon(hLayout, "edit-find");
+ }
+
+ if (item.type & UrlSearchItem::Bookmark)
+ {
+ insertIcon(hLayout, "rating");
+ }
- iconLabel->setPixmap(pixmap);
- iconLabel->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
- hLayout->addWidget(iconLabel);
+ if (item.type & UrlSearchItem::History)
+ {
+ insertIcon(hLayout, "view-history");
+ }
setLayout(hLayout);
@@ -109,6 +139,16 @@ ListItem::~ListItem()
}
+void ListItem::insertIcon(QLayout *layout, QString icon)
+{
+ QLabel *iconLabel = new QLabel;
+ QPixmap pixmap = KIcon(icon).pixmap(18);
+ iconLabel->setPixmap(pixmap);
+ iconLabel->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
+ layout->addWidget(iconLabel);
+}
+
+
//TODO: REMOVE DUPLICATE CODE WITH PREVIEWIMAGE
QString ListItem::guessNameFromUrl(QUrl url)
{