summaryrefslogtreecommitdiff
path: root/src/urlbar
diff options
context:
space:
mode:
Diffstat (limited to 'src/urlbar')
-rw-r--r--src/urlbar/completionwidget.cpp54
-rw-r--r--src/urlbar/completionwidget.h2
-rw-r--r--src/urlbar/urlresolver.cpp3
3 files changed, 33 insertions, 26 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();
+
}
diff --git a/src/urlbar/completionwidget.h b/src/urlbar/completionwidget.h
index d9f9be49..7f6c93f0 100644
--- a/src/urlbar/completionwidget.h
+++ b/src/urlbar/completionwidget.h
@@ -92,6 +92,8 @@ private:
QString _typedString;
bool _hasSuggestions;
+
+ UrlSearchList _resList;
};
#endif // COMPLETION_WIDGET_H
diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp
index 807e8f7c..b6d7e598 100644
--- a/src/urlbar/urlresolver.cpp
+++ b/src/urlbar/urlresolver.cpp
@@ -107,6 +107,8 @@ UrlResolver::UrlResolver(const QString &typedUrl)
}
_searchEnginesRegexp = QRegExp(reg);
}
+
+ computeSuggestions();
}
@@ -132,7 +134,6 @@ UrlSearchList UrlResolver::orderedSearchItems()
}
//compute lists
- computeSuggestions();
computeHistory();
computeQurlFromUserInput();
computeWebSearches();