diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2010-08-20 15:37:21 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2010-08-20 15:37:21 +0200 |
commit | c39497cca6a6fb80a4658572d45bec53d561f1ed (patch) | |
tree | a1cb9c4781f92e7450e353efcf1e349fbcc31d7e | |
parent | OpenSearch review (diff) | |
parent | fix suggestion item: use the correct search engine (diff) | |
download | rekonq-c39497cca6a6fb80a4658572d45bec53d561f1ed.tar.xz |
Merge commit 'refs/merge-requests/169' of git://gitorious.org/rekonq/mainline into opensearch
-rw-r--r-- | src/urlbar/completionwidget.cpp | 9 | ||||
-rw-r--r-- | src/urlbar/listitem.cpp | 33 | ||||
-rw-r--r-- | src/urlbar/listitem.h | 8 | ||||
-rw-r--r-- | src/urlbar/urlresolver.cpp | 1 |
4 files changed, 43 insertions, 8 deletions
diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp index b77e2d7c..a9203bf7 100644 --- a/src/urlbar/completionwidget.cpp +++ b/src/urlbar/completionwidget.cpp @@ -153,13 +153,10 @@ void CompletionWidget::activateCurrentListItem() //update text of the url bar bar->blockSignals(true); //without compute suggestions - if (!widget->inherits("SearchListItem")) - bar->setQUrl( widget->url() ); - else - bar->setQUrl( _typedString ); + bar->setQUrl(widget->text()); bar->blockSignals(false); bar->setFocus(); - bar->setCursorPosition( bar->text().length() ); + bar->setCursorPosition(bar->text().length()); } @@ -240,7 +237,7 @@ bool CompletionWidget::eventFilter(QObject *obj, QEvent *ev) if( _currentIndex == -1) _currentIndex = 0; child = findChild<ListItem *>(QString::number(_currentIndex)); - if(child && _typedString == w->text()) + if(child) { emit chosenUrl(child->url(), Rekonq::CurrentTab); } diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp index 791ad2fa..e9bb6fbb 100644 --- a/src/urlbar/listitem.cpp +++ b/src/urlbar/listitem.cpp @@ -139,6 +139,12 @@ KUrl ListItem::url() } +QString ListItem::text() +{ + return m_url.url(); +} + + void ListItem::nextItemSubChoice() { //will be override @@ -298,6 +304,12 @@ SearchListItem::SearchListItem(const UrlSearchItem &item, const QString &text, Q } +QString SearchListItem::text() +{ + return m_text; +} + + QString SearchListItem::searchItemTitle(QString engine, QString text) { return QString(i18nc("%1=search engine, e.g. Google, Wikipedia %2=text to search for", "Search %1 for <b>%2</b>", engine, Qt::escape(text))); @@ -393,11 +405,25 @@ void EngineBar::selectNextEngine() SuggestionListItem::SuggestionListItem(const UrlSearchItem &item, const QString &text, QWidget *parent) : ListItem(item, parent) + , m_text(item.title) { QHBoxLayout *hLayout = new QHBoxLayout; hLayout->setSpacing(4); - hLayout->addWidget(new IconLabel(item.url, this)); + QString query = item.title; + KService::Ptr engine = SearchEngine::fromString(query); + if (engine) + { + query = query.remove(0, text.indexOf(SearchEngine::delimiter()) + 1); + } + else + { + engine = qobject_cast<CompletionWidget *>(parent)->searchEngine(); + } + + m_url = SearchEngine::buildQuery(engine, query); + + hLayout->addWidget(new IconLabel(SearchEngine::buildQuery(engine, ""), this)); hLayout->addWidget(new TextLabel(item.title, text, this)); hLayout->addWidget(new TypeIconLabel(item.type, this)); @@ -405,6 +431,11 @@ SuggestionListItem::SuggestionListItem(const UrlSearchItem &item, const QString } +QString SuggestionListItem::text() +{ + return m_text; +} + // --------------------------------------------------------------- diff --git a/src/urlbar/listitem.h b/src/urlbar/listitem.h index 0e1a7ad5..06a02b80 100644 --- a/src/urlbar/listitem.h +++ b/src/urlbar/listitem.h @@ -61,7 +61,8 @@ public: void deactivate(); KUrl url(); - + virtual QString text(); + public slots: virtual void nextItemSubChoice(); @@ -153,6 +154,7 @@ class SearchListItem : public ListItem public: explicit SearchListItem(const UrlSearchItem &item, const QString &text, QWidget *parent = 0); + QString text(); public slots: virtual void nextItemSubChoice(); @@ -180,6 +182,10 @@ class SuggestionListItem : public ListItem public: SuggestionListItem(const UrlSearchItem &item, const QString &text, QWidget *parent = 0); + QString text(); + +private: + QString m_text; }; diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp index ebd01a58..d6f49923 100644 --- a/src/urlbar/urlresolver.cpp +++ b/src/urlbar/urlresolver.cpp @@ -396,6 +396,7 @@ void UrlResolver::computeSuggestions() void UrlResolver::suggestionsReceived(const QStringList &suggestion) { + foreach (QString s, suggestion) { UrlSearchItem gItem(UrlSearchItem::Suggestion, s, s); |