summaryrefslogtreecommitdiff
path: root/src/urlbar/completionwidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/urlbar/completionwidget.cpp')
-rw-r--r--src/urlbar/completionwidget.cpp44
1 files changed, 40 insertions, 4 deletions
diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp
index be86238d..8307940b 100644
--- a/src/urlbar/completionwidget.cpp
+++ b/src/urlbar/completionwidget.cpp
@@ -28,6 +28,9 @@
#include "completionwidget.h"
#include "completionwidget.moc"
+// Auto Includes
+#include "rekonq.h"
+
// Local Includes
#include "application.h"
#include "urlresolver.h"
@@ -45,11 +48,15 @@
#include <QEvent>
#include <QKeyEvent>
+// Defines
+#define QL1S(x) QLatin1String(x)
+
CompletionWidget::CompletionWidget(QWidget *parent)
- : QFrame( parent, Qt::ToolTip)
+ : QFrame(parent, Qt::ToolTip)
, _parent(parent)
, _currentIndex(-1)
+ , _searchEngine( defaultSearchEngine() )
{
setFrameStyle(QFrame::Panel);
setLayoutDirection(Qt::LeftToRight);
@@ -66,8 +73,8 @@ void CompletionWidget::insertSearchList(const UrlSearchList &list, const QString
int i = 0;
foreach(UrlSearchItem item, _list)
{
- ListItem *suggestion = ListItemFactory::create(item, text);
- suggestion->setBackgroundRole(i%2 ? QPalette::AlternateBase: QPalette::Base);
+ ListItem *suggestion = ListItemFactory::create(item, text, this);
+ suggestion->setBackgroundRole(i%2 ? QPalette::AlternateBase : QPalette::Base);
connect(suggestion, SIGNAL(itemClicked(ListItem *, Qt::MouseButton)), this, SLOT(itemChosen(ListItem *, Qt::MouseButton)));
connect(this, SIGNAL(nextItemSubChoice()), suggestion, SLOT(nextItemSubChoice()));
suggestion->setObjectName( QString::number(i++) );
@@ -268,7 +275,6 @@ void CompletionWidget::suggestUrls(const QString &text)
UrlResolver res(text);
UrlSearchList list = res.orderedSearchItems();
-
if(list.count() > 0)
{
clear();
@@ -276,3 +282,33 @@ void CompletionWidget::suggestUrls(const QString &text)
popup();
}
}
+
+
+QString CompletionWidget::defaultSearchEngine()
+{
+ int n = ReKonfig::searchEngine();
+ QString engine;
+ switch(n)
+ {
+ case 0:
+ engine = QL1S("google");
+ break;
+ case 1:
+ engine = QL1S("altavista");
+ break;
+ case 2:
+ engine = QL1S("lycos");
+ break;
+ case 3:
+ engine = QL1S("wikipedia");
+ break;
+ case 4:
+ engine = QL1S("wolfram");
+ break;
+ default:
+ engine = QL1S("google");
+ break;
+ }
+
+ return engine;
+}