From 55e0a976e5e6eec92985cb5d24a2e7ac2939396e Mon Sep 17 00:00:00 2001 From: lionelc Date: Tue, 10 Aug 2010 17:32:57 +0200 Subject: don't replace the type text by the url of the listitem when this listitem is a searchlistitem --- src/urlbar/completionwidget.cpp | 37 +++++++++++++++++-------------------- src/urlbar/completionwidget.h | 6 +----- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp index b5e06a27..b77e2d7c 100644 --- a/src/urlbar/completionwidget.cpp +++ b/src/urlbar/completionwidget.cpp @@ -117,49 +117,46 @@ void CompletionWidget::popup() void CompletionWidget::up() { // deactivate previous - ListItem *widget = findChild(QString::number(_currentIndex)); - widget->deactivate(); + findChild(QString::number(_currentIndex))->deactivate(); // deactivate previous if (_currentIndex > 0) _currentIndex--; else _currentIndex = layout()->count() - 1; - kDebug() << _currentIndex; - kDebug() << _typedString; - UrlBar *bar = qobject_cast(_parent); - - // activate "new" current - widget = findChild(QString::number(_currentIndex)); - widget->activate(); - bar->blockSignals(true); - bar->setQUrl( widget->url() ); - bar->blockSignals(false); - bar->setFocus(); - bar->setCursorPosition( bar->text().length() ); + activateCurrentListItem(); } void CompletionWidget::down() { - ListItem *widget = findChild(QString::number(_currentIndex)); - widget->deactivate(); + findChild(QString::number(_currentIndex))->deactivate(); // deactivate previous if (_currentIndex < _list.count() - 1) _currentIndex++; else _currentIndex = 0; - + activateCurrentListItem(); +} + + +void CompletionWidget::activateCurrentListItem() +{ kDebug() << _currentIndex; kDebug() << _typedString; UrlBar *bar = qobject_cast(_parent); // activate "new" current - widget = findChild(QString::number(_currentIndex)); + ListItem *widget = findChild(QString::number(_currentIndex)); widget->activate(); - bar->blockSignals(true); - bar->setQUrl( widget->url() ); + + //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->blockSignals(false); bar->setFocus(); bar->setCursorPosition( bar->text().length() ); diff --git a/src/urlbar/completionwidget.h b/src/urlbar/completionwidget.h index fbca5b81..e14535f4 100644 --- a/src/urlbar/completionwidget.h +++ b/src/urlbar/completionwidget.h @@ -78,16 +78,12 @@ private: void sizeAndPosition(); void up(); void down(); + void activateCurrentListItem(); QWidget *_parent; UrlSearchList _list; - /** - * The current index of the pointed out item - * - * -1 means no item, so the actual typed text is considered - */ int _currentIndex; KService::Ptr _searchEngine; -- cgit v1.2.1