summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormegabigbug <megabigbug@arrakis.(none)>2010-08-19 21:34:46 +0200
committermegabigbug <megabigbug@arrakis.(none)>2010-08-19 21:34:46 +0200
commit802d8d468189308394e06cf25fe9c74699aa96ec (patch)
tree04c58d6e41e5467883712a3f0e77d7122bd2c63d
parentworking opensearch suggestions (diff)
downloadrekonq-802d8d468189308394e06cf25fe9c74699aa96ec.tar.xz
fix suggestion item: use the correct search engine
-rw-r--r--src/urlbar/completionwidget.cpp9
-rw-r--r--src/urlbar/listitem.cpp33
-rw-r--r--src/urlbar/listitem.h8
-rw-r--r--src/urlbar/urlresolver.cpp1
4 files changed, 43 insertions, 8 deletions
diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp
index 8e72b26b..2afc44b2 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 c9946257..a6258cb5 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);