diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2012-11-12 23:31:08 +0100 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2012-12-10 02:48:06 +0100 |
commit | f372d5fdc089895a0dd8fedbd37d144756fea36b (patch) | |
tree | b83c3b223eabd7b897f0c41f50984f82080bd297 /src/urlbar | |
parent | Fix crash on control click on suggestions list (diff) | |
download | rekonq-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')
-rw-r--r-- | src/urlbar/urlbar.cpp | 35 | ||||
-rw-r--r-- | src/urlbar/urlbar.h | 2 |
2 files changed, 5 insertions, 32 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); diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h index b0edc80e..48447975 100644 --- a/src/urlbar/urlbar.h +++ b/src/urlbar/urlbar.h @@ -90,8 +90,6 @@ public: explicit UrlBar(QWidget *parent = 0); ~UrlBar(); - void activateSuggestions(bool); - public Q_SLOTS: void setQUrl(const QUrl &url); |