summaryrefslogtreecommitdiff
path: root/src/urlbar
diff options
context:
space:
mode:
Diffstat (limited to 'src/urlbar')
-rw-r--r--src/urlbar/completionwidget.cpp23
-rw-r--r--src/urlbar/listitem.cpp9
2 files changed, 15 insertions, 17 deletions
diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp
index 0733b1f0..311694b3 100644
--- a/src/urlbar/completionwidget.cpp
+++ b/src/urlbar/completionwidget.cpp
@@ -50,45 +50,36 @@ CompletionWidget::CompletionWidget( QWidget *parent)
, _parent(parent)
, _currentIndex(-1)
{
- QPalette p(palette());
- p.setColor(QPalette::Background, Qt::white); // TODO: choose the correct color
- setPalette(p);
setFrameStyle(QFrame::Panel);
setLayoutDirection(Qt::LeftToRight);
QVBoxLayout *layout = new QVBoxLayout;
layout->setMargin(0);
+ layout->setSpacing(0);
setLayout(layout);
-
}
void CompletionWidget::insertSearchList(const UrlSearchList &list)
{
_list = list;
- int i=0;
+ int i = 0;
foreach(UrlSearchItem item, _list)
{
ListItem *suggestion = new ListItem(item);
+ suggestion->setBackgroundRole(i%2 ? QPalette::AlternateBase : QPalette::Base);
connect(suggestion, SIGNAL(itemClicked(ListItem *, Qt::MouseButton)), this, SLOT(itemChosen(ListItem *, Qt::MouseButton)));
- suggestion->setObjectName( QString::number(i++) );
+ suggestion->setObjectName( QString::number(i) );
layout()->addWidget( suggestion );
+ i++;
}
}
void CompletionWidget::sizeAndPosition()
{
- // size
- int h = 34;
- ListItem *widget;
- for(int i = 0; i < layout()->count(); ++i)
- {
- widget = findChild<ListItem *>( QString::number(i) );
- h = qMax(widget->sizeHint().height(), h);
- }
- setFixedHeight(layout()->count() * (h + 10) );
setFixedWidth( _parent->width() );
-
+ adjustSize();
+
// position
QPoint p = _parent->mapToGlobal( QPoint(0,0) );
move(p.x(), p.y() + _parent->height());
diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp
index 91af352b..61a739f8 100644
--- a/src/urlbar/listitem.cpp
+++ b/src/urlbar/listitem.cpp
@@ -51,7 +51,14 @@
ListItem::ListItem(const UrlSearchItem &item, QWidget *parent)
: QWidget(parent)
{
- //preview and icon
+ setAutoFillBackground(true);
+
+ QPalette p = palette();
+ p.setColor(QPalette::Base, Qt::white); // TODO: choose the correct color
+ p.setColor(QPalette::AlternateBase, QColor(247,247,247)); // TODO: choose the correct color
+ setPalette(p);
+
+ // ----------------------------------------
QHBoxLayout *hLayout = new QHBoxLayout;