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/bookmarkwidget.cpp | 4 +- src/urlbar/completionwidget.cpp | 67 ++++++++++++++---------------- src/urlbar/favoritewidget.cpp | 2 +- src/urlbar/listitem.cpp | 70 +++++++++++++++---------------- src/urlbar/rsswidget.cpp | 8 ++-- src/urlbar/sslwidget.cpp | 18 ++++---- src/urlbar/stackedurlbar.cpp | 2 +- src/urlbar/urlbar.cpp | 90 ++++++++++++++++++++-------------------- src/urlbar/urlresolver.cpp | 66 ++++++++++++++--------------- src/urlbar/urlresolver.h | 2 +- src/urlbar/webshortcutwidget.cpp | 8 ++-- 11 files changed, 167 insertions(+), 170 deletions(-) (limited to 'src/urlbar') diff --git a/src/urlbar/bookmarkwidget.cpp b/src/urlbar/bookmarkwidget.cpp index eb2ac08e..c6480d1c 100644 --- a/src/urlbar/bookmarkwidget.cpp +++ b/src/urlbar/bookmarkwidget.cpp @@ -80,7 +80,7 @@ BookmarkWidget::BookmarkWidget(const KBookmark &bookmark, QWidget *parent) QLabel *nameLabel = new QLabel(this); nameLabel->setText(i18n("Name:")); m_name = new KLineEdit(this); - if(m_bookmark->isNull()) + if (m_bookmark->isNull()) { m_name->setEnabled(false); } @@ -119,7 +119,7 @@ void BookmarkWidget::showAt(const QPoint &pos) void BookmarkWidget::accept() { - if(!m_bookmark->isNull() && m_name->text() != m_bookmark->fullText()) + if (!m_bookmark->isNull() && m_name->text() != m_bookmark->fullText()) { m_bookmark->setFullText(m_name->text()); rApp->bookmarkProvider()->bookmarkManager()->emitChanged(); 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()); } diff --git a/src/urlbar/favoritewidget.cpp b/src/urlbar/favoritewidget.cpp index d58ba3f6..da97ef65 100644 --- a/src/urlbar/favoritewidget.cpp +++ b/src/urlbar/favoritewidget.cpp @@ -107,7 +107,7 @@ void FavoriteWidget::showAt(const QPoint &pos) void FavoriteWidget::accept() { QStringList urls = ReKonfig::previewUrls(); - if(urls.removeOne(m_tab->url().url())) + if (urls.removeOne(m_tab->url().url())) { ReKonfig::setPreviewUrls(urls); QStringList titles = ReKonfig::previewNames(); diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp index 150cc0a9..50562022 100644 --- a/src/urlbar/listitem.cpp +++ b/src/urlbar/listitem.cpp @@ -105,7 +105,7 @@ void ListItem::paintEvent(QPaintEvent *event) m_option.rect = QRect(QPoint(), size()); painter.fillRect(m_option.rect, palette().brush(backgroundRole())); - if(m_option.state.testFlag(QStyle::State_Selected) || m_option.state.testFlag(QStyle::State_MouseOver)) + if (m_option.state.testFlag(QStyle::State_Selected) || m_option.state.testFlag(QStyle::State_MouseOver)) { style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &m_option, &painter, this); } @@ -166,15 +166,15 @@ TypeIconLabel::TypeIconLabel(int type, QWidget *parent) hLayout->setAlignment(Qt::AlignRight); setLayout(hLayout); - if(type & UrlSearchItem::Search) + if (type & UrlSearchItem::Search) hLayout->addWidget(getIcon("edit-find")); - if(type & UrlSearchItem::Browse) + if (type & UrlSearchItem::Browse) hLayout->addWidget(getIcon("applications-internet")); - if(type & UrlSearchItem::Bookmark) + if (type & UrlSearchItem::Bookmark) hLayout->addWidget(getIcon("rating")); - if(type & UrlSearchItem::History) + if (type & UrlSearchItem::History) hLayout->addWidget(getIcon("view-history")); - if(type & UrlSearchItem::Suggestion) + if (type & UrlSearchItem::Suggestion) hLayout->addWidget(getIcon("help-hint")); } @@ -220,7 +220,7 @@ static QString highlightWordsInText(const QString &text, const QStringList &word foreach(const QString & wordToPointOut, words) { int index = ret.indexOf(wordToPointOut, 0, Qt::CaseInsensitive); - while(index > -1) + while (index > -1) { boldSections.fill(true, index, index + wordToPointOut.size()); index = ret.indexOf(wordToPointOut, index + wordToPointOut.size(), Qt::CaseInsensitive); @@ -228,34 +228,34 @@ static QString highlightWordsInText(const QString &text, const QStringList &word } - if(boldSections.isEmpty()) + if (boldSections.isEmpty()) return ret; int numSections = 0; - for(int i = 0; i < boldSections.size() - 1; ++i) + for (int i = 0; i < boldSections.size() - 1; ++i) { - if(boldSections.testBit(i) && !boldSections.testBit(i + 1)) + if (boldSections.testBit(i) && !boldSections.testBit(i + 1)) ++numSections; } - if(boldSections.testBit(boldSections.size() - 1)) //last char was still part of a bold section + if (boldSections.testBit(boldSections.size() - 1)) //last char was still part of a bold section ++numSections; const int tagLength = 7; // length of "" and "" we're going to add for each bold section. ret.reserve(ret.size() + numSections * tagLength); bool bold = false; - for(int i = boldSections.size() - 1; i >= 0; --i) + for (int i = boldSections.size() - 1; i >= 0; --i) { - if(!bold && boldSections.testBit(i)) + if (!bold && boldSections.testBit(i)) { ret.insert(i + 1, QL1S("")); bold = true; } - else if(bold && !boldSections.testBit(i)) + else if (bold && !boldSections.testBit(i)) { ret.insert(i + 1, QL1S("")); bold = false; } } - if(bold) + if (bold) ret.insert(0, QL1S("")); return ret; } @@ -268,12 +268,12 @@ TextLabel::TextLabel(const QString &text, const QString &textToPointOut, QWidget setMouseTracking(false); QString t = text; const bool wasItalic = t.startsWith(QL1S("")); - if(wasItalic) + if (wasItalic) t.remove(QRegExp(QL1S("<[/ib]*>"))); t = Qt::escape(t); QStringList words = Qt::escape(textToPointOut.simplified()).split(QL1C(' ')); t = highlightWordsInText(t, words); - if(wasItalic) + if (wasItalic) t = QL1S("") + t + QL1S(""); setText(t); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); @@ -303,10 +303,10 @@ DescriptionLabel::DescriptionLabel(const QString &text, QWidget *parent) { QString t = text; const bool wasItalic = t.startsWith(QL1S("")); - if(wasItalic) + if (wasItalic) t.remove(QRegExp("<[/ib]*>")); - if(wasItalic) + if (wasItalic) t = QL1S("") + t + QL1S(""); setWordWrap(false); //TODO: why setWordWrap(true) make items have a strange behavior ? @@ -335,7 +335,7 @@ PreviewListItem::PreviewListItem(const UrlSearchItem &item, const QString &text, vLayout->setMargin(0); QString title = item.title; - if(title.isEmpty()) + if (title.isEmpty()) { title = item.url; title = title.remove("http://"); @@ -363,7 +363,7 @@ PreviewLabel::PreviewLabel(const QString &url, int width, int height, QWidget *p setFrameStyle(QFrame::StyledPanel | QFrame::Raised); KUrl u = KUrl(url); - if(WebSnap::existsImage(KUrl(u))) + if (WebSnap::existsImage(KUrl(u))) { QPixmap preview; preview.load(WebSnap::imagePathFromUrl(u)); @@ -380,7 +380,7 @@ ImageLabel::ImageLabel(const QString &url, int width, int height, QWidget *paren m_url(url) { setFixedSize(width, height); - if(WebSnap::existsImage(KUrl(url))) + if (WebSnap::existsImage(KUrl(url))) { QPixmap pix; pix.load(WebSnap::imagePathFromUrl(url)); @@ -407,7 +407,7 @@ void ImageLabel::slotData(KIO::Job *job, const QByteArray &data) void ImageLabel::slotResult(KJob *) { QPixmap pix; - if(!pix.loadFromData(m_data)) + if (!pix.loadFromData(m_data)) kDebug() << "error while loading image: "; setPixmap(pix); pix.save(WebSnap::imagePathFromUrl(m_url), "PNG"); @@ -472,12 +472,12 @@ EngineBar::EngineBar(KService::Ptr selectedEngine, QWidget *parent) m_engineGroup = new QActionGroup(this); m_engineGroup->setExclusive(true); - if(SearchEngine::defaultEngine().isNull()) + if (SearchEngine::defaultEngine().isNull()) return; m_engineGroup->addAction(newEngineAction(SearchEngine::defaultEngine(), selectedEngine)); foreach(const KService::Ptr & engine, SearchEngine::favorites()) { - if(engine->desktopEntryName() != SearchEngine::defaultEngine()->desktopEntryName()) + if (engine->desktopEntryName() != SearchEngine::defaultEngine()->desktopEntryName()) { m_engineGroup->addAction(newEngineAction(engine, selectedEngine)); } @@ -495,7 +495,7 @@ KAction *EngineBar::newEngineAction(KService::Ptr engine, KService::Ptr selected kDebug() << "Engine NAME: " << engine->name() << " URL: " << url; KAction *a = new KAction(rApp->iconManager()->iconForUrl(url), engine->name(), this); a->setCheckable(true); - if(engine->desktopEntryName() == selectedEngine->desktopEntryName()) a->setChecked(true); + if (engine->desktopEntryName() == selectedEngine->desktopEntryName()) a->setChecked(true); a->setData(engine->entryPath()); connect(a, SIGNAL(triggered(bool)), this, SLOT(changeSearchEngine())); return a; @@ -513,12 +513,12 @@ void EngineBar::selectNextEngine() { QList e = m_engineGroup->actions(); int i = 0; - while(i < e.count() && !e.at(i)->isChecked()) + while (i < e.count() && !e.at(i)->isChecked()) { i++; } - if(i + 1 == e.count()) + if (i + 1 == e.count()) { e.at(0)->setChecked(true); e.at(0)->trigger(); @@ -567,7 +567,7 @@ VisualSuggestionListItem::VisualSuggestionListItem(const UrlSearchItem &item, co hLayout->setSpacing(4); QLabel *previewLabelIcon = new QLabel(this); - if(!item.image.isEmpty()) + if (!item.image.isEmpty()) { previewLabelIcon->setFixedSize(item.image_width + 10, item.image_height + 10); new ImageLabel(item.image, item.image_width, item.image_height, previewLabelIcon); @@ -627,29 +627,29 @@ BrowseListItem::BrowseListItem(const UrlSearchItem &item, const QString &text, Q ListItem *ListItemFactory::create(const UrlSearchItem &item, const QString &text, QWidget *parent) { - if(item.type & UrlSearchItem::Search) + if (item.type & UrlSearchItem::Search) { return new SearchListItem(item, text, parent); } - if(item.type & UrlSearchItem::Browse) + if (item.type & UrlSearchItem::Browse) { return new BrowseListItem(item, text, parent); } - if(item.type & UrlSearchItem::History) + if (item.type & UrlSearchItem::History) { return new PreviewListItem(item, text, parent); } - if(item.type & UrlSearchItem::Bookmark) + if (item.type & UrlSearchItem::Bookmark) { return new PreviewListItem(item, text, parent); } - if(item.type & UrlSearchItem::Suggestion) + if (item.type & UrlSearchItem::Suggestion) { - if(item.description.isEmpty()) + if (item.description.isEmpty()) { return new SuggestionListItem(item, text, parent); } diff --git a/src/urlbar/rsswidget.cpp b/src/urlbar/rsswidget.cpp index c0d78225..a8be8bd5 100644 --- a/src/urlbar/rsswidget.cpp +++ b/src/urlbar/rsswidget.cpp @@ -124,7 +124,7 @@ void RSSWidget::accept() { QString url = m_map.key(m_feeds->currentText()).toMimeDataString(); - if(m_agregators->currentIndex() == 0) + if (m_agregators->currentIndex() == 0) addWithAkregator(url); else addWithGoogleReader(url); @@ -143,12 +143,12 @@ void RSSWidget::addWithGoogleReader(const QString &url) void RSSWidget::addWithAkregator(const QString &url) { // Akregator is running - if(QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.akregator")) + if (QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.akregator")) { QDBusInterface akregator("org.kde.akregator", "/Akregator", "org.kde.akregator.part"); QDBusReply reply = akregator.call("addFeedsToGroup", QStringList(url) , i18n("Imported Feeds")); - if(!reply.isValid()) + if (!reply.isValid()) { KMessageBox::error(0, QString(i18n("Could not add feed to Akregator. Please add it manually:") + "

" + url + "")); @@ -160,7 +160,7 @@ void RSSWidget::addWithAkregator(const QString &url) KProcess proc; proc << "akregator" << "-g" << i18n("Imported Feeds"); proc << "-a" << url; - if(proc.startDetached() == 0) + if (proc.startDetached() == 0) { KMessageBox::error(0, QString(i18n("There was an error. Please verify Akregator is installed on your system.") + "

" + url + "")); diff --git a/src/urlbar/sslwidget.cpp b/src/urlbar/sslwidget.cpp index ce08e974..64275e81 100644 --- a/src/urlbar/sslwidget.cpp +++ b/src/urlbar/sslwidget.cpp @@ -52,13 +52,13 @@ SSLWidget::SSLWidget(const QUrl &url, const WebSslInfo &info, QWidget *parent) QList certList = m_info.certificateChain(); QSslCertificate cert; if (!certList.isEmpty()) - cert = certList.first(); + cert = certList.first(); QList certErrorList = SslInfoDialog::errorsFromString(m_info.certificateErrors()); QStringList firstCertErrorList; if (!certErrorList.isEmpty()) firstCertErrorList = certErrorList.first(); - + QGridLayout *layout = new QGridLayout(this); QLabel *label; @@ -79,7 +79,7 @@ SSLWidget::SSLWidget(const QUrl &url, const WebSslInfo &info, QWidget *parent) label = new QLabel(this); label->setWordWrap(true); - if(cert.isNull()) + if (cert.isNull()) { label->setText(i18n("Warning: this site is NOT carrying a certificate!")); @@ -89,10 +89,10 @@ SSLWidget::SSLWidget(const QUrl &url, const WebSslInfo &info, QWidget *parent) } else { - if(cert.isValid() && firstCertErrorList.isEmpty()) + if (cert.isValid() && firstCertErrorList.isEmpty()) { label->setText(i18n("The certificate for this site is valid and has been verified by:\n%1.", - Qt::escape(cert.issuerInfo(QSslCertificate::CommonName)) )); + Qt::escape(cert.issuerInfo(QSslCertificate::CommonName)))); imageLabel->setPixmap(KIcon("security-high").pixmap(32)); } @@ -145,7 +145,7 @@ SSLWidget::SSLWidget(const QUrl &url, const WebSslInfo &info, QWidget *parent) { label = new QLabel(this); label->setWordWrap(true); - label->setText( i18n("Your connection to \"%1\" is encrypted!\n", m_url.host()) ); + label->setText(i18n("Your connection to \"%1\" is encrypted!\n", m_url.host())); layout->addWidget(label, rows++, 1); QString vers = m_info.protocol(); @@ -173,7 +173,7 @@ SSLWidget::SSLWidget(const QUrl &url, const WebSslInfo &info, QWidget *parent) label = new QLabel(this); label->setWordWrap(true); - label->setText( i18n("It uses protocol: %1.\n", sslVersion) ); + label->setText(i18n("It uses protocol: %1.\n", sslVersion)); layout->addWidget(label, rows++, 1); const QStringList cipherInfo = m_info.ciphers().split('\n', QString::SkipEmptyParts); @@ -186,7 +186,7 @@ SSLWidget::SSLWidget(const QUrl &url, const WebSslInfo &info, QWidget *parent) cipherInfo[3], cipherInfo[2], cipherInfo[1]) - ); + ); layout->addWidget(label, rows++, 1); } @@ -208,7 +208,7 @@ SSLWidget::SSLWidget(const QUrl &url, const WebSslInfo &info, QWidget *parent) HistoryItem firstVisit = rApp->historyManager()->find(url.toString()).first(); - if(firstVisit.visitCount == 1) + if (firstVisit.visitCount == 1) { label->setText(i18n("It is your first time visiting this site!")); imageLabel->setPixmap(KIcon("security-medium").pixmap(32)); diff --git a/src/urlbar/stackedurlbar.cpp b/src/urlbar/stackedurlbar.cpp index 745818e3..728a9c1b 100644 --- a/src/urlbar/stackedurlbar.cpp +++ b/src/urlbar/stackedurlbar.cpp @@ -51,7 +51,7 @@ UrlBar *StackedUrlBar::currentUrlBar() UrlBar *StackedUrlBar::urlBar(int index) { UrlBar *urlBar = qobject_cast(QStackedWidget::widget(index)); - if(!urlBar) + if (!urlBar) { kWarning() << "URL bar with index" << index << "not found. Returning NULL. line:" << __LINE__; } diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp index a5d225dd..0d17f6cf 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -136,7 +136,7 @@ UrlBar::~UrlBar() void UrlBar::setQUrl(const QUrl& url) { - if(url.scheme() == QL1S("about")) + if (url.scheme() == QL1S("about")) { clear(); setFocus(); @@ -166,7 +166,7 @@ void UrlBar::paintEvent(QPaintEvent *event) QColor backgroundColor; QColor foregroundColor; - if(QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) + if (QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) { backgroundColor = QColor(220, 220, 220); // light gray foregroundColor = Qt::black; @@ -181,9 +181,9 @@ void UrlBar::paintEvent(QPaintEvent *event) QPalette p = palette(); int progr = _tab->progress(); - if(progr == 0) + if (progr == 0) { - if(_tab->url().scheme() == QL1S("https")) + if (_tab->url().scheme() == QL1S("https")) { backgroundColor = _tab->page()->hasSslValid() ? colorScheme.background(KColorScheme::PositiveBackground).color() @@ -204,7 +204,7 @@ void UrlBar::paintEvent(QPaintEvent *event) QColor loadingColor(r, g, b); - if(abs(loadingColor.lightness() - backgroundColor.lightness()) < 20) //eg. Gaia color scheme + if (abs(loadingColor.lightness() - backgroundColor.lightness()) < 20) //eg. Gaia color scheme { r = (2 * highlight.red() + backgroundColor.red()) / 3; g = (2 * highlight.green() + backgroundColor.green()) / 3; @@ -223,7 +223,7 @@ void UrlBar::paintEvent(QPaintEvent *event) // you need this before our code to draw inside the line edit.. KLineEdit::paintEvent(event); - if(text().isEmpty() && progr == 0) + if (text().isEmpty() && progr == 0) { QStyleOptionFrame option; initStyleOption(&option); @@ -242,36 +242,36 @@ void UrlBar::keyPressEvent(QKeyEvent *event) { // this handles the Modifiers + Return key combinations QString currentText = text().trimmed(); - if(event->modifiers() == Qt::AltModifier) + if (event->modifiers() == Qt::AltModifier) { - if(event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) + if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) { activated(currentText, Rekonq::NewFocusedTab); } } - if((event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) + if ((event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) && !currentText.startsWith(QL1S("http://"), Qt::CaseInsensitive) && event->modifiers() != Qt::NoModifier) { QString append; - if(event->modifiers() == Qt::ControlModifier) + if (event->modifiers() == Qt::ControlModifier) { append = QL1S(".com"); } - else if(event->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) + else if (event->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) { append = QL1S(".org"); } - else if(event->modifiers() == Qt::ShiftModifier) + else if (event->modifiers() == Qt::ShiftModifier) { append = QL1S(".net"); } - if(!append.isEmpty()) + if (!append.isEmpty()) { QUrl url(QL1S("http://www.") + currentText); QString host = url.host(); - if(!host.endsWith(append, Qt::CaseInsensitive)) + if (!host.endsWith(append, Qt::CaseInsensitive)) { host += append; url.setHost(host); @@ -282,16 +282,16 @@ void UrlBar::keyPressEvent(QKeyEvent *event) } } - else if((event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) - && !currentText.isEmpty()) + else if ((event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) + && !currentText.isEmpty()) { loadTyped(currentText); } - else if(event->key() == Qt::Key_Escape) + else if (event->key() == Qt::Key_Escape) { clearFocus(); - if(text() != rApp->mainWindow()->currentTab()->view()->url().toString() + if (text() != rApp->mainWindow()->currentTab()->view()->url().toString() && !rApp->mainWindow()->currentTab()->view()->url().toString().startsWith("about")) setText(rApp->mainWindow()->currentTab()->view()->url().toString()); event->accept(); @@ -312,11 +312,11 @@ void UrlBar::focusInEvent(QFocusEvent *event) void UrlBar::dropEvent(QDropEvent *event) { // handles only plain-text with url format - if(event->mimeData()->hasFormat("text/plain") && event->source() != this) + if (event->mimeData()->hasFormat("text/plain") && event->source() != this) { QUrl url = QUrl::fromUserInput(event->mimeData()->data("text/plain")); - if(url.isValid()) + if (url.isValid()) { setQUrl(url); activated(text()); @@ -332,14 +332,14 @@ void UrlBar::dropEvent(QDropEvent *event) void UrlBar::loadFinished() { - if(_tab->url().scheme() == QL1S("about")) + if (_tab->url().scheme() == QL1S("about")) { update(); return; } // show Favorite Icon - if(ReKonfig::previewUrls().contains(_tab->url().url())) + if (ReKonfig::previewUrls().contains(_tab->url().url())) { IconButton *bt = addRightIcon(UrlBar::Favorite); connect(bt, SIGNAL(clicked(QPoint)), this, SLOT(showFavoriteDialog(QPoint))); @@ -350,21 +350,21 @@ void UrlBar::loadFinished() connect(bt, SIGNAL(clicked(QPoint)), this, SLOT(showBookmarkInfo(QPoint))); // show KGet downloads?? - if(!KStandardDirs::findExe("kget").isNull() && ReKonfig::kgetList()) + if (!KStandardDirs::findExe("kget").isNull() && ReKonfig::kgetList()) { IconButton *bt = addRightIcon(UrlBar::KGet); connect(bt, SIGNAL(clicked(QPoint)), _tab->page(), SLOT(downloadAllContentsWithKGet(QPoint))); } // show RSS - if(_tab->hasRSSInfo()) + if (_tab->hasRSSInfo()) { IconButton *bt = addRightIcon(UrlBar::RSS); connect(bt, SIGNAL(clicked(QPoint)), _tab, SLOT(showRSSInfo(QPoint))); } // show SSL - if(_tab->url().scheme() == QL1S("https")) + if (_tab->url().scheme() == QL1S("https")) { // NOTE: the choice for the right SSL icon is done in the addRightIcon method IconButton *bt = addRightIcon(UrlBar::SSL); @@ -372,7 +372,7 @@ void UrlBar::loadFinished() } // show add search engine - if(_tab->hasNewSearchEngine()) + if (_tab->hasNewSearchEngine()) { IconButton *bt = addRightIcon(UrlBar::SearchEngine); connect(bt, SIGNAL(clicked(QPoint)), _tab, SLOT(showSearchEngine(QPoint))); @@ -394,12 +394,12 @@ void UrlBar::showBookmarkDialog() void UrlBar::showBookmarkInfo(QPoint pos) { - if(_tab->url().scheme() == QL1S("about")) + if (_tab->url().scheme() == QL1S("about")) return; KBookmark bookmark = rApp->bookmarkProvider()->bookmarkForUrl(_tab->url()); - if(bookmark.isNull()) + if (bookmark.isNull()) { bookmark = rApp->bookmarkProvider()->bookmarkOwner()->bookmarkCurrentPage(); updateRightIcons(); @@ -415,7 +415,7 @@ void UrlBar::showBookmarkInfo(QPoint pos) void UrlBar::updateRightIcons() { - if(!_tab->isPageLoading()) + if (!_tab->isPageLoading()) { clearRightIcons(); loadFinished(); @@ -431,9 +431,9 @@ void UrlBar::loadTyped(const QString &text) void UrlBar::activateSuggestions(bool b) { - if(b) + if (b) { - if(_box.isNull()) + if (_box.isNull()) { _box = new CompletionWidget(this); installEventFilter(_box.data()); @@ -464,7 +464,7 @@ IconButton *UrlBar::addRightIcon(UrlBar::icon ic) { IconButton *rightIcon = new IconButton(this); - switch(ic) + switch (ic) { case UrlBar::KGet: rightIcon->setIcon(KIcon("download")); @@ -481,7 +481,7 @@ IconButton *UrlBar::addRightIcon(UrlBar::icon ic) rightIcon->setToolTip(i18n("Show SSL Info")); break; case UrlBar::BK: - if(rApp->bookmarkProvider()->bookmarkForUrl(_tab->url()).isNull()) + if (rApp->bookmarkProvider()->bookmarkForUrl(_tab->url()).isNull()) { rightIcon->setIcon(KIcon("bookmarks").pixmap(32, 32, QIcon::Disabled)); rightIcon->setToolTip(i18n("Bookmark this page")); @@ -497,7 +497,7 @@ IconButton *UrlBar::addRightIcon(UrlBar::icon ic) case UrlBar::SearchEngine: { KIcon wsIcon("edit-web-search"); - if(wsIcon.isNull()) + if (wsIcon.isNull()) { wsIcon = KIcon("preferences-web-browser-shortcuts"); } @@ -539,7 +539,7 @@ void UrlBar::resizeEvent(QResizeEvent *event) int iconsCount = _rightIconsList.count(); int w = width(); - for(int i = 0; i < iconsCount; ++i) + for (int i = 0; i < iconsCount; ++i) { IconButton *bt = _rightIconsList.at(i); bt->move(w - 25 * (i + 1), newHeight); @@ -551,13 +551,13 @@ void UrlBar::resizeEvent(QResizeEvent *event) void UrlBar::detectTypedString(const QString &typed) { - if(typed.count() == 1) + if (typed.count() == 1) { QTimer::singleShot(0, this, SLOT(suggest())); return; } - if(_suggestionTimer->isActive()) + if (_suggestionTimer->isActive()) _suggestionTimer->stop(); _suggestionTimer->start(50); } @@ -565,21 +565,21 @@ void UrlBar::detectTypedString(const QString &typed) void UrlBar::suggest() { - if(!_box.isNull()) + if (!_box.isNull()) _box.data()->suggestUrls(text()); } void UrlBar::refreshFavicon() { - if(QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) + if (QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) { _icon->setIcon(KIcon("view-media-artist")); return; } KUrl u = _tab->url(); - if(u.scheme() == QL1S("about")) + if (u.scheme() == QL1S("about")) { _icon->setIcon(KIcon("arrow-right")); return; @@ -590,11 +590,11 @@ void UrlBar::refreshFavicon() void UrlBar::showFavoriteDialog(QPoint pos) { - if(_tab->url().scheme() == QL1S("about")) + if (_tab->url().scheme() == QL1S("about")) return; IconButton *bt = qobject_cast(this->sender()); - if(!bt) + if (!bt) return; FavoriteWidget *widget = new FavoriteWidget(_tab, window()); @@ -610,14 +610,14 @@ void UrlBar::bookmarkContextMenu(QPoint pos) KMenu menu(this); QAction *qa; - if(!rApp->bookmarkProvider()->bookmarkForUrl(_tab->url()).isNull()) + if (!rApp->bookmarkProvider()->bookmarkForUrl(_tab->url()).isNull()) { qa = new KAction(KIcon("bookmarks"), i18n("Edit Bookmark"), this); connect(qa, SIGNAL(triggered(bool)), this, SLOT(showBookmarkDialog())); menu.addAction(qa); } - if(!ReKonfig::previewUrls().contains(_tab->url().url())) + if (!ReKonfig::previewUrls().contains(_tab->url().url())) { qa = new KAction(KIcon("emblem-favorite"), i18n("Add to favorite"), this); connect(qa, SIGNAL(triggered(bool)), this, SLOT(addFavorite())); @@ -631,7 +631,7 @@ void UrlBar::bookmarkContextMenu(QPoint pos) void UrlBar::addFavorite() { - if(ReKonfig::previewUrls().contains(_tab->url().url())) + if (ReKonfig::previewUrls().contains(_tab->url().url())) return; QStringList urls = ReKonfig::previewUrls(); diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp index 0ff00bba..e8352e44 100644 --- a/src/urlbar/urlresolver.cpp +++ b/src/urlbar/urlresolver.cpp @@ -71,13 +71,13 @@ UrlResolver::UrlResolver(const QString &typedUrl) , _typedString(typedUrl.trimmed()) , _typedQuery() { - if(!_searchEngine) + if (!_searchEngine) setSearchEngine(SearchEngine::defaultEngine()); - if(_browseRegexp.isEmpty()) + if (_browseRegexp.isEmpty()) { // FIXME move to use QL1S here!!! - + QString protocol = QString("^(%1)").arg(KProtocolInfo::protocols().join("|")); QString localhost = "^localhost"; @@ -100,14 +100,14 @@ UrlResolver::UrlResolver(const QString &typedUrl) _browseRegexp = QRegExp('(' + protocol + ")|(" + localhost + ")|(" + local + ")|(" + address + ")|(" + ipv6 + ")|(" + ipv4 + ')'); } - if(_searchEnginesRegexp.isEmpty()) + if (_searchEnginesRegexp.isEmpty()) { QString reg; QString engineUrl; Q_FOREACH(KService::Ptr s, SearchEngine::favorites()) { engineUrl = QRegExp::escape(s->property("Query").toString()).replace("\\\\\\{@\\}", "[\\d\\w-.]+"); - if(reg.isEmpty()) + if (reg.isEmpty()) reg = '(' + engineUrl + ')'; else reg = reg + "|(" + engineUrl + ')'; @@ -119,7 +119,7 @@ UrlResolver::UrlResolver(const QString &typedUrl) UrlSearchList UrlResolver::orderedSearchItems() { - if(_typedString.startsWith(QL1S("about:"))) + if (_typedString.startsWith(QL1S("about:"))) { UrlSearchList list; UrlSearchItem home(UrlSearchItem::Browse, QString("about:home"), QL1S("home")); @@ -162,7 +162,7 @@ UrlSearchList UrlResolver::orderLists() UrlSearchList list; - if(_browseRegexp.indexIn(_typedString) != -1) + if (_browseRegexp.indexIn(_typedString) != -1) { list << _qurlFromUserInput; list << _webSearches; @@ -183,19 +183,19 @@ UrlSearchList UrlResolver::orderLists() // prefer items which are history items as well bookmarks item // if there are more than 1000 bookmark results, the performance impact is noticeable - if(bookmarksCount < 1000) + if (bookmarksCount < 1000) { //add as many items to the common list as there are available entries in the dropdown list UrlSearchItem urlSearchItem; - for(int i = 0; i < _history.count(); i++) + for (int i = 0; i < _history.count(); i++) { - if(_bookmarks.removeOne(_history.at(i))) + if (_bookmarks.removeOne(_history.at(i))) { urlSearchItem = _history.takeAt(i); urlSearchItem.type |= UrlSearchItem::Bookmark; common << urlSearchItem; commonCount++; - if(commonCount >= availableEntries) + if (commonCount >= availableEntries) { break; } @@ -203,7 +203,7 @@ UrlSearchList UrlResolver::orderLists() } commonCount = common.count(); - if(commonCount >= availableEntries) + if (commonCount >= availableEntries) { common = common.mid(0, availableEntries); _history = UrlSearchList(); @@ -213,11 +213,11 @@ UrlSearchList UrlResolver::orderLists() else //remove all items from the history and bookmarks list up to the remaining entries in the dropdown list { availableEntries -= commonCount; - if(historyCount >= availableEntries) + if (historyCount >= availableEntries) { _history = _history.mid(0, availableEntries); } - if(bookmarksCount >= availableEntries) + if (bookmarksCount >= availableEntries) { _bookmarks = _bookmarks.mid(0, availableEntries); } @@ -226,19 +226,19 @@ UrlSearchList UrlResolver::orderLists() else //if there are too many bookmarks items, remove all items up to the remaining entries in the dropdown list { - if(historyCount >= availableEntries) + if (historyCount >= availableEntries) { _history = _history.mid(0, availableEntries); } - if(bookmarksCount >= availableEntries) + if (bookmarksCount >= availableEntries) { _bookmarks = _bookmarks.mid(0, availableEntries); } UrlSearchItem urlSearchItem; - for(int i = 0; i < _history.count(); i++) + for (int i = 0; i < _history.count(); i++) { - if(_bookmarks.removeOne(_history.at(i))) + if (_bookmarks.removeOne(_history.at(i))) { urlSearchItem = _history.takeAt(i); urlSearchItem.type |= UrlSearchItem::Bookmark; @@ -254,26 +254,26 @@ UrlSearchList UrlResolver::orderLists() commonCount = common.count(); //now fill the list to MAX_ELEMENTS - if(availableEntries > 0) + if (availableEntries > 0) { int historyEntries = ((int)(availableEntries / 2)) + availableEntries % 2; int bookmarksEntries = availableEntries - historyEntries; - if(historyCount >= historyEntries && bookmarksCount >= bookmarksEntries) + if (historyCount >= historyEntries && bookmarksCount >= bookmarksEntries) { _history = _history.mid(0, historyEntries); _bookmarks = _bookmarks.mid(0, bookmarksEntries); } - else if(historyCount < historyEntries && bookmarksCount >= bookmarksEntries) + else if (historyCount < historyEntries && bookmarksCount >= bookmarksEntries) { - if(historyCount + bookmarksCount > availableEntries) + if (historyCount + bookmarksCount > availableEntries) { _bookmarks = _bookmarks.mid(0, availableEntries - historyCount); } } - else if(historyCount >= historyEntries && bookmarksCount < bookmarksEntries) + else if (historyCount >= historyEntries && bookmarksCount < bookmarksEntries) { - if(historyCount + bookmarksCount > availableEntries) + if (historyCount + bookmarksCount > availableEntries) { _history = _history.mid(0, availableEntries - bookmarksCount); } @@ -283,7 +283,7 @@ UrlSearchList UrlResolver::orderLists() availableEntries -= _history.count(); availableEntries -= _bookmarks.count(); - if(_suggestions.count() > availableEntries + MIN_SUGGESTIONS) + if (_suggestions.count() > availableEntries + MIN_SUGGESTIONS) { _suggestions = _suggestions.mid(0, availableEntries + MIN_SUGGESTIONS); } @@ -302,7 +302,7 @@ void UrlResolver::computeQurlFromUserInput() { QString url = _typedString; QUrl urlFromUserInput = QUrl::fromUserInput(url); - if(urlFromUserInput.isValid()) + if (urlFromUserInput.isValid()) { QString gTitle = i18nc("Browse a website", "Browse"); UrlSearchItem gItem(UrlSearchItem::Browse, urlFromUserInput.toString(), gTitle); @@ -316,13 +316,13 @@ void UrlResolver::computeWebSearches() { QString query = _typedString; KService::Ptr engine = SearchEngine::fromString(_typedString); - if(engine) + if (engine) { query = query.remove(0, _typedString.indexOf(SearchEngine::delimiter()) + 1); setSearchEngine(engine); } - if(_searchEngine) + if (_searchEngine) { UrlSearchItem item = UrlSearchItem(UrlSearchItem::Search, SearchEngine::buildQuery(_searchEngine, query), query); UrlSearchList list; @@ -340,7 +340,7 @@ void UrlResolver::computeHistory() Q_FOREACH(const HistoryItem & i, found) { - if(_searchEnginesRegexp.indexIn(i.url) == -1) //filter all urls that are search engine results + if (_searchEnginesRegexp.indexIn(i.url) == -1) //filter all urls that are search engine results { UrlSearchItem gItem(UrlSearchItem::History, i.url, i.title); _history << gItem; @@ -366,7 +366,7 @@ void UrlResolver::computeSuggestions() { // if a string startsWith /, it is probably a local path // so, no need for suggestions... - if(_typedString.startsWith('/') || !rApp->opensearchManager()->isSuggestionAvailable()) + if (_typedString.startsWith('/') || !rApp->opensearchManager()->isSuggestionAvailable()) { UrlSearchList list; emit suggestionsReady(list, _typedString); @@ -375,7 +375,7 @@ void UrlResolver::computeSuggestions() QString query = _typedString; KService::Ptr engine = SearchEngine::fromString(_typedString); - if(engine) + if (engine) { query = query.remove(0, _typedString.indexOf(SearchEngine::delimiter()) + 1); setSearchEngine(engine); @@ -393,7 +393,7 @@ void UrlResolver::computeSuggestions() void UrlResolver::suggestionsReceived(const QString &text, const ResponseList &suggestions) { - if(text != _typedQuery) + if (text != _typedQuery) return; UrlSearchList sugList; @@ -401,7 +401,7 @@ void UrlResolver::suggestionsReceived(const QString &text, const ResponseList &s Q_FOREACH(const Response & i, suggestions) { urlString = i.url; - if(urlString.isEmpty()) + if (urlString.isEmpty()) { urlString = SearchEngine::buildQuery(UrlResolver::searchEngine(), i.title); } diff --git a/src/urlbar/urlresolver.h b/src/urlbar/urlresolver.h index 510ab328..cc429fa0 100644 --- a/src/urlbar/urlresolver.h +++ b/src/urlbar/urlresolver.h @@ -132,7 +132,7 @@ public: static void setSearchEngine(KService::Ptr engine) { _searchEngine = engine; - if(engine) + if (engine) rApp->opensearchManager()->setSearchProvider(engine->desktopEntryName()); }; diff --git a/src/urlbar/webshortcutwidget.cpp b/src/urlbar/webshortcutwidget.cpp index 492f2d83..495e0d2e 100644 --- a/src/urlbar/webshortcutwidget.cpp +++ b/src/urlbar/webshortcutwidget.cpp @@ -45,7 +45,7 @@ WebShortcutWidget::WebShortcutWidget(QWidget *parent) QLabel *iconLabel = new QLabel(this); KIcon wsIcon("edit-web-search"); - if(wsIcon.isNull()) + if (wsIcon.isNull()) { wsIcon = KIcon("preferences-web-browser-shortcuts"); } @@ -158,7 +158,7 @@ void WebShortcutWidget::shortcutsChanged(const QString& newShorthands) { Q_FOREACH(KService::Ptr provider, m_providers) { - if(provider->property("Keys").toStringList().contains(shorthand)) + if (provider->property("Keys").toStringList().contains(shorthand)) { contenderName = provider->property("Name").toString(); contenderWS = shorthand; @@ -167,7 +167,7 @@ void WebShortcutWidget::shortcutsChanged(const QString& newShorthands) } } - if(!contenderName.isEmpty()) + if (!contenderName.isEmpty()) { m_okButton->setEnabled(false); m_noteLabel->setText(i18n("The shortcut \"%1\" is already assigned to \"%2\".", contenderWS, contenderName)); @@ -180,7 +180,7 @@ void WebShortcutWidget::shortcutsChanged(const QString& newShorthands) m_noteLabel->clear(); bool noteIsVisible = m_noteLabel->isVisible(); m_noteLabel->setVisible(false); - if(noteIsVisible) + if (noteIsVisible) { resize(minimumSize()); } -- cgit v1.2.1