From 6874df57d7a07466accd2c8dc3ad05ffd737e552 Mon Sep 17 00:00:00 2001 From: nowrep Date: Sat, 5 Apr 2014 14:42:19 +0200 Subject: [PATCH] [Coding Style] Edited coding style (use linux style brackets) Linux style brackets are now used also for source files. One line blocks can now be without brackets. Example: if (test) foo(); Multi-line if statements are now written with conditionals (||, &&, ...) at the end of line. The last line of if body does not ends with closing bracket, instead the closing bracket is written on separate line. One line blocks in multi-line if statements should not be without brackets. Example: if (test || test2 && test3 ) { foo(); } [ci skip] --- scripts/coding_style.sh | 26 +++--- src/lib/3rdparty/qftp/qftp.cpp | 3 +- src/lib/adblock/adblockrule.cpp | 18 ++-- src/lib/app/commandlineoptions.cpp | 11 ++- .../databaseencryptedpasswordbackend.cpp | 2 +- src/lib/bookmarks/bookmarks.cpp | 7 +- .../bookmarksimport/htmlimporter.cpp | 4 +- src/lib/downloads/downloaditem.cpp | 5 +- src/lib/history/history.cpp | 9 +- src/lib/history/historyview.cpp | 5 +- src/lib/navigation/locationbar.cpp | 3 +- src/lib/network/pac/proxyautoconfig.cpp | 4 +- .../schemehandlers/ftpschemehandler.cpp | 5 +- src/lib/opensearch/opensearchreader.cpp | 33 ++++---- src/lib/opensearch/searchenginesmanager.cpp | 7 +- src/lib/other/registerqappassociation.cpp | 21 +++-- .../plugins/qtwebkit/spellcheck/speller.cpp | 6 +- src/lib/popupwindow/popupwebpage.cpp | 5 +- src/lib/tabwidget/combotabbar.cpp | 3 +- src/lib/tabwidget/tabstackedwidget.cpp | 6 +- src/lib/tools/qztools.cpp | 82 +++++++++---------- src/lib/webkit/webview.cpp | 10 ++- .../AccessKeysNavigation/akn_handler.cpp | 21 +++-- src/plugins/MouseGestures/mousegestures.cpp | 3 +- 24 files changed, 165 insertions(+), 134 deletions(-) diff --git a/scripts/coding_style.sh b/scripts/coding_style.sh index 631bde4c5..e37114d14 100755 --- a/scripts/coding_style.sh +++ b/scripts/coding_style.sh @@ -5,28 +5,24 @@ # normalize (Qt tool to normalize all signal/slots format) # -function format_sources { - astyle --indent=spaces=4 --style=1tbs \ - --indent-labels --pad-oper --unpad-paren --pad-header \ - --convert-tabs --indent-preprocessor --break-closing-brackets \ - --align-pointer=type --align-reference=name \ - `find -type f -name '*.cpp'` | grep 'Formatted' +OPTIONS="--indent=spaces=4 --style=linux + --pad-oper --unpad-paren --pad-header --convert-tabs + --indent-preprocessor --break-closing-brackets + --align-pointer=type --align-reference=name + --suffix=none --formatted" - find . -name "*.orig" -print0 | xargs -0 rm -rf +function format_sources { + astyle $OPTIONS \ + `find -type f \( -name '*.cpp' -not -name 'moc_*.cpp' \)` } function format_headers { - astyle --indent=spaces=4 --style=linux \ - --indent-labels --pad-oper --unpad-paren --pad-header \ - --keep-one-line-statements --keep-one-line-blocks \ - --indent-preprocessor --convert-tabs \ - --align-pointer=type --align-reference=name \ - `find -type f -name '*.h'` | grep 'Formatted' - - find . -name "*.orig" -print0 | xargs -0 rm -rf + astyle $OPTIONS --keep-one-line-statements --keep-one-line-blocks \ + `find -type f -name '*.h'` } cd ../src + echo "Running astyle for *.cpp ..." format_sources diff --git a/src/lib/3rdparty/qftp/qftp.cpp b/src/lib/3rdparty/qftp/qftp.cpp index 2af643f0b..7757f61f2 100644 --- a/src/lib/3rdparty/qftp/qftp.cpp +++ b/src/lib/3rdparty/qftp/qftp.cpp @@ -1149,7 +1149,8 @@ bool QFtpPI::processReply() } else if (replyCodeInt == 230) { if (currentCmd.startsWith(QLatin1String("USER ")) && pendingCommands.count() > 0 && - pendingCommands.first().startsWith(QLatin1String("PASS "))) { + pendingCommands.first().startsWith(QLatin1String("PASS ")) + ) { // no need to send the PASS -- we are already logged in pendingCommands.pop_front(); } diff --git a/src/lib/adblock/adblockrule.cpp b/src/lib/adblock/adblockrule.cpp index 3f93733bd..8dc384e5b 100644 --- a/src/lib/adblock/adblockrule.cpp +++ b/src/lib/adblock/adblockrule.cpp @@ -477,8 +477,10 @@ void AdBlockRule::parseFilter() } // We can use fast string matching for domain here - if (parsedLine.startsWith(QLatin1String("||")) && parsedLine.endsWith(QLatin1Char('^')) - && !parsedLine.contains(QzRegExp("[/:?=&\\*]"))) { + if (parsedLine.startsWith(QLatin1String("||")) && + parsedLine.endsWith(QLatin1Char('^')) && + !parsedLine.contains(QzRegExp("[/:?=&\\*]")) + ) { parsedLine = parsedLine.mid(2); parsedLine = parsedLine.left(parsedLine.size() - 1); @@ -488,8 +490,10 @@ void AdBlockRule::parseFilter() } // If rule contains only | at end, we can also use string matching - if (parsedLine.endsWith(QLatin1Char('|')) && !parsedLine.contains(QzRegExp("[\\^\\*]")) - && parsedLine.count(QLatin1Char('|')) == 1) { + if (parsedLine.endsWith(QLatin1Char('|')) && + parsedLine.count(QLatin1Char('|')) == 1 && + !parsedLine.contains(QzRegExp("[\\^\\*]")) + ) { parsedLine = parsedLine.left(parsedLine.size() - 1); m_type = StringEndsMatchRule; @@ -499,8 +503,10 @@ void AdBlockRule::parseFilter() // If we still find a wildcard (*) or separator (^) or (|) // we must modify parsedLine to comply with QzRegExp - if (parsedLine.contains(QLatin1Char('*')) || parsedLine.contains(QLatin1Char('^')) - || parsedLine.contains(QLatin1Char('|'))) { + if (parsedLine.contains(QLatin1Char('*')) || + parsedLine.contains(QLatin1Char('^')) || + parsedLine.contains(QLatin1Char('|')) + ) { QString parsedRegExp = parsedLine; parsedRegExp.replace(QzRegExp(QLatin1String("\\*+")), QLatin1String("*")) // remove multiple wildcards diff --git a/src/lib/app/commandlineoptions.cpp b/src/lib/app/commandlineoptions.cpp index c0a3867cc..01a071437 100644 --- a/src/lib/app/commandlineoptions.cpp +++ b/src/lib/app/commandlineoptions.cpp @@ -198,9 +198,14 @@ void CommandLineOptions::parseActions() url = fileInfo.absoluteFilePath(); } - if (m_argc > 1 && !url.isEmpty() && !url.startsWith(QLatin1Char('-')) && - (url.contains(QLatin1Char('.')) || url.contains(QLatin1Char('/')) - || url.contains(QLatin1Char('\\')))) { + if (m_argc > 1 && + !url.isEmpty() && + !url.startsWith(QLatin1Char('-')) && + (url.contains(QLatin1Char('.')) || + url.contains(QLatin1Char('/')) || + url.contains(QLatin1Char('\\')) + ) + ) { ActionPair pair; pair.action = Qz::CL_OpenUrl; pair.text = url; diff --git a/src/lib/autofill/passwordbackends/databaseencryptedpasswordbackend.cpp b/src/lib/autofill/passwordbackends/databaseencryptedpasswordbackend.cpp index 819400804..780673993 100644 --- a/src/lib/autofill/passwordbackends/databaseencryptedpasswordbackend.cpp +++ b/src/lib/autofill/passwordbackends/databaseencryptedpasswordbackend.cpp @@ -609,7 +609,7 @@ void MasterPasswordDialog::showSetMasterPasswordPage() void MasterPasswordDialog::clearMasterPasswordAndConvert(bool forcedAskPass) { if (QMessageBox::information(this, tr("Warning!"), tr("Are you sure to clear master password and decrypt data?"), QMessageBox::Yes | QMessageBox::No) - == QMessageBox::No) { + == QMessageBox::No) { reject(); return; } diff --git a/src/lib/bookmarks/bookmarks.cpp b/src/lib/bookmarks/bookmarks.cpp index d6f186f99..d72d03689 100644 --- a/src/lib/bookmarks/bookmarks.cpp +++ b/src/lib/bookmarks/bookmarks.cpp @@ -420,9 +420,10 @@ void Bookmarks::search(QList* items, BookmarkItem* parent, const case BookmarkItem::Url: if (parent->title().contains(string, sensitive) || - parent->urlString().contains(string, sensitive) || - parent->description().contains(string, sensitive) || - parent->keyword().compare(string, sensitive) == 0) { + parent->urlString().contains(string, sensitive) || + parent->description().contains(string, sensitive) || + parent->keyword().compare(string, sensitive) == 0 + ) { items->append(parent); } break; diff --git a/src/lib/bookmarks/bookmarksimport/htmlimporter.cpp b/src/lib/bookmarks/bookmarksimport/htmlimporter.cpp index 6ac0ea9a4..3c3a5b68e 100644 --- a/src/lib/bookmarks/bookmarksimport/htmlimporter.cpp +++ b/src/lib/bookmarks/bookmarksimport/htmlimporter.cpp @@ -152,10 +152,8 @@ BookmarkItem* HtmlImporter::importBookmarks() start += posOfLink + rx.cap(0).size(); - if (linkName.isEmpty() || url.isEmpty() || url.scheme() == QLatin1String("place") - || url.scheme() == QLatin1String("about")) { + if (linkName.isEmpty() || url.isEmpty() || url.scheme() == QL1S("place") || url.scheme() == QL1S("about")) continue; - } BookmarkItem* b = new BookmarkItem(BookmarkItem::Url, folders.isEmpty() ? root : folders.last()); b->setTitle(linkName); diff --git a/src/lib/downloads/downloaditem.cpp b/src/lib/downloads/downloaditem.cpp index 2ddceee49..99e2059c3 100644 --- a/src/lib/downloads/downloaditem.cpp +++ b/src/lib/downloads/downloaditem.cpp @@ -469,7 +469,10 @@ void DownloadItem::updateDownload() // after caling stop() (from readyRead()) m_reply will be a dangling pointer, // thus it should be checked after m_outputFile.isOpen() if (ui->progressBar->maximum() == 0 && m_outputFile.isOpen() && - ((m_reply && m_reply->isFinished()) || (m_ftpDownloader && m_ftpDownloader->isFinished()))) { + ((m_reply && m_reply->isFinished()) || + (m_ftpDownloader && m_ftpDownloader->isFinished()) + ) + ) { downloadProgress(0, 0); finished(); } diff --git a/src/lib/history/history.cpp b/src/lib/history/history.cpp index 6c687de70..b38af7f53 100644 --- a/src/lib/history/history.cpp +++ b/src/lib/history/history.cpp @@ -68,10 +68,11 @@ void History::addHistoryEntry(const QUrl &url, QString title) if (!m_isSaving) { return; } - if (url.scheme() == QLatin1String("qupzilla") || - url.scheme() == QLatin1String("about") || - url.scheme() == QLatin1String("data") || - url.isEmpty()) { + if (url.isEmpty() || + url.scheme() == QLatin1String("qupzilla") || + url.scheme() == QLatin1String("about") || + url.scheme() == QLatin1String("data") + ) { return; } diff --git a/src/lib/history/historyview.cpp b/src/lib/history/historyview.cpp index 58e01d666..9cfc83cf2 100644 --- a/src/lib/history/historyview.cpp +++ b/src/lib/history/historyview.cpp @@ -110,8 +110,9 @@ void HistoryView::itemPressed(const QModelIndex &index) return; } - if ((selectionMode() == QAbstractItemView::SingleSelection && QApplication::keyboardModifiers() & Qt::ControlModifier) - || (QApplication::mouseButtons() & Qt::MiddleButton)) { + if ((selectionMode() == QAbstractItemView::SingleSelection && QApplication::keyboardModifiers() & Qt::ControlModifier) || + QApplication::mouseButtons() & Qt::MiddleButton + ) { emit openLink(index.data(HistoryModel::UrlRole).toUrl(), OpenInNewTab); } } diff --git a/src/lib/navigation/locationbar.cpp b/src/lib/navigation/locationbar.cpp index 9fc7008af..baf59b367 100644 --- a/src/lib/navigation/locationbar.cpp +++ b/src/lib/navigation/locationbar.cpp @@ -515,7 +515,8 @@ void LocationBar::keyReleaseEvent(QKeyEvent* event) QString localDomain = tr(".co.uk", "Append domain name on ALT + Enter = Should be different for every country"); if (event->key() == Qt::Key_Alt && m_holdingAlt && qzSettings->addCountryWithAlt && - !text().endsWith(localDomain) && !text().endsWith(QLatin1Char('/'))) { + !text().endsWith(localDomain) && !text().endsWith(QLatin1Char('/')) + ) { LineEdit::setText(text().append(localDomain)); } diff --git a/src/lib/network/pac/proxyautoconfig.cpp b/src/lib/network/pac/proxyautoconfig.cpp index 61df6c7df..252b8f97a 100644 --- a/src/lib/network/pac/proxyautoconfig.cpp +++ b/src/lib/network/pac/proxyautoconfig.cpp @@ -228,10 +228,8 @@ QScriptValue ProxyAutoConfig::myIpAddress(QScriptContext* context, QScriptEngine } foreach (QHostAddress address, QNetworkInterface::allAddresses()) { - if (address != QHostAddress::LocalHost - && address != QHostAddress::LocalHostIPv6) { + if (address != QHostAddress::LocalHost && address != QHostAddress::LocalHostIPv6) return QScriptValue(engine, address.toString()); - } } return engine->undefinedValue(); diff --git a/src/lib/network/schemehandlers/ftpschemehandler.cpp b/src/lib/network/schemehandlers/ftpschemehandler.cpp index 8c32578e6..72bab518b 100644 --- a/src/lib/network/schemehandlers/ftpschemehandler.cpp +++ b/src/lib/network/schemehandlers/ftpschemehandler.cpp @@ -482,8 +482,9 @@ QFtp::Error FtpDownloader::error() QString FtpDownloader::errorString() const { if (!m_lastErrorString.isEmpty() - && m_lastError != QFtp::NoError - && QFtp::error() == QFtp::NoError) { + && m_lastError != QFtp::NoError + && QFtp::error() == QFtp::NoError + ) { return m_lastErrorString; } else { diff --git a/src/lib/opensearch/opensearchreader.cpp b/src/lib/opensearch/opensearchreader.cpp index e27da0ae4..e44d5aa8c 100644 --- a/src/lib/opensearch/opensearchreader.cpp +++ b/src/lib/opensearch/opensearchreader.cpp @@ -100,7 +100,8 @@ OpenSearchEngine* OpenSearchReader::read() m_searchXml = device()->peek(1024 * 5); if (!m_searchXml.contains(QLatin1String("http://a9.com/-/spec/opensearch/1.1/")) && - !m_searchXml.contains(QLatin1String("http://www.mozilla.org/2006/browser/search/"))) { + !m_searchXml.contains(QLatin1String("http://www.mozilla.org/2006/browser/search/")) + ) { raiseError(QObject::tr("The file is not an OpenSearch 1.1 file.")); return engine; } @@ -140,15 +141,17 @@ OpenSearchEngine* OpenSearchReader::read() QString url = attributes().value(QLatin1String("template")).toString(); QString method = attributes().value(QLatin1String("method")).toString(); - if (type == QLatin1String("application/x-suggestions+json") - && !engine->suggestionsUrlTemplate().isEmpty()) { + if (type == QLatin1String("application/x-suggestions+json") && + !engine->suggestionsUrlTemplate().isEmpty() + ) { continue; } - if ((type.isEmpty() - || type == QLatin1String("text/html") - || type == QLatin1String("application/xhtml+xml")) - && !engine->searchUrlTemplate().isEmpty()) { + if ((type.isEmpty() || + type == QLatin1String("text/html") || + type == QLatin1String("application/xhtml+xml")) && + !engine->searchUrlTemplate().isEmpty() + ) { continue; } @@ -161,8 +164,9 @@ OpenSearchEngine* OpenSearchReader::read() readNext(); while (!isEndElement() || (name() != QLatin1String("Url") && name() != QLatin1String("os:Url"))) { - if (!isStartElement() || (name() != QLatin1String("Param") && name() != QLatin1String("Parameter") - && name() != QLatin1String("os:Param") && name() != QLatin1String("os:Parameter"))) { + if (!isStartElement() || (name() != QLatin1String("Param") && name() != QLatin1String("Parameter") && + name() != QLatin1String("os:Param") && name() != QLatin1String("os:Parameter")) + ) { readNext(); continue; } @@ -195,11 +199,12 @@ OpenSearchEngine* OpenSearchReader::read() engine->setImageUrl(readElementText()); } - if (!engine->name().isEmpty() - && !engine->description().isEmpty() - && !engine->suggestionsUrlTemplate().isEmpty() - && !engine->searchUrlTemplate().isEmpty() - && !engine->imageUrl().isEmpty()) { + if (!engine->name().isEmpty() && + !engine->description().isEmpty() && + !engine->suggestionsUrlTemplate().isEmpty() && + !engine->searchUrlTemplate().isEmpty() && + !engine->imageUrl().isEmpty() + ) { break; } } diff --git a/src/lib/opensearch/searchenginesmanager.cpp b/src/lib/opensearch/searchenginesmanager.cpp index cc5387005..8f9281ce7 100644 --- a/src/lib/opensearch/searchenginesmanager.cpp +++ b/src/lib/opensearch/searchenginesmanager.cpp @@ -223,9 +223,10 @@ void SearchEnginesManager::engineChangedImage() } foreach (Engine e, m_allEngines) { - if (e.name == engine->name() && e.url.contains(engine->searchUrl("%s").toString()) - && !engine->image().isNull()) { - + if (e.name == engine->name() && + e.url.contains(engine->searchUrl("%s").toString()) && + !engine->image().isNull() + ) { int index = m_allEngines.indexOf(e); if (index != -1) { m_allEngines[index].icon = QIcon(QPixmap::fromImage(engine->image())); diff --git a/src/lib/other/registerqappassociation.cpp b/src/lib/other/registerqappassociation.cpp index 48a3c76a7..a1f001280 100644 --- a/src/lib/other/registerqappassociation.cpp +++ b/src/lib/other/registerqappassociation.cpp @@ -172,9 +172,10 @@ void RegisterQAppAssociation::registerAssociation(const QString &assocName, Asso hr = pAAR->SetAppAsDefault(_appRegisteredName.toStdWString().c_str(), assocName.toStdWString().c_str(), AT_URLPROTOCOL); - if (SUCCEEDED(hr) - && !currentUrlDefault.isEmpty() - && currentUrlDefault != _urlAssocHash.value(assocName)) { + if (SUCCEEDED(hr) && + !currentUrlDefault.isEmpty() && + currentUrlDefault != _urlAssocHash.value(assocName) + ) { regCurrentUserRoot.setValue("Software/Classes" + assocName + "/shell/open/command/backup_progid", currentUrlDefault); @@ -199,9 +200,10 @@ void RegisterQAppAssociation::registerAssociation(const QString &assocName, Asso QString progId = _fileAssocHash.value(assocName); createProgId(progId); QString currentDefault = regClassesRoot.value(assocName + "/Default").toString(); - if (!currentDefault.isEmpty() - && currentDefault != progId - && regUserRoot.value(assocName + "/backup_val").toString() != progId) { + if (!currentDefault.isEmpty() && + currentDefault != progId && + regUserRoot.value(assocName + "/backup_val").toString() != progId + ) { regUserRoot.setValue(assocName + "/backup_val", currentDefault); } regUserRoot.setValue(assocName + "/.", progId); @@ -212,9 +214,10 @@ void RegisterQAppAssociation::registerAssociation(const QString &assocName, Asso createProgId(progId); QString currentDefault = regClassesRoot.value(assocName + "/shell/open/command/Default").toString(); QString command = "\"" + _appPath + "\" \"%1\""; - if (!currentDefault.isEmpty() - && currentDefault != command - && regUserRoot.value(assocName + "/shell/open/command/backup_val").toString() != command) { + if (!currentDefault.isEmpty() && + currentDefault != command && + regUserRoot.value(assocName + "/shell/open/command/backup_val").toString() != command + ) { regUserRoot.setValue(assocName + "/shell/open/command/backup_val", currentDefault); } diff --git a/src/lib/plugins/qtwebkit/spellcheck/speller.cpp b/src/lib/plugins/qtwebkit/spellcheck/speller.cpp index cb78b0c62..e3b059919 100644 --- a/src/lib/plugins/qtwebkit/spellcheck/speller.cpp +++ b/src/lib/plugins/qtwebkit/spellcheck/speller.cpp @@ -173,8 +173,10 @@ void Speller::populateContextMenu(QMenu* menu, const QWebHitTestResult &hitTest) { m_element = hitTest.element(); - if (!m_enabled || m_element.isNull() || - m_element.attribute(QLatin1String("type")) == QLatin1String("password")) { + if (!m_enabled || + m_element.isNull() || + m_element.attribute(QLatin1String("type")) == QLatin1String("password") + ) { return; } diff --git a/src/lib/popupwindow/popupwebpage.cpp b/src/lib/popupwindow/popupwebpage.cpp index 8d5deb933..81a0ccb01 100644 --- a/src/lib/popupwindow/popupwebpage.cpp +++ b/src/lib/popupwindow/popupwebpage.cpp @@ -109,8 +109,9 @@ void PopupWebPage::checkBehaviour() // If so, we should open new window. // But not when all visibilities are false, it occurs with target=_blank links - if (!m_createNewWindow && (!m_menuBarVisible || !m_statusBarVisible || !m_toolBarVisible) - && !(!m_menuBarVisible && !m_statusBarVisible && !m_toolBarVisible)) { + if (!m_createNewWindow && (!m_menuBarVisible || !m_statusBarVisible || !m_toolBarVisible) && + !(!m_menuBarVisible && !m_statusBarVisible && !m_toolBarVisible) + ) { m_createNewWindow = true; } diff --git a/src/lib/tabwidget/combotabbar.cpp b/src/lib/tabwidget/combotabbar.cpp index 5f02cdf41..8ab804c75 100644 --- a/src/lib/tabwidget/combotabbar.cpp +++ b/src/lib/tabwidget/combotabbar.cpp @@ -979,7 +979,8 @@ bool TabBarHelper::isDisplayedOnViewPort(int globalLeft, int globalRight) if (m_scrollArea) { if (globalRight < m_scrollArea->viewport()->mapToGlobal(QPoint(0, 0)).x() || - globalLeft > m_scrollArea->viewport()->mapToGlobal(m_scrollArea->viewport()->rect().topRight()).x()) { + globalLeft > m_scrollArea->viewport()->mapToGlobal(m_scrollArea->viewport()->rect().topRight()).x() + ) { isVisible = false; } } diff --git a/src/lib/tabwidget/tabstackedwidget.cpp b/src/lib/tabwidget/tabstackedwidget.cpp index 96f91b5cc..d0c03aed5 100644 --- a/src/lib/tabwidget/tabstackedwidget.cpp +++ b/src/lib/tabwidget/tabstackedwidget.cpp @@ -118,9 +118,9 @@ bool TabStackedWidget::eventFilter(QObject* obj, QEvent* event) void TabStackedWidget::keyPressEvent(QKeyEvent* event) { if (((event->key() == Qt::Key_Tab || event->key() == Qt::Key_Backtab) && - count() > 1 && event->modifiers() & Qt::ControlModifier) + count() > 1 && event->modifiers() & Qt::ControlModifier) #ifdef QT_KEYPAD_NAVIGATION - || QApplication::keypadNavigationEnabled() && (event->key() == Qt::Key_Left || event->key() == Qt::Key_Right) && count() > 1 + || QApplication::keypadNavigationEnabled() && (event->key() == Qt::Key_Left || event->key() == Qt::Key_Right) && count() > 1 #endif ) { int pageCount = count(); @@ -135,7 +135,7 @@ void TabStackedWidget::keyPressEvent(QKeyEvent* event) page += dx; if (page < 0 #ifdef QT_KEYPAD_NAVIGATION - && !event->isAutoRepeat() + && !event->isAutoRepeat() #endif ) { page = count() - 1; diff --git a/src/lib/tools/qztools.cpp b/src/lib/tools/qztools.cpp index 38a9a4d86..dab327b7d 100644 --- a/src/lib/tools/qztools.cpp +++ b/src/lib/tools/qztools.cpp @@ -470,65 +470,65 @@ bool QzTools::isUtf8(const char* string) const unsigned char* bytes = (const unsigned char*)string; while (*bytes) { if ((// ASCII - bytes[0] == 0x09 || - bytes[0] == 0x0A || - bytes[0] == 0x0D || - (0x20 <= bytes[0] && bytes[0] <= 0x7F) - ) + bytes[0] == 0x09 || + bytes[0] == 0x0A || + bytes[0] == 0x0D || + (0x20 <= bytes[0] && bytes[0] <= 0x7F) + ) ) { bytes += 1; continue; } if ((// non-overlong 2-byte - (0xC2 <= bytes[0] && bytes[0] <= 0xDF) && - (0x80 <= bytes[1] && bytes[1] <= 0xBF) - ) + (0xC2 <= bytes[0] && bytes[0] <= 0xDF) && + (0x80 <= bytes[1] && bytes[1] <= 0xBF) + ) ) { bytes += 2; continue; } if ((// excluding overlongs - bytes[0] == 0xE0 && - (0xA0 <= bytes[1] && bytes[1] <= 0xBF) && - (0x80 <= bytes[2] && bytes[2] <= 0xBF) - ) || - (// straight 3-byte - ((0xE1 <= bytes[0] && bytes[0] <= 0xEC) || - bytes[0] == 0xEE || - bytes[0] == 0xEF) && - (0x80 <= bytes[1] && bytes[1] <= 0xBF) && - (0x80 <= bytes[2] && bytes[2] <= 0xBF) - ) || - (// excluding surrogates - bytes[0] == 0xED && - (0x80 <= bytes[1] && bytes[1] <= 0x9F) && - (0x80 <= bytes[2] && bytes[2] <= 0xBF) - ) + bytes[0] == 0xE0 && + (0xA0 <= bytes[1] && bytes[1] <= 0xBF) && + (0x80 <= bytes[2] && bytes[2] <= 0xBF) + ) || + (// straight 3-byte + ((0xE1 <= bytes[0] && bytes[0] <= 0xEC) || + bytes[0] == 0xEE || + bytes[0] == 0xEF) && + (0x80 <= bytes[1] && bytes[1] <= 0xBF) && + (0x80 <= bytes[2] && bytes[2] <= 0xBF) + ) || + (// excluding surrogates + bytes[0] == 0xED && + (0x80 <= bytes[1] && bytes[1] <= 0x9F) && + (0x80 <= bytes[2] && bytes[2] <= 0xBF) + ) ) { bytes += 3; continue; } if ((// planes 1-3 - bytes[0] == 0xF0 && - (0x90 <= bytes[1] && bytes[1] <= 0xBF) && - (0x80 <= bytes[2] && bytes[2] <= 0xBF) && - (0x80 <= bytes[3] && bytes[3] <= 0xBF) - ) || - (// planes 4-15 - (0xF1 <= bytes[0] && bytes[0] <= 0xF3) && - (0x80 <= bytes[1] && bytes[1] <= 0xBF) && - (0x80 <= bytes[2] && bytes[2] <= 0xBF) && - (0x80 <= bytes[3] && bytes[3] <= 0xBF) - ) || - (// plane 16 - bytes[0] == 0xF4 && - (0x80 <= bytes[1] && bytes[1] <= 0x8F) && - (0x80 <= bytes[2] && bytes[2] <= 0xBF) && - (0x80 <= bytes[3] && bytes[3] <= 0xBF) - ) + bytes[0] == 0xF0 && + (0x90 <= bytes[1] && bytes[1] <= 0xBF) && + (0x80 <= bytes[2] && bytes[2] <= 0xBF) && + (0x80 <= bytes[3] && bytes[3] <= 0xBF) + ) || + (// planes 4-15 + (0xF1 <= bytes[0] && bytes[0] <= 0xF3) && + (0x80 <= bytes[1] && bytes[1] <= 0xBF) && + (0x80 <= bytes[2] && bytes[2] <= 0xBF) && + (0x80 <= bytes[3] && bytes[3] <= 0xBF) + ) || + (// plane 16 + bytes[0] == 0xF4 && + (0x80 <= bytes[1] && bytes[1] <= 0x8F) && + (0x80 <= bytes[2] && bytes[2] <= 0xBF) && + (0x80 <= bytes[3] && bytes[3] <= 0xBF) + ) ) { bytes += 4; continue; diff --git a/src/lib/webkit/webview.cpp b/src/lib/webkit/webview.cpp index 7648cfddd..5a7e05cfc 100644 --- a/src/lib/webkit/webview.cpp +++ b/src/lib/webkit/webview.cpp @@ -948,7 +948,8 @@ void WebView::createContextMenu(QMenu* menu, const QWebHitTestResult &hitTest, c // Hiding double Direction + Fonts menu (bug in QtWebKit 2.2) if (i <= 1 && act->menu()) { if (act->menu()->actions().contains(pageAction(QWebPage::SetTextDirectionDefault)) || - act->menu()->actions().contains(pageAction(QWebPage::ToggleBold))) { + act->menu()->actions().contains(pageAction(QWebPage::ToggleBold)) + ) { act->setVisible(false); } } @@ -1526,9 +1527,10 @@ bool WebView::eventFilter(QObject* obj, QEvent* event) } if (event->type() == QEvent::MouseButtonPress || - event->type() == QEvent::MouseButtonRelease || - event->type() == QEvent::MouseButtonDblClick || - event->type() == QEvent::MouseMove) { + event->type() == QEvent::MouseButtonRelease || + event->type() == QEvent::MouseButtonDblClick || + event->type() == QEvent::MouseMove + ) { QMouseEvent* ev = static_cast(event); diff --git a/src/plugins/AccessKeysNavigation/akn_handler.cpp b/src/plugins/AccessKeysNavigation/akn_handler.cpp index f978cb671..80305a8bd 100644 --- a/src/plugins/AccessKeysNavigation/akn_handler.cpp +++ b/src/plugins/AccessKeysNavigation/akn_handler.cpp @@ -187,9 +187,10 @@ void AKN_Handler::handleAccessKey(QKeyEvent* event) other = key.toLower(); } - if (!other.isNull() - && m_accessKeyNodes.contains(other) - && !m_accessKeyNodes.contains(key)) { + if (!other.isNull() && + m_accessKeyNodes.contains(other) && + !m_accessKeyNodes.contains(key) + ) { key = other; } @@ -253,8 +254,9 @@ void AKN_Handler::showAccessKeys() QList result = page->currentFrame()->findAllElements(elementType).toList(); foreach (const QWebElement &element, result) { const QRect geometry = element.geometry(); - if (geometry.size().isEmpty() - || !viewport.contains(geometry.topLeft())) { + if (geometry.size().isEmpty() || + !viewport.contains(geometry.topLeft()) + ) { continue; } QString accessKeyAttribute = element.attribute(QLatin1String("accesskey")).toUpper(); @@ -284,10 +286,11 @@ void AKN_Handler::showAccessKeys() QWebElementCollection result = page->currentFrame()->findAllElements(elementType); foreach (const QWebElement &element, result) { const QRect geometry = element.geometry(); - if (unusedKeys.isEmpty() - || alreadyLabeled.contains(element) - || geometry.size().isEmpty() - || !viewport.contains(geometry.topLeft())) { + if (unusedKeys.isEmpty() || + alreadyLabeled.contains(element) || + geometry.size().isEmpty() || + !viewport.contains(geometry.topLeft()) + ) { continue; } QChar accessKey; diff --git a/src/plugins/MouseGestures/mousegestures.cpp b/src/plugins/MouseGestures/mousegestures.cpp index da17288fd..a8d85b927 100644 --- a/src/plugins/MouseGestures/mousegestures.cpp +++ b/src/plugins/MouseGestures/mousegestures.cpp @@ -80,7 +80,8 @@ bool MouseGestures::mousePress(QObject* obj, QMouseEvent* event) QWebFrame* frame = m_view.data()->page()->mainFrame(); if (frame->scrollBarGeometry(Qt::Vertical).contains(event->pos()) || - frame->scrollBarGeometry(Qt::Horizontal).contains(event->pos())) { + frame->scrollBarGeometry(Qt::Horizontal).contains(event->pos()) + ) { return false; }