mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
LocationCompleter: Add search/visit item immediately
Instead of waiting until first refresh job finishes, add search/visit item immediately on complete request and also update m_originalText. This fixes issue where accepting the typed completion before the refresh job finished resulting in searching for old typed text (from last finished refresh job).
This commit is contained in:
parent
5c5dc20c6d
commit
6d26d67db4
@ -98,6 +98,26 @@ void LocationCompleter::complete(const QString &string)
|
|||||||
} else {
|
} else {
|
||||||
m_oldSuggestions.clear();
|
m_oldSuggestions.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add search/visit item
|
||||||
|
if (!trimmedStr.isEmpty()) {
|
||||||
|
QStandardItem *item = new QStandardItem();
|
||||||
|
item->setText(trimmedStr);
|
||||||
|
item->setData(trimmedStr, LocationCompleterModel::UrlRole);
|
||||||
|
item->setData(trimmedStr, LocationCompleterModel::SearchStringRole);
|
||||||
|
item->setData(true, LocationCompleterModel::VisitSearchItemRole);
|
||||||
|
s_model->setCompletions({item});
|
||||||
|
addSuggestions(m_oldSuggestions);
|
||||||
|
showPopup();
|
||||||
|
if (!s_view->currentIndex().isValid()) {
|
||||||
|
m_ignoreCurrentChanged = true;
|
||||||
|
s_view->setCurrentIndex(s_model->index(0, 0));
|
||||||
|
m_ignoreCurrentChanged = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_originalText = m_locationBar->text();
|
||||||
|
s_view->setOriginalText(m_originalText);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocationCompleter::showMostVisited()
|
void LocationCompleter::showMostVisited()
|
||||||
@ -115,10 +135,10 @@ void LocationCompleter::refreshJobFinished()
|
|||||||
// Also don't open the popup again when it was already closed
|
// Also don't open the popup again when it was already closed
|
||||||
if (!job->isCanceled() && job->timestamp() > m_lastRefreshTimestamp && !m_popupClosed) {
|
if (!job->isCanceled() && job->timestamp() > m_lastRefreshTimestamp && !m_popupClosed) {
|
||||||
s_model->setCompletions(job->completions());
|
s_model->setCompletions(job->completions());
|
||||||
m_lastRefreshTimestamp = job->timestamp();
|
|
||||||
|
|
||||||
showPopup();
|
|
||||||
addSuggestions(m_oldSuggestions);
|
addSuggestions(m_oldSuggestions);
|
||||||
|
showPopup();
|
||||||
|
|
||||||
|
m_lastRefreshTimestamp = job->timestamp();
|
||||||
|
|
||||||
if (!s_view->currentIndex().isValid() && s_model->index(0, 0).data(LocationCompleterModel::VisitSearchItemRole).toBool()) {
|
if (!s_view->currentIndex().isValid() && s_model->index(0, 0).data(LocationCompleterModel::VisitSearchItemRole).toBool()) {
|
||||||
m_ignoreCurrentChanged = true;
|
m_ignoreCurrentChanged = true;
|
||||||
@ -129,9 +149,6 @@ void LocationCompleter::refreshJobFinished()
|
|||||||
if (qzSettings->useInlineCompletion) {
|
if (qzSettings->useInlineCompletion) {
|
||||||
emit showDomainCompletion(job->domainCompletion());
|
emit showDomainCompletion(job->domainCompletion());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_originalText = m_locationBar->text();
|
|
||||||
s_view->setOriginalText(m_originalText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
job->deleteLater();
|
job->deleteLater();
|
||||||
|
Loading…
Reference in New Issue
Block a user