summaryrefslogtreecommitdiff
path: root/src/urlbar/completionwidget.cpp
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-06-26 00:44:32 +0200
committerAndrea Diamantini <adjam7@gmail.com>2012-06-26 00:44:32 +0200
commitd8e66449a62a2758d07b7b90f40a2470e440a3e8 (patch)
tree7a1f9cc4f50fe61811db819cc48a6dc2766c2fd4 /src/urlbar/completionwidget.cpp
parentSVN_SILENT made messages (.desktop file) (diff)
downloadrekonq-d8e66449a62a2758d07b7b90f40a2470e440a3e8.tar.xz
Ensure users can recover typed text in the urlbar
PS: contains also an easy check improved to avoid duplicating suggestions creation ;) Thanks to Franz Fellner for REPORTING and FIXING himself the problem :D BUG: 302391 REVIEWED-BY: adjam
Diffstat (limited to 'src/urlbar/completionwidget.cpp')
-rw-r--r--src/urlbar/completionwidget.cpp48
1 files changed, 28 insertions, 20 deletions
diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp
index fa38d7f0..83de2f09 100644
--- a/src/urlbar/completionwidget.cpp
+++ b/src/urlbar/completionwidget.cpp
@@ -135,26 +135,26 @@ void CompletionWidget::popup()
void CompletionWidget::up()
{
- // deactivate previous
- findChild<ListItem *>(QString::number(_currentIndex))->deactivate(); // deactivate previous
-
- if (_currentIndex > 0)
- _currentIndex--;
- else
- _currentIndex = layout()->count() - 1;
-
+ if (_currentIndex >= 0)
+ findChild<ListItem *>(QString::number(_currentIndex))->deactivate(); // deactivate previous
+
+ --_currentIndex;
+ if (_currentIndex < -1) {
+ _currentIndex = _list.count() - 1;
+ }
+
activateCurrentListItem();
}
void CompletionWidget::down()
{
- findChild<ListItem *>(QString::number(_currentIndex))->deactivate(); // deactivate previous
+ if(_currentIndex >= 0)
+ findChild<ListItem *>(QString::number(_currentIndex))->deactivate(); // deactivate previous
- if (_currentIndex < _list.count() - 1)
- _currentIndex++;
- else
- _currentIndex = 0;
+ ++_currentIndex;
+ if (_currentIndex == _list.count())
+ _currentIndex = -1;
activateCurrentListItem();
}
@@ -166,11 +166,18 @@ void CompletionWidget::activateCurrentListItem()
// activate "new" current
ListItem *widget = findChild<ListItem *>(QString::number(_currentIndex));
- widget->activate();
-
- //update text of the url bar
- bar->blockSignals(true); //without compute suggestions
- bar->setQUrl(widget->text());
+
+ // update text of the url bar
+ bar->blockSignals(true); // without compute suggestions
+ if (widget)
+ {
+ widget->activate();
+ bar->setQUrl(widget->text());
+ }
+ else
+ {
+ bar->setText(_typedString);
+ }
bar->blockSignals(false);
bar->setFocus();
bar->setCursorPosition(bar->text().length());
@@ -290,11 +297,12 @@ bool CompletionWidget::eventFilter(QObject *obj, QEvent *ev)
}
}
-
+ kDebug() << "Suggestion INDEX chosen: " << _currentIndex;
if (_currentIndex == -1)
_currentIndex = 0;
child = findChild<ListItem *>(QString::number(_currentIndex));
- if (child && _currentIndex != 0) //the completionwidget is visible and the user had press down
+
+ if (child) //the completionwidget is visible and the user had press down
{
//we can use the url of the listitem
emit chosenUrl(child->url(), Rekonq::CurrentTab);