summaryrefslogtreecommitdiff
path: root/src
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
parentabout url detection fix (diff)
downloadrekonq-d9926d60f2cd5ab66ae968eeb50634c5feab025c.tar.xz
Fix adding suggestions to not let completion widget "flicker"
Diffstat (limited to 'src')
-rw-r--r--src/search/opensearchmanager.cpp2
-rw-r--r--src/urlbar/completionwidget.cpp54
-rw-r--r--src/urlbar/completionwidget.h2
-rw-r--r--src/urlbar/urlresolver.cpp3
4 files changed, 34 insertions, 27 deletions
diff --git a/src/search/opensearchmanager.cpp b/src/search/opensearchmanager.cpp
index 2bb23121..773c2acb 100644
--- a/src/search/opensearchmanager.cpp
+++ b/src/search/opensearchmanager.cpp
@@ -161,7 +161,7 @@ void OpenSearchManager::jobFinished(KJob *job)
if (m_state == REQ_SUGGESTION)
{
const QStringList suggestionsList = m_activeEngine->parseSuggestion(m_jobData);
- kDebug() << "Received suggestion from " << m_activeEngine->name() << ": " << suggestionsList;
+ kDebug() << "Received suggestions in "<< _typedText << " from " << m_activeEngine->name() << ": " << suggestionsList;
emit suggestionReceived(_typedText, suggestionsList);
return;
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();