summaryrefslogtreecommitdiff
path: root/src/urlbar/completionwidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/urlbar/completionwidget.cpp')
-rw-r--r--src/urlbar/completionwidget.cpp37
1 files changed, 10 insertions, 27 deletions
diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp
index c1f5d83b..12d34ad8 100644
--- a/src/urlbar/completionwidget.cpp
+++ b/src/urlbar/completionwidget.cpp
@@ -56,8 +56,7 @@ CompletionWidget::CompletionWidget(QWidget *parent)
, _parent(parent)
, _currentIndex(0)
, _searchEngine(SearchEngine::defaultEngine())
- , _suggestionsNumber(0)
- , _isSuggesting(false)
+ , _hasSuggestions(false)
{
setFrameStyle(QFrame::Panel);
setLayoutDirection(Qt::LeftToRight);
@@ -95,44 +94,29 @@ void CompletionWidget::insertSearchList(const UrlSearchList &list, const QString
void CompletionWidget::updateSearchList(const UrlSearchList &list, const QString& text)
{
- kDebug() << "TYPED STRING: " << _typedString;
- kDebug() << "text from suggestion: " << text;
-
- if(_isSuggesting || !isVisible() || _typedString != text)
+ if(_hasSuggestions || _typedString != text || !isVisible())
return;
+ _hasSuggestions = true;
- _isSuggesting = true;
-
- // clean up eventual old suggestions
- if(_suggestionsNumber > 0)
- {
- int offset = _list.count();
- for(int i = offset; i < offset + _suggestionsNumber; ++i)
- {
- QLayoutItem *item = layout()->takeAt( i );
- delete item;
- }
- }
+ UrlSearchList sugList = list.mid(0,4);
// add new suggestions to the list
- int i = _list.count();
- Q_FOREACH(const UrlSearchItem &item, list)
+ int offset = _list.count();
+ Q_FOREACH(const UrlSearchItem &item, sugList)
{
ListItem *suggestion = ListItemFactory::create(item, text, this);
- suggestion->setBackgroundRole(i % 2 ? QPalette::AlternateBase : QPalette::Base);
+ suggestion->setBackgroundRole(offset % 2 ? QPalette::AlternateBase : QPalette::Base);
connect(suggestion,
SIGNAL(itemClicked(ListItem *, Qt::MouseButton, Qt::KeyboardModifiers)),
this,
SLOT(itemChosen(ListItem *, Qt::MouseButton, Qt::KeyboardModifiers)));
connect(this, SIGNAL(nextItemSubChoice()), suggestion, SLOT(nextItemSubChoice()));
- suggestion->setObjectName(QString::number(i++));
+ suggestion->setObjectName(QString::number(offset++));
layout()->addWidget(suggestion);
}
- _suggestionsNumber = list.count();
- _list.append(list);
+ _list.append(sugList);
sizeAndPosition();
- _isSuggesting = false;
}
@@ -192,8 +176,6 @@ void CompletionWidget::down()
void CompletionWidget::activateCurrentListItem()
{
- kDebug() << _currentIndex;
- kDebug() << _typedString;
UrlBar *bar = qobject_cast<UrlBar *>(_parent);
// activate "new" current
@@ -218,6 +200,7 @@ void CompletionWidget::clear()
delete child;
}
_currentIndex = 0;
+ _hasSuggestions = false;
}