diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2010-08-29 17:23:11 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2010-08-29 17:23:11 +0200 |
commit | 86d13c73a4306e1e88cfab60c3d00a41b39c649c (patch) | |
tree | 1b93baf9c2ff4b6793e27677114dfc8bad698534 | |
parent | First fixes, 4 suggestions (diff) | |
download | rekonq-86d13c73a4306e1e88cfab60c3d00a41b39c649c.tar.xz |
Cleaning up new suggestions mechanism
-rw-r--r-- | src/urlbar/completionwidget.cpp | 35 | ||||
-rw-r--r-- | src/urlbar/completionwidget.h | 3 | ||||
-rw-r--r-- | src/urlbar/urlbar.cpp | 7 | ||||
-rw-r--r-- | src/urlbar/urlresolver.cpp | 2 |
4 files changed, 9 insertions, 38 deletions
diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp index bd907fa9..12d34ad8 100644 --- a/src/urlbar/completionwidget.cpp +++ b/src/urlbar/completionwidget.cpp @@ -56,8 +56,7 @@ CompletionWidget::CompletionWidget(QWidget *parent) , _parent(parent) , _currentIndex(0) , _searchEngine(SearchEngine::defaultEngine()) - , _suggestionsNumber(0) - , _isSuggesting(false) + , _hasSuggestions(false) { setFrameStyle(QFrame::Panel); setLayoutDirection(Qt::LeftToRight); @@ -79,8 +78,6 @@ void CompletionWidget::insertSearchList(const UrlSearchList &list, const QString int i = 0; foreach(const UrlSearchItem &item, _list) { - kDebug() << "ITEM URL: " << item.url; - kDebug() << "ITEM TYPE: " << item.type; ListItem *suggestion = ListItemFactory::create(item, text, this); suggestion->setBackgroundRole(i % 2 ? QPalette::AlternateBase : QPalette::Base); connect(suggestion, @@ -97,45 +94,29 @@ void CompletionWidget::insertSearchList(const UrlSearchList &list, const QString void CompletionWidget::updateSearchList(const UrlSearchList &list, const QString& text) { - if(_isSuggesting || !isVisible() || _typedString != text) + if(_hasSuggestions || _typedString != text || !isVisible()) return; + _hasSuggestions = true; - _isSuggesting = true; - - kDebug() << "LIST COUNT: " << list.count(); UrlSearchList sugList = list.mid(0,4); - kDebug() << "SUGLIST COUNT: " << sugList.count(); - -// // clean up eventual old suggestions -// if(_suggestionsNumber > 0) -// { -// int offset = _list.count(); -// for(int i = offset; i < offset + _suggestionsNumber; ++i) -// { -// QLayoutItem *item = layout()->takeAt( i ); -// delete item; -// } -// } // add new suggestions to the list - int i = _list.count(); + int offset = _list.count(); Q_FOREACH(const UrlSearchItem &item, sugList) { ListItem *suggestion = ListItemFactory::create(item, text, this); - suggestion->setBackgroundRole(i % 2 ? QPalette::AlternateBase : QPalette::Base); + suggestion->setBackgroundRole(offset % 2 ? QPalette::AlternateBase : QPalette::Base); connect(suggestion, SIGNAL(itemClicked(ListItem *, Qt::MouseButton, Qt::KeyboardModifiers)), this, SLOT(itemChosen(ListItem *, Qt::MouseButton, Qt::KeyboardModifiers))); connect(this, SIGNAL(nextItemSubChoice()), suggestion, SLOT(nextItemSubChoice())); - suggestion->setObjectName(QString::number(i++)); + suggestion->setObjectName(QString::number(offset++)); layout()->addWidget(suggestion); } - _suggestionsNumber = sugList.count(); _list.append(sugList); sizeAndPosition(); - _isSuggesting = false; } @@ -195,8 +176,6 @@ void CompletionWidget::down() void CompletionWidget::activateCurrentListItem() { - kDebug() << _currentIndex; - kDebug() << _typedString; UrlBar *bar = qobject_cast<UrlBar *>(_parent); // activate "new" current @@ -221,7 +200,7 @@ void CompletionWidget::clear() delete child; } _currentIndex = 0; -// _suggestionsNumber = 0; + _hasSuggestions = false; } diff --git a/src/urlbar/completionwidget.h b/src/urlbar/completionwidget.h index 29f80721..d9f9be49 100644 --- a/src/urlbar/completionwidget.h +++ b/src/urlbar/completionwidget.h @@ -91,8 +91,7 @@ private: KService::Ptr _searchEngine; QString _typedString; - int _suggestionsNumber; - bool _isSuggesting; + bool _hasSuggestions; }; #endif // COMPLETION_WIDGET_H diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp index 0b966b74..f1729d53 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -500,12 +500,5 @@ void UrlBar::suggest() void UrlBar::refreshFavicon() { - kDebug() << "------------------ REFRESH ME!!! -------------"; -// if( u.scheme() == QL1S("about") ) -// { -// kDebug() << "ABOUT SCHEME..."; -// return; -// } - _icon->setIcon(Application::iconManager()->iconForUrl(_tab->view()->url())); } diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp index 985b15c3..787546cd 100644 --- a/src/urlbar/urlresolver.cpp +++ b/src/urlbar/urlresolver.cpp @@ -45,7 +45,7 @@ #include <QByteArray> // defines -#define MAX_ELEMENTS 10 +#define MAX_ELEMENTS 8 #define MIN_SUGGESTIONS 3 // NOTE |