From 14664e54b1a2dbe9c06f474a0918a262dba04e20 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 25 Jul 2011 19:48:41 +0200 Subject: clean up - QL1S - one stupid kDebug less - codingstyle --- src/urlbar/completionwidget.cpp | 67 ++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 35 deletions(-) (limited to 'src/urlbar/completionwidget.cpp') diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp index 00a04bda..5bb55c92 100644 --- a/src/urlbar/completionwidget.cpp +++ b/src/urlbar/completionwidget.cpp @@ -87,14 +87,11 @@ void CompletionWidget::insertItems(const UrlSearchList &list, const QString& tex void CompletionWidget::updateSearchList(const UrlSearchList &list, const QString& text) { - static int counter = 0; - counter++; - kDebug() << counter; - if(_hasSuggestions || _typedString != text) + if (_hasSuggestions || _typedString != text) return; _hasSuggestions = true; - if(_resList.count() > 0) + if (_resList.count() > 0) { clear(); @@ -114,7 +111,7 @@ void CompletionWidget::sizeAndPosition() setFixedWidth(_parent->width()); int h = 0; - for(int i = 0; i < layout()->count(); i++) + for (int i = 0; i < layout()->count(); i++) { QWidget *widget = layout()->itemAt(i)->widget(); h += widget->sizeHint().height(); @@ -131,7 +128,7 @@ void CompletionWidget::popup() { findChild(QString::number(0))->activate(); //activate first listitem sizeAndPosition(); - if(!isVisible()) + if (!isVisible()) show(); } @@ -141,7 +138,7 @@ void CompletionWidget::up() // deactivate previous findChild(QString::number(_currentIndex))->deactivate(); // deactivate previous - if(_currentIndex > 0) + if (_currentIndex > 0) _currentIndex--; else _currentIndex = layout()->count() - 1; @@ -154,7 +151,7 @@ void CompletionWidget::down() { findChild(QString::number(_currentIndex))->deactivate(); // deactivate previous - if(_currentIndex < _list.count() - 1) + if (_currentIndex < _list.count() - 1) _currentIndex++; else _currentIndex = 0; @@ -183,7 +180,7 @@ void CompletionWidget::activateCurrentListItem() void CompletionWidget::clear() { QLayoutItem *child; - while((child = layout()->takeAt(0)) != 0) + while ((child = layout()->takeAt(0)) != 0) { delete child->widget(); delete child; @@ -198,37 +195,37 @@ bool CompletionWidget::eventFilter(QObject *obj, QEvent *ev) int type = ev->type(); QWidget *wid = qobject_cast(obj); - if(obj == this) + if (obj == this) { return false; } // hide conditions of the CompletionWidget - if(wid + if (wid && ((wid == _parent && (type == QEvent::Move || type == QEvent::Resize)) || ((wid->windowFlags() & Qt::Window) && (type == QEvent::Move || type == QEvent::Hide || type == QEvent::WindowDeactivate) && wid == _parent->window()) || (type == QEvent::MouseButtonPress && !isAncestorOf(wid))) - ) + ) { hide(); return false; } //actions on the CompletionWidget - if(wid && wid->isAncestorOf(_parent) && isVisible()) + if (wid && wid->isAncestorOf(_parent) && isVisible()) { ListItem *child; UrlBar *w; - if(type == QEvent::KeyPress) + if (type == QEvent::KeyPress) { QKeyEvent *kev = static_cast(ev); - switch(kev->key()) + switch (kev->key()) { case Qt::Key_Up: case Qt::Key_Backtab: - if(kev->modifiers() == Qt::NoButton || (kev->modifiers() & Qt::ShiftModifier)) + if (kev->modifiers() == Qt::NoButton || (kev->modifiers() & Qt::ShiftModifier)) { up(); kev->accept(); @@ -238,13 +235,13 @@ bool CompletionWidget::eventFilter(QObject *obj, QEvent *ev) case Qt::Key_Down: case Qt::Key_Tab: - if(kev->modifiers() == Qt::NoButton) + if (kev->modifiers() == Qt::NoButton) { down(); kev->accept(); return true; } - if(kev->modifiers() & Qt::ControlModifier) + if (kev->modifiers() & Qt::ControlModifier) { emit nextItemSubChoice(); kev->accept(); @@ -255,35 +252,35 @@ bool CompletionWidget::eventFilter(QObject *obj, QEvent *ev) case Qt::Key_Enter: case Qt::Key_Return: w = qobject_cast(parent()); - if(kev->modifiers() == Qt::AltModifier) + if (kev->modifiers() == Qt::AltModifier) { - if(kev->key() == Qt::Key_Return || kev->key() == Qt::Key_Enter) + if (kev->key() == Qt::Key_Return || kev->key() == Qt::Key_Enter) { emit chosenUrl(w->text(), Rekonq::NewFocusedTab); } } - if(!w->text().startsWith(QL1S("http://"), Qt::CaseInsensitive)) + if (!w->text().startsWith(QL1S("http://"), Qt::CaseInsensitive)) { QString append; - if(kev->modifiers() == Qt::ControlModifier) + if (kev->modifiers() == Qt::ControlModifier) { append = QL1S(".com"); } - else if(kev->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) + else if (kev->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) { append = QL1S(".org"); } - else if(kev->modifiers() == Qt::ShiftModifier) + else if (kev->modifiers() == Qt::ShiftModifier) { append = QL1S(".net"); } - if(!append.isEmpty()) + if (!append.isEmpty()) { QUrl url(QL1S("http://www.") + w->text()); QString host = url.host(); - if(!host.endsWith(append, Qt::CaseInsensitive)) + if (!host.endsWith(append, Qt::CaseInsensitive)) { host += append; url.setHost(host); @@ -294,10 +291,10 @@ bool CompletionWidget::eventFilter(QObject *obj, QEvent *ev) } - if(_currentIndex == -1) + if (_currentIndex == -1) _currentIndex = 0; child = findChild(QString::number(_currentIndex)); - if(child && _currentIndex != 0) //the completionwidget is visible and the user had press down + if (child && _currentIndex != 0) //the completionwidget is visible and the user had press down { //we can use the url of the listitem emit chosenUrl(child->url(), Rekonq::CurrentTab); @@ -306,7 +303,7 @@ bool CompletionWidget::eventFilter(QObject *obj, QEvent *ev) { UrlResolver res(w->text()); UrlSearchList list = res.orderedSearchItems(); - if(list.isEmpty()) + if (list.isEmpty()) { emit chosenUrl(KUrl(_typedString), Rekonq::CurrentTab); } @@ -332,7 +329,7 @@ bool CompletionWidget::eventFilter(QObject *obj, QEvent *ev) void CompletionWidget::setVisible(bool visible) { - if(visible) + if (visible) { rApp->installEventFilter(this); } @@ -348,7 +345,7 @@ void CompletionWidget::setVisible(bool visible) void CompletionWidget::itemChosen(ListItem *item, Qt::MouseButton button, Qt::KeyboardModifiers modifier) { - if(button == Qt::MidButton + if (button == Qt::MidButton || modifier == Qt::ControlModifier) { emit chosenUrl(item->url(), Rekonq::NewFocusedTab); @@ -372,16 +369,16 @@ void CompletionWidget::suggestUrls(const QString &text) _typedString = text; QWidget *w = qobject_cast(parent()); - if(!w->hasFocus()) + if (!w->hasFocus()) return; - if(text.isEmpty()) + if (text.isEmpty()) { hide(); return; } - if(!isVisible()) + if (!isVisible()) { UrlResolver::setSearchEngine(SearchEngine::defaultEngine()); } -- cgit v1.2.1