diff options
-rw-r--r-- | src/urlbar/completionwidget.cpp | 37 | ||||
-rw-r--r-- | 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<ListItem *>(QString::number(_currentIndex)); - widget->deactivate(); + findChild<ListItem *>(QString::number(_currentIndex))->deactivate(); // deactivate previous if (_currentIndex > 0) _currentIndex--; else _currentIndex = layout()->count() - 1; - kDebug() << _currentIndex; - kDebug() << _typedString; - UrlBar *bar = qobject_cast<UrlBar *>(_parent); - - // activate "new" current - widget = findChild<ListItem *>(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<ListItem *>(QString::number(_currentIndex)); - widget->deactivate(); + findChild<ListItem *>(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<UrlBar *>(_parent); // activate "new" current - widget = findChild<ListItem *>(QString::number(_currentIndex)); + ListItem *widget = findChild<ListItem *>(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; |