summaryrefslogtreecommitdiff
path: root/src/urlbar/completionwidget.cpp
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-08-30 17:29:01 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-08-30 17:29:01 +0200
commitd9926d60f2cd5ab66ae968eeb50634c5feab025c (patch)
tree5b82b26e6077e80aef34149037f0bc6a3ce13116 /src/urlbar/completionwidget.cpp
parentabout url detection fix (diff)
downloadrekonq-d9926d60f2cd5ab66ae968eeb50634c5feab025c.tar.xz
Fix adding suggestions to not let completion widget "flicker"
Diffstat (limited to 'src/urlbar/completionwidget.cpp')
-rw-r--r--src/urlbar/completionwidget.cpp54
1 files changed, 29 insertions, 25 deletions
diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp
index 12d34ad8..2199dfdf 100644
--- a/src/urlbar/completionwidget.cpp
+++ b/src/urlbar/completionwidget.cpp
@@ -94,29 +94,38 @@ void CompletionWidget::insertSearchList(const UrlSearchList &list, const QString
void CompletionWidget::updateSearchList(const UrlSearchList &list, const QString& text)
{
- if(_hasSuggestions || _typedString != text || !isVisible())
+ static int counter = 0;
+ counter++;
+ kDebug() << counter;
+ if(_hasSuggestions || _typedString != text)
return;
_hasSuggestions = true;
- UrlSearchList sugList = list.mid(0,4);
-
- // add new suggestions to the list
- int offset = _list.count();
- Q_FOREACH(const UrlSearchItem &item, sugList)
+ if (_resList.count() > 0)
{
- ListItem *suggestion = ListItemFactory::create(item, text, this);
- 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(offset++));
- layout()->addWidget(suggestion);
+ clear();
+ insertSearchList(_resList, text);
+
+ UrlSearchList sugList = list.mid(0,4);
+
+ // add new suggestions to the list
+ int offset = _list.count();
+ Q_FOREACH(const UrlSearchItem &item, sugList)
+ {
+ ListItem *suggestion = ListItemFactory::create(item, text, this);
+ 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(offset++));
+ layout()->addWidget(suggestion);
+ }
+ _list.append(sugList);
+ popup();
}
- _list.append(sugList);
- sizeAndPosition();
}
@@ -335,11 +344,6 @@ void CompletionWidget::suggestUrls(const QString &text)
UrlResolver *res = new UrlResolver(text);
connect(res, SIGNAL(suggestionsReady(const UrlSearchList &, const QString &)), this, SLOT(updateSearchList(const UrlSearchList &, const QString &)));
- UrlSearchList list = res->orderedSearchItems();
- if (list.count() > 0)
- {
- clear();
- insertSearchList(list, text);
- popup();
- }
+ _resList = res->orderedSearchItems();
+
}