summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/filterurljob.cpp5
-rw-r--r--src/filterurljob.h3
-rw-r--r--src/urlbar/completionwidget.h3
-rw-r--r--src/urlbar/urlbar.cpp24
-rw-r--r--src/urlbar/urlbar.h6
5 files changed, 36 insertions, 5 deletions
diff --git a/src/filterurljob.cpp b/src/filterurljob.cpp
index bc6118d7..c887ac62 100644
--- a/src/filterurljob.cpp
+++ b/src/filterurljob.cpp
@@ -28,15 +28,14 @@
#include "filterurljob.h"
// KDE Includes
-#include <KUriFilter>
#include <KUriFilterData>
-
FilterUrlJob::FilterUrlJob(WebView *view, const QString &urlString, QObject *parent)
: Job(parent)
, _view(view)
, _urlString(urlString)
{
+ uriFilter = KUriFilter::self();
}
@@ -59,7 +58,7 @@ void FilterUrlJob::run()
KUriFilterData data(_urlString);
data.setCheckForExecutables(false); // if true, queries like "rekonq" or "dolphin" are considered as executables
- if (KUriFilter::self()->filterUri(data) && data.uriType() != KUriFilterData::Error)
+ if (uriFilter->filterUri(data) && data.uriType() != KUriFilterData::Error)
{
QString tempUrlString = data.uri().url();
_url = KUrl(tempUrlString);
diff --git a/src/filterurljob.h b/src/filterurljob.h
index 6ab10695..c10c5e35 100644
--- a/src/filterurljob.h
+++ b/src/filterurljob.h
@@ -35,6 +35,7 @@
// KDE Includes
#include <KUrl>
+#include <KUriFilter>
#include <ThreadWeaver/Job>
// Qt Includes
@@ -59,6 +60,8 @@ private:
WebView *_view;
QString _urlString;
KUrl _url;
+ KUriFilter *uriFilter;
+
};
#endif // FILTER_URL_JOB_H
diff --git a/src/urlbar/completionwidget.h b/src/urlbar/completionwidget.h
index fc0798e7..4ce8248d 100644
--- a/src/urlbar/completionwidget.h
+++ b/src/urlbar/completionwidget.h
@@ -61,9 +61,10 @@ public:
_searchEngine = engine;
};
+ void suggestUrls(const QString &text);
+
private slots:
void itemChosen(ListItem *item, Qt::MouseButton = Qt::LeftButton);
- void suggestUrls(const QString &text);
signals:
void chosenUrl(const KUrl &, Rekonq::OpenType);
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index ad0f34a1..e1e542b7 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -75,6 +75,7 @@ UrlBar::UrlBar(QWidget *parent)
, _tab(0)
, _privateMode(false)
, _icon(new IconButton(this))
+ , _suggestionTimer(new QTimer(this))
{
// initial style
setStyleSheet(QString("UrlBar { padding: 0 0 0 %1px;} ").arg(_icon->sizeHint().width()));
@@ -108,6 +109,9 @@ UrlBar::UrlBar(QWidget *parent)
// load typed urls
connect(this, SIGNAL(returnPressed(const QString &)), this, SLOT(loadTyped(const QString &)));
+ _suggestionTimer->setSingleShot(true);
+ connect(_suggestionTimer, SIGNAL(timeout()), this, SLOT(suggest()));
+
activateSuggestions(true);
}
@@ -316,11 +320,12 @@ void UrlBar::activateSuggestions(bool b)
connect(_box.data(), SIGNAL(chosenUrl(const KUrl &, Rekonq::OpenType)), this, SLOT(activated(const KUrl &, Rekonq::OpenType)));
// activate suggestions on edit text
- connect(this, SIGNAL(textChanged(const QString &)), _box.data(), SLOT(suggestUrls(const QString &)));
+ connect(this, SIGNAL(textChanged(const QString &)), this, SLOT(detectTypedString(const QString &)));
}
}
else
{
+ disconnect(this, SIGNAL(textChanged(const QString &)), this, SLOT(detectTypedString(const QString &)));
removeEventFilter(_box.data());
_box.data()->deleteLater();
}
@@ -389,3 +394,20 @@ void UrlBar::resizeEvent(QResizeEvent *event)
KLineEdit::resizeEvent(event);
}
+
+
+void UrlBar::detectTypedString(const QString &typed)
+{
+ Q_UNUSED(typed);
+
+ if(_suggestionTimer->isActive())
+ _suggestionTimer->stop();
+ _suggestionTimer->start(200);
+}
+
+
+void UrlBar::suggest()
+{
+ if(!_box.isNull())
+ _box.data()->suggestUrls( text() );
+} \ No newline at end of file
diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h
index b644f84f..cda8a2e1 100644
--- a/src/urlbar/urlbar.h
+++ b/src/urlbar/urlbar.h
@@ -46,6 +46,7 @@ class QLinearGradient;
class QWidget;
class CompletionWidget;
class WebTab;
+class QTimer;
class IconButton : public QToolButton
@@ -97,6 +98,9 @@ private slots:
void loadTyped(const QString &);
void clearRightIcons();
+
+ void detectTypedString(const QString &);
+ void suggest();
protected:
void paintEvent(QPaintEvent *event);
@@ -116,6 +120,8 @@ private:
IconButton *_icon;
IconButtonPointerList _rightIconsList;
+
+ QTimer *_suggestionTimer;
};