From a90e4880d0114cdaed23459cbba202a8d3777e57 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Mon, 15 Feb 2016 07:10:24 +0100 Subject: [PATCH] Fixed some problem with Google suggest. --- resources/text/CHANGELOG | 1 + src/network-web/googlesuggest.cpp | 10 +++++++--- src/network-web/googlesuggest.h | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG index 263b49fd6..d97b654b8 100755 --- a/resources/text/CHANGELOG +++ b/resources/text/CHANGELOG @@ -23,6 +23,7 @@ Fixed: Changed: +▪ Adjusted behavior of Google suggestions when no suggestions are available for give text. ▪ Adjusted soěrting, particularly in message list. ▪ Tweaked "remove duplicates" policy. ▪ TT-RSS plugin can now restore messages from local recycle bin. diff --git a/src/network-web/googlesuggest.cpp b/src/network-web/googlesuggest.cpp index 54b2d4707..4a914f9ac 100755 --- a/src/network-web/googlesuggest.cpp +++ b/src/network-web/googlesuggest.cpp @@ -60,7 +60,7 @@ GoogleSuggest::GoogleSuggest(LocationLineEdit *editor, QObject *parent) - : QObject(parent), editor(editor), popup(new QListWidget()) { + : QObject(parent), editor(editor), popup(new QListWidget()), m_enteredText(QString()) { popup->setWindowFlags(Qt::Popup); popup->setFocusPolicy(Qt::NoFocus); popup->setFocusProxy(editor); @@ -167,8 +167,8 @@ void GoogleSuggest::preventSuggest() { } void GoogleSuggest::autoSuggest() { - QString str = QUrl::toPercentEncoding(editor->text()); - QString url = QString(GOOGLE_SUGGEST_URL).arg(str); + m_enteredText = QUrl::toPercentEncoding(editor->text()); + QString url = QString(GOOGLE_SUGGEST_URL).arg(m_enteredText); connect(SilentNetworkAccessManager::instance()->get(QNetworkRequest(QString(url))), SIGNAL(finished()), this, SLOT(handleNetworkData())); @@ -195,6 +195,10 @@ void GoogleSuggest::handleNetworkData() { } } + if (choices.isEmpty()) { + choices.append(m_enteredText); + } + showCompletion(choices); } } diff --git a/src/network-web/googlesuggest.h b/src/network-web/googlesuggest.h index 6808949fa..5c07a794b 100755 --- a/src/network-web/googlesuggest.h +++ b/src/network-web/googlesuggest.h @@ -76,6 +76,7 @@ class GoogleSuggest : public QObject { LocationLineEdit *editor; QScopedPointer popup; QTimer *timer; + QString m_enteredText; }; #endif // GOOGLESUGGEST_H