summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlionelc <lionelc@lionelc.(none)>2010-08-10 17:14:27 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-08-11 00:23:31 +0200
commitbb736cbc675ae0a3366d46d59d9443ab090c96ea (patch)
treef36c77f9a65dcd59a9edddca23cde552e2931e6e
parentMerge commit 'refs/merge-requests/161' of git://gitorious.org/rekonq/mainline... (diff)
downloadrekonq-bb736cbc675ae0a3366d46d59d9443ab090c96ea.tar.xz
select first item
-rw-r--r--src/urlbar/completionwidget.cpp64
1 files changed, 23 insertions, 41 deletions
diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp
index 62eb72a6..b5e06a27 100644
--- a/src/urlbar/completionwidget.cpp
+++ b/src/urlbar/completionwidget.cpp
@@ -54,7 +54,7 @@
CompletionWidget::CompletionWidget(QWidget *parent)
: QFrame(parent, Qt::ToolTip)
, _parent(parent)
- , _currentIndex(-1)
+ , _currentIndex(0)
, _searchEngine(SearchEngine::defaultEngine())
{
setFrameStyle(QFrame::Panel);
@@ -107,6 +107,7 @@ void CompletionWidget::sizeAndPosition()
void CompletionWidget::popup()
{
+ findChild<ListItem *>(QString::number(0))->activate(); //activate first listitem
sizeAndPosition();
if (!isVisible())
show();
@@ -116,13 +117,10 @@ void CompletionWidget::popup()
void CompletionWidget::up()
{
// deactivate previous
- if (_currentIndex != -1)
- {
- ListItem *widget = findChild<ListItem *>(QString::number(_currentIndex));
- widget->deactivate();
- }
+ ListItem *widget = findChild<ListItem *>(QString::number(_currentIndex));
+ widget->deactivate();
- if (_currentIndex >= 0)
+ if (_currentIndex > 0)
_currentIndex--;
else
_currentIndex = layout()->count() - 1;
@@ -130,17 +128,13 @@ void CompletionWidget::up()
kDebug() << _currentIndex;
kDebug() << _typedString;
UrlBar *bar = qobject_cast<UrlBar *>(_parent);
- if(_currentIndex != -1)
- {
- // activate "new" current
- ListItem *widget = findChild<ListItem *>(QString::number(_currentIndex));
- widget->activate();
- bar->setQUrl( widget->url() );
- }
- else
- {
- bar->setText(_typedString);
- }
+
+ // 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() );
}
@@ -148,33 +142,25 @@ void CompletionWidget::up()
void CompletionWidget::down()
{
- // deactivate previous
- if (_currentIndex != -1)
- {
- ListItem *widget = findChild<ListItem *>(QString::number(_currentIndex));
- widget->deactivate();
- }
+ ListItem *widget = findChild<ListItem *>(QString::number(_currentIndex));
+ widget->deactivate();
if (_currentIndex < _list.count() - 1)
_currentIndex++;
else
- _currentIndex = -1;
+ _currentIndex = 0;
kDebug() << _currentIndex;
kDebug() << _typedString;
UrlBar *bar = qobject_cast<UrlBar *>(_parent);
- if(_currentIndex != -1)
- {
- // activate "new" current
- ListItem *widget = findChild<ListItem *>(QString::number(_currentIndex));
- widget->activate();
- bar->setQUrl( widget->url() );
- }
- else
- {
- bar->setText(_typedString);
- }
+
+ // 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() );
}
@@ -188,7 +174,7 @@ void CompletionWidget::clear()
delete child->widget();
delete child;
}
- _currentIndex = -1;
+ _currentIndex = 0;
}
@@ -309,10 +295,6 @@ void CompletionWidget::itemChosen(ListItem *item, Qt::MouseButton button, Qt::Ke
void CompletionWidget::suggestUrls(const QString &text)
{
- if(_currentIndex != -1)
- return;
-
- kDebug() << "suggesting...";
_typedString = text;
QWidget *w = qobject_cast<QWidget *>(parent());