summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/urlbar/completionwidget.cpp38
-rw-r--r--src/urlbar/completionwidget.h10
-rw-r--r--src/urlbar/urlbar.cpp40
-rw-r--r--src/urlbar/urlbar.h11
4 files changed, 45 insertions, 54 deletions
diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp
index 83e99f9d..d6777b18 100644
--- a/src/urlbar/completionwidget.cpp
+++ b/src/urlbar/completionwidget.cpp
@@ -30,6 +30,7 @@
// Local Includes
#include "application.h"
+#include "urlresolver.h"
// KDE Includes
#include <KGlobalSettings>
@@ -173,6 +174,8 @@ bool CompletionWidget::eventFilter( QObject *o, QEvent *e )
//actions on the CompletionWidget
if (wid && wid->isAncestorOf(_parent) && isVisible())
{
+ ListItem *child;
+
if ( type == QEvent::KeyPress )
{
QKeyEvent *ev = static_cast<QKeyEvent *>( e );
@@ -196,7 +199,7 @@ bool CompletionWidget::eventFilter( QObject *o, QEvent *e )
ev->accept();
return true;
}
- else if (ev->modifiers() & Qt::ControlModifier)
+ if (ev->modifiers() & Qt::ControlModifier)
{
emit nextItemSubChoice();
ev->accept();
@@ -206,18 +209,19 @@ bool CompletionWidget::eventFilter( QObject *o, QEvent *e )
case Qt::Key_Enter:
case Qt::Key_Return:
-
- // need this to let ListItem magic work..
- ListItem *child = findChild<ListItem *>( QString::number(_currentIndex) );
+ child = findChild<ListItem *>( QString::number(_currentIndex) );
emit chosenUrl( child->url(), Rekonq::CurrentTab);
ev->accept();
hide();
return true;
- break;
+
+ case Qt::Key_Escape:
+ hide();
+ return true;
}
}
}
-
+
return QFrame::eventFilter(o,e);
}
@@ -246,3 +250,25 @@ void CompletionWidget::itemChosen(ListItem *item, Qt::MouseButton button)
emit chosenUrl( item->url(), Rekonq::CurrentTab);
hide();
}
+
+
+
+
+void CompletionWidget::suggestUrls(const QString &text)
+{
+ if(text.isEmpty())
+ {
+ hide();
+ return;
+ }
+
+ UrlResolver res(text);
+ UrlSearchList list = res.orderedSearchItems();
+
+ if(list.count() > 0)
+ {
+ clear();
+ insertSearchList(list, text);
+ popup();
+ }
+}
diff --git a/src/urlbar/completionwidget.h b/src/urlbar/completionwidget.h
index 125e186a..896518fc 100644
--- a/src/urlbar/completionwidget.h
+++ b/src/urlbar/completionwidget.h
@@ -30,7 +30,6 @@
// Local Includes
#include "application.h"
-#include "urlresolver.h"
#include "listitem.h"
// KDE Includes
@@ -47,21 +46,22 @@ class CompletionWidget : public QFrame
public:
CompletionWidget(QWidget *parent);
- void insertSearchList(const UrlSearchList &list, const QString& text);
- void popup();
- void clear();
-
virtual bool eventFilter(QObject *obj, QEvent *ev);
void setVisible(bool visible);
private slots:
void itemChosen(ListItem *item, Qt::MouseButton = Qt::LeftButton);
+ void suggestUrls(const QString &text);
signals:
void chosenUrl(const KUrl &, Rekonq::OpenType);
void nextItemSubChoice();
private:
+ void insertSearchList(const UrlSearchList &list, const QString& text);
+ void popup();
+ void clear();
+
void sizeAndPosition();
void up();
void down();
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index 4e7310bf..a4c7a0e0 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -38,8 +38,9 @@
#include "application.h"
#include "lineedit.h"
#include "mainwindow.h"
+#include "webtab.h"
#include "webview.h"
-#include "urlresolver.h"
+#include "completionwidget.h"
// KDE Includes
#include <KDebug>
@@ -71,7 +72,7 @@ UrlBar::UrlBar(QWidget *parent)
// suggestions
installEventFilter(_box);
- connect(_box, SIGNAL(chosenUrl(const KUrl &, Rekonq::OpenType)), SLOT(activated(const KUrl &, Rekonq::OpenType)));
+ connect(_box, SIGNAL(chosenUrl(const KUrl &, Rekonq::OpenType)), this, SLOT(activated(const KUrl &, Rekonq::OpenType)));
// load typed urls
connect(this, SIGNAL(returnPressed(const QString &)), this, SLOT(loadTyped(const QString &)));
@@ -103,7 +104,7 @@ void UrlBar::setQUrl(const QUrl& url)
void UrlBar::activated(const KUrl& url, Rekonq::OpenType type)
{
- disconnect(this, SIGNAL(textChanged(const QString &)), this, SLOT(suggestUrls(const QString &)));
+ disconnect(this, SIGNAL(textChanged(const QString &)), _box, SLOT(suggestUrls(const QString &)));
clearFocus();
setUrl(url);
@@ -152,12 +153,6 @@ void UrlBar::paintEvent(QPaintEvent *event)
void UrlBar::keyPressEvent(QKeyEvent *event)
{
- if(event->key() == Qt::Key_Escape)
- {
- _box->hide();
- return;
- }
-
// this handles the Modifiers + Return key combinations
QString currentText = text().trimmed();
if ((event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return)
@@ -191,35 +186,10 @@ void UrlBar::keyPressEvent(QKeyEvent *event)
}
-void UrlBar::suggestUrls(const QString &text)
-{
- if (!hasFocus())
- {
- return;
- }
-
- if(text.isEmpty())
- {
- _box->hide();
- return;
- }
-
- UrlResolver res(text);
- UrlSearchList list = res.orderedSearchItems();
-
- if(list.count() > 0)
- {
- _box->clear();
- _box->insertSearchList(list, text);
- _box->popup();
- }
-}
-
-
void UrlBar::focusInEvent(QFocusEvent *event)
{
// activate suggestions on edit text
- connect(this, SIGNAL(textChanged(const QString &)), this, SLOT(suggestUrls(const QString &)));
+ connect(this, SIGNAL(textChanged(const QString &)), _box, SLOT(suggestUrls(const QString &)));
LineEdit::focusInEvent(event);
}
diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h
index 804188f7..3ecd914e 100644
--- a/src/urlbar/urlbar.h
+++ b/src/urlbar/urlbar.h
@@ -33,20 +33,16 @@
// Local Includes
#include "lineedit.h"
-#include "completionwidget.h"
-#include "webtab.h"
+#include "application.h"
// KDE Includes
#include <KUrl>
-#include <KComboBox>
-
-// Qt Includes
-#include <QUrl>
-#include <QPointer>
// Forward Declarations
class QLinearGradient;
class QWidget;
+class CompletionWidget;
+class WebTab;
class UrlBar : public LineEdit
@@ -61,7 +57,6 @@ public:
private slots:
void activated(const KUrl& url, Rekonq::OpenType = Rekonq::CurrentTab);
- void suggestUrls(const QString &editedText);
void setQUrl(const QUrl &url);
void loadFinished();