summaryrefslogtreecommitdiff
path: root/src/urlbar/urlbar.cpp
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-11-12 23:31:08 +0100
committerAndrea Diamantini <adjam7@gmail.com>2012-12-10 02:48:06 +0100
commitf372d5fdc089895a0dd8fedbd37d144756fea36b (patch)
treeb83c3b223eabd7b897f0c41f50984f82080bd297 /src/urlbar/urlbar.cpp
parentFix crash on control click on suggestions list (diff)
downloadrekonq-f372d5fdc089895a0dd8fedbd37d144756fea36b.tar.xz
Clean up url suggestions, step 1
Improve performances by NOT create/delete everytime a suggester but reusing each time the same one...
Diffstat (limited to 'src/urlbar/urlbar.cpp')
-rw-r--r--src/urlbar/urlbar.cpp35
1 files changed, 5 insertions, 30 deletions
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index 2b32738d..1bab4ae3 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -116,6 +116,7 @@ QString guessUrlWithCustomFirstLevel(const QString &str1, const QString &str2)
UrlBar::UrlBar(QWidget *parent)
: KLineEdit(parent)
+ , _box(new CompletionWidget(this))
, _tab(0)
, _icon(new IconButton(this))
, _suggestionTimer(new QTimer(this))
@@ -158,6 +159,10 @@ UrlBar::UrlBar(QWidget *parent)
// bookmark icon
connect(BookmarkManager::self(), SIGNAL(bookmarksUpdated()), this, SLOT(updateRightIcons()));
+ // suggestions
+ connect(_box.data(), SIGNAL(chosenUrl(KUrl, Rekonq::OpenType)), this, SLOT(loadRequestedUrl(KUrl, Rekonq::OpenType)));
+ connect(this, SIGNAL(textEdited(QString)), this, SLOT(detectTypedString(QString)));
+
_suggestionTimer->setSingleShot(true);
connect(_suggestionTimer, SIGNAL(timeout()), this, SLOT(suggest()));
}
@@ -166,7 +171,6 @@ UrlBar::UrlBar(QWidget *parent)
UrlBar::~UrlBar()
{
_suggestionTimer->stop();
- activateSuggestions(false);
_box.clear();
disconnect();
@@ -192,7 +196,6 @@ void UrlBar::setQUrl(const QUrl& url)
void UrlBar::loadRequestedUrl(const KUrl& url, Rekonq::OpenType type)
{
- activateSuggestions(false);
clearFocus();
setUrl(url);
rApp->loadUrl(url, type);
@@ -345,7 +348,6 @@ void UrlBar::keyPressEvent(QKeyEvent *event)
void UrlBar::focusInEvent(QFocusEvent *event)
{
emit focusIn();
- activateSuggestions(true);
KLineEdit::focusInEvent(event);
}
@@ -435,33 +437,6 @@ void UrlBar::updateRightIcons()
}
-void UrlBar::activateSuggestions(bool b)
-{
- if (b)
- {
- if (_box.isNull())
- {
- _box = new CompletionWidget(this);
- connect(_box.data(), SIGNAL(chosenUrl(KUrl, Rekonq::OpenType)), this, SLOT(loadRequestedUrl(KUrl, Rekonq::OpenType)));
-
- // activate suggestions on edit text
- connect(this, SIGNAL(textChanged(QString)), this, SLOT(detectTypedString(QString)));
- }
- }
- else
- {
- disconnect(this, SIGNAL(textChanged(QString)), this, SLOT(detectTypedString(QString)));
-
- if (!_box.isNull())
- {
- // This was just deleted later because of a crash in completionwidget...
- delete _box.data();
- _box.clear();
- }
- }
-}
-
-
void UrlBar::mouseDoubleClickEvent(QMouseEvent *event)
{
Q_UNUSED(event);