diff options
author | Lionel Chauvin <megabigbug@yahoo.fr> | 2011-01-22 10:34:48 +0100 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2011-01-22 10:34:48 +0100 |
commit | 7e291fdc453a74e76b803057cc99e821ed517e66 (patch) | |
tree | e222fedf0f4327f308fa2572a3581842aab0c2f2 /src/opensearch/opensearchmanager.cpp | |
parent | This code fixes new tab button appearing on new window when tabbar is set hidden (diff) | |
download | rekonq-7e291fdc453a74e76b803057cc99e821ed517e66.tar.xz |
Keep downloaded suggestions in memory.
This prevents from downloading it again, letting the completion
list be more reactive.
Diffstat (limited to 'src/opensearch/opensearchmanager.cpp')
-rw-r--r-- | src/opensearch/opensearchmanager.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/opensearch/opensearchmanager.cpp b/src/opensearch/opensearchmanager.cpp index 41e46ec6..eedc8208 100644 --- a/src/opensearch/opensearchmanager.cpp +++ b/src/opensearch/opensearchmanager.cpp @@ -147,15 +147,20 @@ void OpenSearchManager::requestSuggestion(const QString &searchText) idleJob(); } - _typedText = searchText; - - KUrl url = m_activeEngine->suggestionsUrl(searchText); - kDebug() << "Requesting for suggestions: " << url.url(); - - m_currentJob = KIO::get(url, KIO::NoReload, KIO::HideProgressInfo); - m_state = REQ_SUGGESTION; - connect(m_currentJob, SIGNAL(data(KIO::Job *, const QByteArray &)), this, SLOT(dataReceived(KIO::Job *, const QByteArray &))); - connect(m_currentJob, SIGNAL(result(KJob *)), this, SLOT(jobFinished(KJob *))); + if (m_activeEngine->hasCachedSuggestionsFor(searchText)) + { + emit suggestionsReceived(searchText, m_activeEngine->cachedSuggestionsFor(searchText)); + } + else + { + KUrl url = m_activeEngine->suggestionsUrl(searchText); + kDebug() << "Requesting for suggestions: " << url.url(); + _typedText = searchText; + m_currentJob = KIO::get(url, KIO::NoReload, KIO::HideProgressInfo); + m_state = REQ_SUGGESTION; + connect(m_currentJob, SIGNAL(data(KIO::Job *, const QByteArray &)), this, SLOT(dataReceived(KIO::Job *, const QByteArray &))); + connect(m_currentJob, SIGNAL(result(KJob *)), this, SLOT(jobFinished(KJob *))); + } } @@ -177,13 +182,12 @@ void OpenSearchManager::jobFinished(KJob *job) if (m_state == REQ_SUGGESTION) { - const ResponseList suggestionsList = m_activeEngine->parseSuggestion(m_jobData); + const ResponseList suggestionsList = m_activeEngine->parseSuggestion(_typedText, m_jobData); kDebug() << "Received suggestions in "<< _typedText << " from " << m_activeEngine->name() << ": "; Q_FOREACH(const Response &r, suggestionsList) { kDebug() << r.title; } - emit suggestionsReceived(_typedText, suggestionsList); idleJob(); return; |