diff options
Diffstat (limited to 'src')
72 files changed, 1292 insertions, 1295 deletions
diff --git a/src/adblock/adblockhostmatcher.cpp b/src/adblock/adblockhostmatcher.cpp index 4a29fb9e..021fe12d 100644 --- a/src/adblock/adblockhostmatcher.cpp +++ b/src/adblock/adblockhostmatcher.cpp @@ -31,20 +31,20 @@ bool AdBlockHostMatcher::tryAddFilter(const QString &filter) { - if(filter.startsWith(QL1S("||"))) + if (filter.startsWith(QL1S("||"))) { QString domain = filter.mid(2); - if(!domain.endsWith(QL1C('^'))) + if (!domain.endsWith(QL1C('^'))) return false; - if(domain.contains(QL1C('$'))) + if (domain.contains(QL1C('$'))) return false; domain = domain.left(domain.size() - 1); - if(domain.contains(QL1C('/')) || domain.contains(QL1C('*')) || domain.contains(QL1C('^'))) + if (domain.contains(QL1C('/')) || domain.contains(QL1C('*')) || domain.contains(QL1C('^'))) return false; domain = domain.toLower(); diff --git a/src/adblock/adblockmanager.cpp b/src/adblock/adblockmanager.cpp index c41ff2eb..6a4a3827 100644 --- a/src/adblock/adblockmanager.cpp +++ b/src/adblock/adblockmanager.cpp @@ -77,7 +77,7 @@ void AdBlockManager::loadSettings(bool checkUpdateDate) kDebug() << "ADBLOCK ENABLED = " << _isAdblockEnabled; // no need to load filters if adblock is not enabled :) - if(!_isAdblockEnabled) + if (!_isAdblockEnabled) return; // just to be sure.. @@ -96,7 +96,7 @@ void AdBlockManager::loadSettings(bool checkUpdateDate) QDateTime lastUpdate = ReKonfig::lastUpdate(); // the day of the implementation.. :) int days = ReKonfig::updateInterval(); - if(!checkUpdateDate || today > lastUpdate.addDays(days)) + if (!checkUpdateDate || today > lastUpdate.addDays(days)) { ReKonfig::setLastUpdate(today); @@ -119,23 +119,23 @@ void AdBlockManager::loadRules(const QStringList &rules) foreach(const QString & stringRule, rules) { // ! rules are comments - if(stringRule.startsWith('!')) + if (stringRule.startsWith('!')) continue; // [ rules are ABP info - if(stringRule.startsWith('[')) + if (stringRule.startsWith('[')) continue; // empty rules are just dangerous.. // (an empty rule in whitelist allows all, in blacklist blocks all..) - if(stringRule.isEmpty()) + if (stringRule.isEmpty()) continue; // white rules - if(stringRule.startsWith(QL1S("@@"))) + if (stringRule.startsWith(QL1S("@@"))) { const QString filter = stringRule.mid(2); - if(_hostWhiteList.tryAddFilter(filter)) + if (_hostWhiteList.tryAddFilter(filter)) continue; AdBlockRule rule(filter); @@ -144,17 +144,17 @@ void AdBlockManager::loadRules(const QStringList &rules) } // hide (CSS) rules - if(stringRule.startsWith(QL1S("##"))) + if (stringRule.startsWith(QL1S("##"))) { _hideList << stringRule.mid(2); continue; } // TODO implement domain-specific hiding - if(stringRule.contains(QL1S("##"))) + if (stringRule.contains(QL1S("##"))) continue; - if(_hostBlackList.tryAddFilter(stringRule)) + if (_hostBlackList.tryAddFilter(stringRule)) continue; AdBlockRule rule(stringRule); @@ -165,11 +165,11 @@ void AdBlockManager::loadRules(const QStringList &rules) QNetworkReply *AdBlockManager::block(const QNetworkRequest &request, WebPage *page) { - if(!_isAdblockEnabled) + if (!_isAdblockEnabled) return 0; // we (ad)block just http traffic - if(request.url().scheme() != QL1S("http")) + if (request.url().scheme() != QL1S("http")) return 0; QString urlString = request.url().toString(); @@ -180,7 +180,7 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request, WebPage *pa // check white rules before :) - if(_hostWhiteList.match(host)) + if (_hostWhiteList.match(host)) { kDebug() << "****ADBLOCK: WHITE RULE (@@) Matched by host matcher: ***********"; kDebug() << "UrlString: " << urlString; @@ -189,7 +189,7 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request, WebPage *pa foreach(const AdBlockRule & filter, _whiteList) { - if(filter.match(request, urlString, urlStringLowerCase)) + if (filter.match(request, urlString, urlStringLowerCase)) { kDebug() << "****ADBLOCK: WHITE RULE (@@) Matched: ***********"; kDebug() << "UrlString: " << urlString; @@ -198,7 +198,7 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request, WebPage *pa } // then check the black ones :( - if(_hostBlackList.match(host)) + if (_hostBlackList.match(host)) { kDebug() << "****ADBLOCK: BLACK RULE Matched by host matcher: ***********"; kDebug() << "UrlString: " << urlString; @@ -208,7 +208,7 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request, WebPage *pa foreach(const AdBlockRule & filter, _blackList) { - if(filter.match(request, urlString, urlStringLowerCase)) + if (filter.match(request, urlString, urlStringLowerCase)) { kDebug() << "****ADBLOCK: BLACK RULE Matched: ***********"; kDebug() << "UrlString: " << urlString; @@ -218,7 +218,7 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request, WebPage *pa foreach(QWebElement el, elements) { const QString srcAttribute = el.attribute("src"); - if(filter.match(request, srcAttribute, srcAttribute.toLower())) + if (filter.match(request, srcAttribute, srcAttribute.toLower())) { kDebug() << "MATCHES ATTRIBUTE!!!!!"; el.setStyleProperty(QL1S("visibility"), QL1S("hidden")); @@ -239,13 +239,13 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request, WebPage *pa void AdBlockManager::applyHidingRules(WebPage *page) { - if(!page) + if (!page) return; - if(!_isAdblockEnabled) + if (!_isAdblockEnabled) return; - if(!_isHideAdsEnabled) + if (!_isHideAdsEnabled) return; QWebElement document = page->mainFrame()->documentElement(); @@ -257,7 +257,7 @@ void AdBlockManager::applyHidingRules(WebPage *page) foreach(QWebElement el, elements) { - if(el.isNull()) + if (el.isNull()) continue; kDebug() << "Hide element: " << el.localName(); el.setStyleProperty(QL1S("visibility"), QL1S("hidden")); @@ -271,7 +271,7 @@ void AdBlockManager::updateNextSubscription() { QStringList locations = ReKonfig::subscriptionLocations(); - if(_index < locations.size()) + if (_index < locations.size()) { QString urlString = locations.at(_index); KUrl subUrl = KUrl(urlString); @@ -296,7 +296,7 @@ void AdBlockManager::updateNextSubscription() void AdBlockManager::slotResult(KJob *job) { - if(job->error()) + if (job->error()) return; QList<QByteArray> list = _buffer.split('\n'); @@ -319,7 +319,7 @@ void AdBlockManager::subscriptionData(KIO::Job* job, const QByteArray& data) { Q_UNUSED(job) - if(data.isEmpty()) + if (data.isEmpty()) return; int oldSize = _buffer.size(); @@ -333,7 +333,7 @@ void AdBlockManager::saveRules(const QStringList &rules) QStringList cleanedRules; foreach(const QString & r, rules) { - if(!r.startsWith('!') && !r.startsWith('[') && !r.isEmpty()) + if (!r.startsWith('!') && !r.startsWith('[') && !r.isEmpty()) cleanedRules << r; } @@ -349,11 +349,11 @@ void AdBlockManager::saveRules(const QStringList &rules) void AdBlockManager::addSubscription(const QString &title, const QString &location) { QStringList titles = ReKonfig::subscriptionTitles(); - if(titles.contains(title)) + if (titles.contains(title)) return; QStringList locations = ReKonfig::subscriptionLocations(); - if(locations.contains(location)) + if (locations.contains(location)) return; titles << title; diff --git a/src/adblock/adblockrule.cpp b/src/adblock/adblockrule.cpp index fcc5fd8c..87fcb680 100644 --- a/src/adblock/adblockrule.cpp +++ b/src/adblock/adblockrule.cpp @@ -37,7 +37,7 @@ AdBlockRule::AdBlockRule(const QString &filter) { - switch(AdBlockRule::ruleType(filter)) + switch (AdBlockRule::ruleType(filter)) { case TextRule: m_implementation = QSharedPointer<AdBlockRuleImpl>(new AdBlockRuleTextMatchImpl(filter)); @@ -57,10 +57,10 @@ AdBlockRule::AdBlockRule(const QString &filter) RuleTypes AdBlockRule::ruleType(const QString &filter) { - if(AdBlockRuleTextMatchImpl::isTextMatchFilter(filter)) + if (AdBlockRuleTextMatchImpl::isTextMatchFilter(filter)) return TextRule; - if(AdBlockRuleNullImpl::isNullFilter(filter)) + if (AdBlockRuleNullImpl::isNullFilter(filter)) return NullRule; return FallbackRule; diff --git a/src/adblock/adblockrule.h b/src/adblock/adblockrule.h index 336987b0..f5f913dc 100644 --- a/src/adblock/adblockrule.h +++ b/src/adblock/adblockrule.h @@ -57,7 +57,7 @@ public: { Q_ASSERT(encodedUrl.toLower() == encodedUrlLowerCase); bool b = m_implementation->match(request, encodedUrl, encodedUrlLowerCase); - if(b) + if (b) { kDebug() << m_implementation->ruleType() << ": rule string = " << m_implementation->ruleString(); } diff --git a/src/adblock/adblockrulefallbackimpl.cpp b/src/adblock/adblockrulefallbackimpl.cpp index 7977849b..7b18feec 100644 --- a/src/adblock/adblockrulefallbackimpl.cpp +++ b/src/adblock/adblockrulefallbackimpl.cpp @@ -52,27 +52,27 @@ AdBlockRuleFallbackImpl::AdBlockRuleFallbackImpl(const QString &filter) QString parsedLine = filter; const int optionsNumber = parsedLine.lastIndexOf(QL1C('$')); - if(optionsNumber >= 0 && !isRegExpFilter(parsedLine)) + if (optionsNumber >= 0 && !isRegExpFilter(parsedLine)) { const QStringList options(parsedLine.mid(optionsNumber + 1).split(QL1C(','))); parsedLine = parsedLine.left(optionsNumber); - if(options.contains(QL1S("match-case"))) + if (options.contains(QL1S("match-case"))) m_regExp.setCaseSensitivity(Qt::CaseSensitive); - if(options.contains(QL1S("third-party"))) + if (options.contains(QL1S("third-party"))) m_thirdPartyOption = true; foreach(const QString & option, options) { // Domain restricted filter const QString domainKeyword(QL1S("domain=")); - if(option.startsWith(domainKeyword)) + if (option.startsWith(domainKeyword)) { QStringList domainList = option.mid(domainKeyword.length()).split(QL1C('|')); foreach(const QString & domain, domainList) { - if(domain.startsWith(QL1C('~'))) + if (domain.startsWith(QL1C('~'))) m_whiteDomains.insert(domain.toLower()); else m_blackDomains.insert(domain.toLower()); @@ -81,7 +81,7 @@ AdBlockRuleFallbackImpl::AdBlockRuleFallbackImpl(const QString &filter) } } - if(isRegExpFilter(parsedLine)) + if (isRegExpFilter(parsedLine)) parsedLine = parsedLine.mid(1, parsedLine.length() - 2); else parsedLine = convertPatternToRegExp(parsedLine); @@ -92,36 +92,36 @@ AdBlockRuleFallbackImpl::AdBlockRuleFallbackImpl(const QString &filter) bool AdBlockRuleFallbackImpl::match(const QNetworkRequest &request, const QString &encodedUrl, const QString &) const { - if(!request.hasRawHeader("referer")) + if (!request.hasRawHeader("referer")) return false; - if(m_thirdPartyOption) + if (m_thirdPartyOption) { const QString referer = request.rawHeader("referer"); const QString host = request.url().host(); bool isThirdParty = !referer.contains(host); - if(!isThirdParty) + if (!isThirdParty) return false; } const bool regexpMatch = m_regExp.indexIn(encodedUrl) != -1; - if(regexpMatch && (!m_whiteDomains.isEmpty() || !m_blackDomains.isEmpty())) + if (regexpMatch && (!m_whiteDomains.isEmpty() || !m_blackDomains.isEmpty())) { Q_ASSERT(qobject_cast<QWebFrame*>(request.originatingObject())); const QWebFrame *const origin = static_cast<QWebFrame * const>(request.originatingObject()); const QString originDomain = origin->url().host(); - if(!m_whiteDomains.isEmpty()) + if (!m_whiteDomains.isEmpty()) { // In this context, white domains means we block anything but what is in the list. - if(m_whiteDomains.contains(originDomain)) + if (m_whiteDomains.contains(originDomain)) return false; return true; } - else if(m_blackDomains.contains(originDomain)) + else if (m_blackDomains.contains(originDomain)) { return true; } diff --git a/src/adblock/adblockrulenullimpl.cpp b/src/adblock/adblockrulenullimpl.cpp index ecd46b1b..807efc64 100644 --- a/src/adblock/adblockrulenullimpl.cpp +++ b/src/adblock/adblockrulenullimpl.cpp @@ -51,7 +51,7 @@ bool AdBlockRuleNullImpl::isNullFilter(const QString &filter) QString parsedLine = filter; const int optionsNumber = parsedLine.lastIndexOf(QL1C('$')); - if(optionsNumber == 0) + if (optionsNumber == 0) return false; const QStringList options(parsedLine.mid(optionsNumber + 1).split(QL1C(','))); @@ -59,63 +59,63 @@ bool AdBlockRuleNullImpl::isNullFilter(const QString &filter) Q_FOREACH(const QString & option, options) { // script - if(option == QL1S("script")) + if (option == QL1S("script")) return true; // image - if(option == QL1S("image")) + if (option == QL1S("image")) return true; // background - if(option == QL1S("background")) + if (option == QL1S("background")) return true; // stylesheet - if(option == QL1S("stylesheet")) + if (option == QL1S("stylesheet")) return true; // object - if(option == QL1S("object")) + if (option == QL1S("object")) return true; // xbl - if(option == QL1S("xbl")) + if (option == QL1S("xbl")) return true; // ping - if(option == QL1S("ping")) + if (option == QL1S("ping")) return true; // xmlhttprequest - if(option == QL1S("xmlhttprequest")) + if (option == QL1S("xmlhttprequest")) return true; // object_subrequest - if(option == QL1S("object-subrequest")) + if (option == QL1S("object-subrequest")) return true; // dtd - if(option == QL1S("dtd")) + if (option == QL1S("dtd")) return true; // subdocument - if(option == QL1S("subdocument")) + if (option == QL1S("subdocument")) return true; // document - if(option == QL1S("document")) + if (option == QL1S("document")) return true; // other - if(option == QL1S("other")) + if (option == QL1S("other")) return true; // third_party: managed inside adblockrulefallbackimpl - if(option == QL1S("third-party")) + if (option == QL1S("third-party")) return false; // collapse - if(option == QL1S("collapse")) + if (option == QL1S("collapse")) return true; } diff --git a/src/adblock/adblockruletextmatchimpl.cpp b/src/adblock/adblockruletextmatchimpl.cpp index 70b5d03d..7b55bf27 100644 --- a/src/adblock/adblockruletextmatchimpl.cpp +++ b/src/adblock/adblockruletextmatchimpl.cpp @@ -47,7 +47,7 @@ AdBlockRuleTextMatchImpl::AdBlockRuleTextMatchImpl(const QString &filter) bool AdBlockRuleTextMatchImpl::match(const QNetworkRequest &request, const QString &encodedUrl, const QString &encodedUrlLowerCase) const { // this basically lets the "first request" to pass... - if(!request.hasRawHeader("referer")) + if (!request.hasRawHeader("referer")) return false; Q_UNUSED(encodedUrl); @@ -62,22 +62,22 @@ bool AdBlockRuleTextMatchImpl::match(const QNetworkRequest &request, const QStri bool AdBlockRuleTextMatchImpl::isTextMatchFilter(const QString &filter) { // We don't deal with options just yet - if(filter.contains(QL1C('$'))) + if (filter.contains(QL1C('$'))) return false; // We don't deal with element matching - if(filter.contains(QL1S("##"))) + if (filter.contains(QL1S("##"))) return false; // We don't deal with the begin-end matching - if(filter.startsWith(QL1C('|')) || filter.endsWith(QL1C('|'))) + if (filter.startsWith(QL1C('|')) || filter.endsWith(QL1C('|'))) return false; // We only handle * at the beginning or the end int starPosition = filter.indexOf(QL1C('*')); - while(starPosition >= 0) + while (starPosition >= 0) { - if(starPosition != 0 && starPosition != (filter.length() - 1)) + if (starPosition != 0 && starPosition != (filter.length() - 1)) return false; starPosition = filter.indexOf(QL1C('*'), starPosition + 1); } diff --git a/src/analyzer/analyzerpanel.cpp b/src/analyzer/analyzerpanel.cpp index 566fea15..60f2c612 100644 --- a/src/analyzer/analyzerpanel.cpp +++ b/src/analyzer/analyzerpanel.cpp @@ -69,7 +69,7 @@ void NetworkAnalyzerPanel::toggle(bool enable) page->enableNetworkAnalyzer(enable); - if(enable) + if (enable) { connect(page, SIGNAL(loadStarted()), _viewer, SLOT(clear())); connect(manager, SIGNAL(networkData(QNetworkAccessManager::Operation, const QNetworkRequest &, QNetworkReply *)), diff --git a/src/analyzer/networkanalyzer.cpp b/src/analyzer/networkanalyzer.cpp index 7decd566..12c048ae 100644 --- a/src/analyzer/networkanalyzer.cpp +++ b/src/analyzer/networkanalyzer.cpp @@ -75,7 +75,7 @@ NetworkAnalyzer::NetworkAnalyzer(QWidget *parent) void NetworkAnalyzer::popupContextMenu(const QPoint& pos) { - if(_requestList->topLevelItemCount() >= 1) + if (_requestList->topLevelItemCount() >= 1) { KMenu menu(_requestList); KAction *copy; @@ -96,7 +96,7 @@ void NetworkAnalyzer::addRequest(QNetworkAccessManager::Operation op, const QNet { // Add to list of requests QStringList cols; - switch(op) + switch (op) { case QNetworkAccessManager::HeadOperation: cols << QL1S("HEAD"); @@ -151,14 +151,14 @@ void NetworkAnalyzer::clear() void NetworkAnalyzer::requestFinished(QObject *replyObject) { QNetworkReply *reply = qobject_cast<QNetworkReply *>(replyObject); - if(!reply) + if (!reply) { kDebug() << "Failed to downcast reply"; return; } QTreeWidgetItem *item = _itemMap[reply]; - if(!item) + if (!item) { kDebug() << "No Item mapped. Returning..."; return; @@ -187,7 +187,7 @@ void NetworkAnalyzer::requestFinished(QObject *replyObject) QString contentType = reply->header(QNetworkRequest::ContentTypeHeader).toString(); item->setText(4, contentType); - if(status == 302) + if (status == 302) { QUrl target = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl(); item->setText(5, i18n("Redirect: %1", target.toString())); @@ -216,7 +216,7 @@ void NetworkAnalyzer::showItemDetails(QTreeWidgetItem *item) QPair< QList<QByteArray>, QList<QByteArray> > replyHeaders = _itemReplyMap[item]; details += i18n("<h3>Response Details</h3>"); details += QL1S("<ul>"); - for(int i = 0; i < replyHeaders.first.count(); i++) + for (int i = 0; i < replyHeaders.first.count(); i++) { details += QL1S("<li>"); details += QL1S(replyHeaders.first[i]); diff --git a/src/application.cpp b/src/application.cpp index bd775050..fc4e81fc 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -95,37 +95,37 @@ Application::~Application() window.clear(); } - if(!m_historyManager.isNull()) + if (!m_historyManager.isNull()) { delete m_historyManager.data(); m_historyManager.clear(); } - if(!m_bookmarkProvider.isNull()) + if (!m_bookmarkProvider.isNull()) { delete m_bookmarkProvider.data(); m_bookmarkProvider.clear(); } - if(!m_sessionManager.isNull()) + if (!m_sessionManager.isNull()) { delete m_sessionManager.data(); m_sessionManager.clear(); } - if(!m_opensearchManager.isNull()) + if (!m_opensearchManager.isNull()) { delete m_opensearchManager.data(); m_opensearchManager.clear(); } - if(!m_iconManager.isNull()) + if (!m_iconManager.isNull()) { delete m_iconManager.data(); m_iconManager.clear(); } - if(!m_adblockManager.isNull()) + if (!m_adblockManager.isNull()) { delete m_adblockManager.data(); m_adblockManager.clear(); @@ -135,7 +135,7 @@ Application::~Application() // add a check to NOT close rekonq // until last download is finished - if(!m_downloadManager.isNull()) + if (!m_downloadManager.isNull()) { delete m_adblockManager.data(); m_adblockManager.clear(); @@ -166,25 +166,25 @@ int Application::newInstance() int exitValue = 1 * isFirstLoad + 2 * areThereArguments + 4 * isRekonqCrashed; - if(isRekonqCrashed && isFirstLoad) + if (isRekonqCrashed && isFirstLoad) { loadUrl(KUrl("about:closedTabs"), Rekonq::NewWindow); mainWindow()->currentTab()->showMessageBar(); } - if(areThereArguments) + if (areThereArguments) { KUrl::List urlList; - for(int i = 0; i < args->count(); ++i) + for (int i = 0; i < args->count(); ++i) { const KUrl u = args->url(i); - if(u.isLocalFile() && QFile::exists(u.toLocalFile())) // "rekonq somefile.html" case + if (u.isLocalFile() && QFile::exists(u.toLocalFile())) // "rekonq somefile.html" case urlList += u; else urlList += KUrl(args->arg(i)); // "rekonq kde.org" || "rekonq kde:kdialog" case } - if(isFirstLoad && !isRekonqCrashed) + if (isFirstLoad && !isRekonqCrashed) { // No windows in the current desktop? No windows at all? // Create a new one and load there sites... @@ -192,17 +192,17 @@ int Application::newInstance() } else { - if(ReKonfig::openTabNoWindow()) + if (ReKonfig::openTabNoWindow()) { loadUrl(urlList.at(0), Rekonq::NewTab); - if(!mainWindow()->isActiveWindow()) + if (!mainWindow()->isActiveWindow()) KWindowSystem::demandAttention(mainWindow()->winId(), true); } else loadUrl(urlList.at(0), Rekonq::NewWindow); } - for(int i = 1; i < urlList.count(); ++i) + for (int i = 1; i < urlList.count(); ++i) loadUrl(urlList.at(i), Rekonq::NewTab); KStartupInfo::appStarted(); @@ -211,9 +211,9 @@ int Application::newInstance() else { - if(isFirstLoad && !isRekonqCrashed) // we are starting rekonq, for the first time with no args: use startup behaviour + if (isFirstLoad && !isRekonqCrashed) // we are starting rekonq, for the first time with no args: use startup behaviour { - switch(ReKonfig::startupBehaviour()) + switch (ReKonfig::startupBehaviour()) { case 0: // open home page newMainWindow()->homePage(); @@ -231,9 +231,9 @@ int Application::newInstance() break; } } - else if(!isFirstLoad) // rekonq has just been started. Just open a new window + else if (!isFirstLoad) // rekonq has just been started. Just open a new window { - switch(ReKonfig::newTabsBehaviour()) + switch (ReKonfig::newTabsBehaviour()) { case 0: // new tab page loadUrl(KUrl("about:home") , Rekonq::NewWindow); @@ -252,7 +252,7 @@ int Application::newInstance() } } - if(isFirstLoad) + if (isFirstLoad) { // give me some time to do the other things.. QTimer::singleShot(100, this, SLOT(postLaunch())); @@ -298,14 +298,14 @@ MainWindow *Application::mainWindow() { MainWindow *active = qobject_cast<MainWindow*>(QApplication::activeWindow()); - if(!active) + if (!active) { - if(m_mainWindows.isEmpty()) + if (m_mainWindows.isEmpty()) return 0; Q_FOREACH(const QWeakPointer<MainWindow> &pointer, m_mainWindows) { - if(KWindowInfo(pointer.data()->effectiveWinId(), NET::WMDesktop, 0).isOnCurrentDesktop()) + if (KWindowInfo(pointer.data()->effectiveWinId(), NET::WMDesktop, 0).isOnCurrentDesktop()) return pointer.data(); } return m_mainWindows.at(0).data(); @@ -316,7 +316,7 @@ MainWindow *Application::mainWindow() HistoryManager *Application::historyManager() { - if(m_historyManager.isNull()) + if (m_historyManager.isNull()) { m_historyManager = new HistoryManager; } @@ -326,7 +326,7 @@ HistoryManager *Application::historyManager() BookmarkProvider *Application::bookmarkProvider() { - if(m_bookmarkProvider.isNull()) + if (m_bookmarkProvider.isNull()) { m_bookmarkProvider = new BookmarkProvider; } @@ -336,7 +336,7 @@ BookmarkProvider *Application::bookmarkProvider() SessionManager *Application::sessionManager() { - if(m_sessionManager.isNull()) + if (m_sessionManager.isNull()) { m_sessionManager = new SessionManager; } @@ -346,7 +346,7 @@ SessionManager *Application::sessionManager() OpenSearchManager *Application::opensearchManager() { - if(m_opensearchManager.isNull()) + if (m_opensearchManager.isNull()) { m_opensearchManager = new OpenSearchManager; } @@ -356,7 +356,7 @@ OpenSearchManager *Application::opensearchManager() IconManager *Application::iconManager() { - if(m_iconManager.isNull()) + if (m_iconManager.isNull()) { m_iconManager = new IconManager; } @@ -366,7 +366,7 @@ IconManager *Application::iconManager() DownloadManager *Application::downloadManager() { - if(m_downloadManager.isNull()) + if (m_downloadManager.isNull()) { m_downloadManager = new DownloadManager(instance()); } @@ -376,10 +376,10 @@ DownloadManager *Application::downloadManager() void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) { - if(url.isEmpty()) + if (url.isEmpty()) return; - if(!url.isValid()) + if (!url.isValid()) { KMessageBox::error(0, i18n("Malformed URL:\n%1", url.url(KUrl::RemoveTrailingSlash))); return; @@ -392,10 +392,10 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) ? newMainWindow() : mainWindow(); - switch(type) + switch (type) { case Rekonq::NewTab: - if(ReKonfig::openTabNoWindow()) + if (ReKonfig::openTabNoWindow()) tab = w->mainView()->newWebTab(!ReKonfig::openTabsBack()); else { @@ -425,7 +425,7 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) WebView *view = tab->view(); - if(view) + if (view) { FilterUrlJob *job = new FilterUrlJob(view, url.pathOrUrl(), this); Weaver::instance()->enqueue(job); @@ -439,7 +439,7 @@ MainWindow *Application::newMainWindow(bool withTab) // This is used to track which window was activated most recently w->installEventFilter(this); - if(withTab) + if (withTab) w->mainView()->newWebTab(); // remember using newWebTab and NOT newTab here!! m_mainWindows.prepend(w); @@ -463,7 +463,7 @@ MainWindowList Application::mainWindowList() AdBlockManager *Application::adblockManager() { - if(m_adblockManager.isNull()) + if (m_adblockManager.isNull()) { m_adblockManager = new AdBlockManager; } @@ -477,7 +477,7 @@ void Application::loadResolvedUrl(ThreadWeaver::Job *job) KUrl url = threadedJob->url(); WebView *view = threadedJob->view(); - if(view) + if (view) { view->load(url); } @@ -498,12 +498,12 @@ bool Application::eventFilter(QObject* watched, QEvent* event) { // Track which window was activated most recently to prefer it on window choosing // (e.g. when another application opens a link) - if(event->type() == QEvent::WindowActivate) + if (event->type() == QEvent::WindowActivate) { MainWindow *window = qobject_cast<MainWindow*>(watched); - if(window) + if (window) { - if(m_mainWindows.at(0).data() != window) + if (m_mainWindows.at(0).data() != window) { int index = m_mainWindows.indexOf(QWeakPointer<MainWindow>(window)); Q_ASSERT(index != -1); @@ -527,7 +527,7 @@ void Application::updateConfiguration() mv->tabBar()->setAnimatedTabHighlighting(ReKonfig::animatedTabHighlighting()); - if(b) + if (b) mv->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab); else mv->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectRightTab); @@ -572,7 +572,7 @@ void Application::updateConfiguration() defaultSettings->setAttribute(QWebSettings::ZoomTextOnly, ReKonfig::zoomTextOnly()); defaultSettings->setAttribute(QWebSettings::PrintElementBackgrounds, ReKonfig::printElementBackgrounds()); - if(ReKonfig::pluginsEnabled() == 2) + if (ReKonfig::pluginsEnabled() == 2) defaultSettings->setAttribute(QWebSettings::PluginsEnabled, false); else defaultSettings->setAttribute(QWebSettings::PluginsEnabled, true); @@ -584,7 +584,7 @@ void Application::updateConfiguration() defaultSettings->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, ReKonfig::offlineStorageDatabaseEnabled()); defaultSettings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, ReKonfig::offlineWebApplicationCacheEnabled()); defaultSettings->setAttribute(QWebSettings::LocalStorageEnabled, ReKonfig::localStorageEnabled()); - if(ReKonfig::localStorageEnabled()) + if (ReKonfig::localStorageEnabled()) { QString path = KStandardDirs::locateLocal("cache", QString("WebkitLocalStorage/rekonq"), true); path.remove("rekonq"); @@ -601,31 +601,31 @@ void Application::updateConfiguration() // ====== load Settings on main classes historyManager()->loadSettings(); adblockManager()->loadSettings(); - if(!ReKonfig::useFavicon()) + if (!ReKonfig::useFavicon()) mainWindow()->setWindowIcon(KIcon("rekonq")); else mainWindow()->changeWindowIcon(mainWindow()->mainView()->currentIndex()); // hovering unfocused tabs options - switch(ReKonfig::hoveringTabOption()) + switch (ReKonfig::hoveringTabOption()) { case 0: // tab previews case 3: // nothing - for(int i = 0; i < mainWindow()->mainView()->tabBar()->count(); i++) + for (int i = 0; i < mainWindow()->mainView()->tabBar()->count(); i++) { mainWindow()->mainView()->tabBar()->setTabToolTip(i, ""); } break; case 1: // title previews - for(int i = 0; i < mainWindow()->mainView()->tabBar()->count(); i++) + for (int i = 0; i < mainWindow()->mainView()->tabBar()->count(); i++) { mainWindow()->mainView()->tabBar()->setTabToolTip(i, mainWindow()->mainView()->tabText(i).remove('&')); } break; case 2: // url previews - for(int i = 0; i < mainWindow()->mainView()->tabBar()->count(); i++) + for (int i = 0; i < mainWindow()->mainView()->tabBar()->count(); i++) { mainWindow()->mainView()->tabBar()->setTabToolTip(i, mainWindow()->mainView()->webTab(i)->url().toMimeDataString()); } @@ -652,17 +652,17 @@ void Application::setPrivateBrowsingMode(bool b) QWebSettings *settings = QWebSettings::globalSettings(); bool isJustEnabled = settings->testAttribute(QWebSettings::PrivateBrowsingEnabled); - if(isJustEnabled == b) + if (isJustEnabled == b) return; // uhm... something goes wrong... - if(b) + if (b) { QString caption = i18n("Are you sure you want to turn on private browsing?"); QString text = i18n("<b>%1</b>" "<p>rekonq will save your current tabs for when you'll stop private browsing the net.</p>", caption); int button = KMessageBox::warningContinueCancel(mainWindow(), text, caption, KStandardGuiItem::cont(), KStandardGuiItem::cancel(), i18n("don't ask again")); - if(button != KMessageBox::Continue) + if (button != KMessageBox::Continue) return; settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true); @@ -685,7 +685,7 @@ void Application::setPrivateBrowsingMode(bool b) _privateBrowsingAction->setChecked(false); loadUrl(KUrl("about:blank"), Rekonq::NewWindow); - if(!sessionManager()->restoreSession()) + if (!sessionManager()->restoreSession()) loadUrl(KUrl("about:home"), Rekonq::NewWindow); } } diff --git a/src/bookmarks/bookmarkowner.cpp b/src/bookmarks/bookmarkowner.cpp index 75b5f12d..b15bf28b 100644 --- a/src/bookmarks/bookmarkowner.cpp +++ b/src/bookmarks/bookmarkowner.cpp @@ -57,7 +57,7 @@ BookmarkOwner::BookmarkOwner(KBookmarkManager *manager, QObject *parent) KAction* BookmarkOwner::createAction(const KBookmark &bookmark, const BookmarkAction &bmAction) { - switch(bmAction) + switch (bmAction) { case OPEN: return createAction(i18n("Open"), "tab-new", @@ -119,7 +119,7 @@ QList< QPair<QString, QString> > BookmarkOwner::currentBookmarkList() const MainView *view = rApp->mainWindow()->mainView(); int tabNumber = view->count(); - for(int i = 0; i < tabNumber; ++i) + for (int i = 0; i < tabNumber; ++i) { QPair<QString, QString> item; item.first = view->webTab(i)->view()->title(); @@ -135,7 +135,7 @@ void BookmarkOwner::openBookmark(const KBookmark &bookmark, Qt::MouseButtons mouseButtons, Qt::KeyboardModifiers keyboardModifiers) { - if(keyboardModifiers & Qt::ControlModifier || mouseButtons & Qt::MidButton) + if (keyboardModifiers & Qt::ControlModifier || mouseButtons & Qt::MidButton) openBookmarkInNewTab(bookmark); else openBookmark(bookmark); @@ -146,15 +146,15 @@ void BookmarkOwner::openFolderinTabs(const KBookmarkGroup &bkGoup) { QList<KUrl> urlList = bkGoup.groupUrlList(); - if(urlList.length() > 8) + if (urlList.length() > 8) { - if(KMessageBox::warningContinueCancel( + if (KMessageBox::warningContinueCancel( rApp->mainWindow(), i18ncp("%1=Number of tabs. Value is always >=8", "You are about to open %1 tabs.\nAre you sure?", "You are about to open %1 tabs.\nAre you sure?", urlList.length())) != KMessageBox::Continue - ) + ) return; } @@ -194,9 +194,9 @@ KBookmark BookmarkOwner::bookmarkCurrentPage(const KBookmark &bookmark) { KBookmarkGroup parent; - if(!bookmark.isNull()) + if (!bookmark.isNull()) { - if(bookmark.isGroup()) + if (bookmark.isGroup()) parent = bookmark.toGroup(); else parent = bookmark.parentGroup(); @@ -207,7 +207,7 @@ KBookmark BookmarkOwner::bookmarkCurrentPage(const KBookmark &bookmark) } KBookmark newBk = parent.addBookmark(currentTitle(), KUrl(currentUrl())); - if(!bookmark.isNull()) + if (!bookmark.isNull()) parent.moveBookmark(newBk, bookmark); m_manager->emitChanged(parent); @@ -221,16 +221,16 @@ KBookmarkGroup BookmarkOwner::newBookmarkFolder(const KBookmark &bookmark) KBookmarkDialog *dialog = bookmarkDialog(m_manager, 0); QString folderName = i18n("New folder"); - if(!bookmark.isNull()) + if (!bookmark.isNull()) { - if(bookmark.isGroup()) + if (bookmark.isGroup()) { newBk = dialog->createNewFolder(folderName, bookmark); } else { newBk = dialog->createNewFolder(folderName, bookmark.parentGroup()); - if(!newBk.isNull()) + if (!newBk.isNull()) { KBookmarkGroup parent = newBk.parentGroup(); parent.moveBookmark(newBk, bookmark); @@ -252,9 +252,9 @@ KBookmark BookmarkOwner::newSeparator(const KBookmark &bookmark) { KBookmark newBk; - if(!bookmark.isNull()) + if (!bookmark.isNull()) { - if(bookmark.isGroup()) + if (bookmark.isGroup()) { newBk = bookmark.toGroup().createNewSeparator(); } @@ -278,7 +278,7 @@ KBookmark BookmarkOwner::newSeparator(const KBookmark &bookmark) void BookmarkOwner::copyLink(const KBookmark &bookmark) { - if(bookmark.isNull()) + if (bookmark.isNull()) return; QApplication::clipboard()->setText(bookmark.url().url()); @@ -287,7 +287,7 @@ void BookmarkOwner::copyLink(const KBookmark &bookmark) void BookmarkOwner::editBookmark(KBookmark bookmark) { - if(bookmark.isNull()) + if (bookmark.isNull()) return; KBookmarkDialog *dialog = bookmarkDialog(m_manager, 0); @@ -299,18 +299,18 @@ void BookmarkOwner::editBookmark(KBookmark bookmark) bool BookmarkOwner::deleteBookmark(const KBookmark &bookmark) { - if(bookmark.isNull()) + if (bookmark.isNull()) return false; KBookmarkGroup bmg = bookmark.parentGroup(); QString dialogCaption, dialogText; - if(bookmark.isGroup()) + if (bookmark.isGroup()) { dialogCaption = i18n("Bookmark Folder Deletion"); dialogText = i18n("Are you sure you wish to remove the bookmark folder\n\"%1\"?", bookmark.fullText()); } - else if(bookmark.isSeparator()) + else if (bookmark.isSeparator()) { dialogCaption = i18n("Separator Deletion"); dialogText = i18n("Are you sure you wish to remove this separator?"); @@ -321,7 +321,7 @@ bool BookmarkOwner::deleteBookmark(const KBookmark &bookmark) dialogText = i18n("Are you sure you wish to remove the bookmark\n\"%1\"?", bookmark.fullText()); } - if(KMessageBox::warningContinueCancel( + if (KMessageBox::warningContinueCancel( 0, dialogText, dialogCaption, @@ -329,7 +329,7 @@ bool BookmarkOwner::deleteBookmark(const KBookmark &bookmark) KStandardGuiItem::cancel(), "bookmarkDeletition_askAgain") != KMessageBox::Continue - ) + ) return false; bmg.deleteBookmark(bookmark); @@ -340,7 +340,7 @@ bool BookmarkOwner::deleteBookmark(const KBookmark &bookmark) void BookmarkOwner::setToolBarFolder(KBookmark bookmark) { - if(!bookmark.isGroup()) + if (!bookmark.isGroup()) return; unsetToolBarFolder(); @@ -354,7 +354,7 @@ void BookmarkOwner::setToolBarFolder(KBookmark bookmark) void BookmarkOwner::unsetToolBarFolder() { KBookmarkGroup toolbar = m_manager->toolbar(); - if(!toolbar.isNull()) + if (!toolbar.isNull()) { toolbar.internalElement().setAttribute("toolbar", "no"); toolbar.setIcon(""); diff --git a/src/bookmarks/bookmarkprovider.cpp b/src/bookmarks/bookmarkprovider.cpp index 62f2433b..9b4be96f 100644 --- a/src/bookmarks/bookmarkprovider.cpp +++ b/src/bookmarks/bookmarkprovider.cpp @@ -57,7 +57,7 @@ BookmarkProvider::BookmarkProvider(QObject *parent) m_manager = KBookmarkManager::userBookmarksManager(); const QString bookmarksFile = KStandardDirs::locateLocal("data", QString::fromLatin1("konqueror/bookmarks.xml")); - if(!QFile::exists(bookmarksFile)) + if (!QFile::exists(bookmarksFile)) { kDebug() << "copying of defaultbookmarks.xbel ..."; @@ -103,7 +103,7 @@ KActionMenu* BookmarkProvider::bookmarkActionMenu(QWidget *parent) void BookmarkProvider::registerBookmarkBar(BookmarkToolBar *toolbar) { - if(m_bookmarkToolBars.contains(toolbar)) + if (m_bookmarkToolBars.contains(toolbar)) return; m_bookmarkToolBars.append(toolbar); @@ -118,7 +118,7 @@ void BookmarkProvider::removeBookmarkBar(BookmarkToolBar *toolbar) void BookmarkProvider::registerBookmarkPanel(BookmarksPanel *panel) { - if(panel && !m_bookmarkPanels.contains(panel)) + if (panel && !m_bookmarkPanels.contains(panel)) { m_bookmarkPanels.append(panel); connect(panel, SIGNAL(expansionChanged()), this, SLOT(slotPanelChanged())); @@ -128,13 +128,13 @@ void BookmarkProvider::registerBookmarkPanel(BookmarksPanel *panel) void BookmarkProvider::removeBookmarkPanel(BookmarksPanel *panel) { - if(!panel) + if (!panel) return; m_bookmarkPanels.removeOne(panel); panel->disconnect(this); - if(m_bookmarkPanels.isEmpty()) + if (m_bookmarkPanels.isEmpty()) rApp->bookmarkProvider()->bookmarkManager()->emitChanged(); } @@ -142,7 +142,7 @@ void BookmarkProvider::removeBookmarkPanel(BookmarksPanel *panel) QAction* BookmarkProvider::actionByName(const QString &name) { QAction *action = m_actionCollection->action(name); - if(action) + if (action) return action; return new QAction(this); } @@ -159,8 +159,8 @@ QList<KBookmark> BookmarkProvider::find(const QString &text) QList<KBookmark> list; KBookmarkGroup root = rApp->bookmarkProvider()->rootGroup(); - if(!root.isNull()) - for(KBookmark bookmark = root.first(); !bookmark.isNull(); bookmark = root.next(bookmark)) + if (!root.isNull()) + for (KBookmark bookmark = root.first(); !bookmark.isNull(); bookmark = root.next(bookmark)) find(&list, bookmark, text); return list; @@ -170,7 +170,7 @@ QList<KBookmark> BookmarkProvider::find(const QString &text) KBookmark BookmarkProvider::bookmarkForUrl(const KUrl &url) { KBookmarkGroup root = rootGroup(); - if(root.isNull()) + if (root.isNull()) return KBookmark(); return bookmarkForUrl(root, url); @@ -181,13 +181,13 @@ void BookmarkProvider::slotBookmarksChanged() { foreach(BookmarkToolBar * bookmarkToolBar, m_bookmarkToolBars) { - if(bookmarkToolBar) + if (bookmarkToolBar) { bookmarkToolBar->toolBar()->clear(); fillBookmarkBar(bookmarkToolBar); } } - if(rApp->mainWindow() && rApp->mainWindow()->currentTab() && rApp->mainWindow()->currentTab()->url().toMimeDataString().contains("about:bookmarks")) + if (rApp->mainWindow() && rApp->mainWindow()->currentTab() && rApp->mainWindow()->currentTab()->url().toMimeDataString().contains("about:bookmarks")) rApp->loadUrl(KUrl("about:bookmarks"), Rekonq::CurrentTab); } @@ -195,12 +195,12 @@ void BookmarkProvider::slotBookmarksChanged() void BookmarkProvider::fillBookmarkBar(BookmarkToolBar *toolBar) { KBookmarkGroup root = m_manager->toolbar(); - if(root.isNull()) + if (root.isNull()) return; - for(KBookmark bookmark = root.first(); !bookmark.isNull(); bookmark = root.next(bookmark)) + for (KBookmark bookmark = root.first(); !bookmark.isNull(); bookmark = root.next(bookmark)) { - if(bookmark.isGroup()) + if (bookmark.isGroup()) { KBookmarkActionMenu *menuAction = new KBookmarkActionMenu(bookmark.toGroup(), this); menuAction->setDelayed(false); @@ -213,7 +213,7 @@ void BookmarkProvider::fillBookmarkBar(BookmarkToolBar *toolBar) toolBar->toolBar()->addAction(menuAction); toolBar->toolBar()->widgetForAction(menuAction)->installEventFilter(toolBar); } - else if(bookmark.isSeparator()) + else if (bookmark.isSeparator()) { toolBar->toolBar()->addSeparator(); } @@ -233,20 +233,20 @@ void BookmarkProvider::slotPanelChanged() { foreach(BookmarksPanel * panel, m_bookmarkPanels) { - if(panel && panel != sender()) + if (panel && panel != sender()) panel->loadFoldedState(); } - if(rApp->mainWindow() && rApp->mainWindow()->currentTab() && rApp->mainWindow()->currentTab()->url().toMimeDataString().contains("about:bookmarks")) + if (rApp->mainWindow() && rApp->mainWindow()->currentTab() && rApp->mainWindow()->currentTab()->url().toMimeDataString().contains("about:bookmarks")) rApp->loadUrl(KUrl("about:bookmarks"), Rekonq::CurrentTab); } void BookmarkProvider::find(QList<KBookmark> *list, const KBookmark &bookmark, const QString &text) { - if(bookmark.isGroup()) + if (bookmark.isGroup()) { KBookmarkGroup group = bookmark.toGroup(); - for(KBookmark bm = group.first(); !bm.isNull(); bm = group.next(bm)) + for (KBookmark bm = group.first(); !bm.isNull(); bm = group.next(bm)) find(list, bm, text); } else @@ -255,14 +255,14 @@ void BookmarkProvider::find(QList<KBookmark> *list, const KBookmark &bookmark, c bool matches = true; foreach(const QString & word, words) { - if(!bookmark.url().url().contains(word, Qt::CaseInsensitive) + if (!bookmark.url().url().contains(word, Qt::CaseInsensitive) && !bookmark.fullText().contains(word, Qt::CaseInsensitive)) { matches = false; break; } } - if(matches) + if (matches) *list << bookmark; } } @@ -272,18 +272,18 @@ KBookmark BookmarkProvider::bookmarkForUrl(const KBookmark &bookmark, const KUrl { KBookmark found; - if(bookmark.isGroup()) + if (bookmark.isGroup()) { KBookmarkGroup group = bookmark.toGroup(); KBookmark bookmark = group.first(); - while(!bookmark.isNull() && found.isNull()) + while (!bookmark.isNull() && found.isNull()) { found = bookmarkForUrl(bookmark, url); bookmark = group.next(bookmark); } } - else if(!bookmark.isSeparator() && bookmark.url() == url) + else if (!bookmark.isSeparator() && bookmark.url() == url) { found = bookmark; } @@ -295,19 +295,19 @@ KBookmark BookmarkProvider::bookmarkForUrl(const KBookmark &bookmark, const KUrl void BookmarkProvider::copyBookmarkGroup(const KBookmarkGroup &groupToCopy, KBookmarkGroup destGroup) { KBookmark bookmark = groupToCopy.first(); - while(!bookmark.isNull()) + while (!bookmark.isNull()) { - if(bookmark.isGroup()) + if (bookmark.isGroup()) { KBookmarkGroup newDestGroup = destGroup.createNewFolder(bookmark.text()); - if(bookmark.toGroup().isToolbarGroup()) + if (bookmark.toGroup().isToolbarGroup()) { newDestGroup.internalElement().setAttribute("toolbar", "yes"); newDestGroup.setIcon("bookmark-toolbar"); } copyBookmarkGroup(bookmark.toGroup(), newDestGroup); } - else if(bookmark.isSeparator()) + else if (bookmark.isSeparator()) { destGroup.createNewSeparator(); } diff --git a/src/bookmarks/bookmarkscontextmenu.cpp b/src/bookmarks/bookmarkscontextmenu.cpp index 16936682..735e3412 100644 --- a/src/bookmarks/bookmarkscontextmenu.cpp +++ b/src/bookmarks/bookmarkscontextmenu.cpp @@ -70,7 +70,7 @@ void BookmarksContextMenu::addFolderActions() { KBookmarkGroup group = bookmark().toGroup(); - if(bookmark().internalElement().attributeNode("toolbar").value() == "yes") + if (bookmark().internalElement().attributeNode("toolbar").value() == "yes") { addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::UNSET_TOOLBAR_FOLDER)); } @@ -79,16 +79,16 @@ void BookmarksContextMenu::addFolderActions() addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::SET_TOOLBAR_FOLDER)); } - if(!group.first().isNull()) + if (!group.first().isNull()) { KBookmark child = group.first(); - while(child.isGroup() || child.isSeparator()) + while (child.isGroup() || child.isSeparator()) { child = group.next(child); } - if(!child.isNull()) + if (!child.isNull()) { addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::OPEN_FOLDER)); addSeparator(); @@ -121,7 +121,7 @@ void BookmarksContextMenu::addSeparatorActions() void BookmarksContextMenu::addNullActions() { KBookmarkManager *manager = rApp->bookmarkProvider()->bookmarkManager(); - if(manager->toolbar().hasParent()) + if (manager->toolbar().hasParent()) { addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::UNSET_TOOLBAR_FOLDER)); } @@ -133,15 +133,15 @@ void BookmarksContextMenu::addNullActions() void BookmarksContextMenu::addActions() { - if(bookmark().isNull() || m_nullForced) + if (bookmark().isNull() || m_nullForced) { addNullActions(); } - else if(bookmark().isSeparator()) + else if (bookmark().isSeparator()) { addSeparatorActions(); } - else if(bookmark().isGroup()) + else if (bookmark().isGroup()) { addFolderActions(); } diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp index fcd62f6c..eb46119e 100644 --- a/src/bookmarks/bookmarkspanel.cpp +++ b/src/bookmarks/bookmarkspanel.cpp @@ -71,7 +71,7 @@ void BookmarksPanel::loadFoldedState() void BookmarksPanel::contextMenu(const QPoint &pos) { - if(_loadingState) + if (_loadingState) return; BookmarksContextMenu menu(bookmarkForIndex(panelTreeView()->indexAt(pos)), @@ -86,7 +86,7 @@ void BookmarksPanel::contextMenu(const QPoint &pos) void BookmarksPanel::deleteBookmark() { QModelIndex index = panelTreeView()->currentIndex(); - if(_loadingState || !index.isValid()) + if (_loadingState || !index.isValid()) return; rApp->bookmarkProvider()->bookmarkOwner()->deleteBookmark(bookmarkForIndex(index)); @@ -95,7 +95,7 @@ void BookmarksPanel::deleteBookmark() void BookmarksPanel::onCollapse(const QModelIndex &index) { - if(_loadingState) + if (_loadingState) return; bookmarkForIndex(index).internalElement().setAttribute("folded", "yes"); @@ -105,7 +105,7 @@ void BookmarksPanel::onCollapse(const QModelIndex &index) void BookmarksPanel::onExpand(const QModelIndex &index) { - if(_loadingState) + if (_loadingState) return; bookmarkForIndex(index).internalElement().setAttribute("folded", "no"); @@ -128,19 +128,19 @@ void BookmarksPanel::setup() void BookmarksPanel::loadFoldedState(const QModelIndex &root) { QAbstractItemModel *model = panelTreeView()->model(); - if(!model) + if (!model) return; int count = model->rowCount(root); QModelIndex index; - for(int i = 0; i < count; ++i) + for (int i = 0; i < count; ++i) { index = model->index(i, 0, root); - if(index.isValid()) + if (index.isValid()) { KBookmark bm = bookmarkForIndex(index); - if(bm.isGroup()) + if (bm.isGroup()) { panelTreeView()->setExpanded(index, bm.toGroup().isOpen()); loadFoldedState(index); @@ -152,7 +152,7 @@ void BookmarksPanel::loadFoldedState(const QModelIndex &root) KBookmark BookmarksPanel::bookmarkForIndex(const QModelIndex &index) { - if(!index.isValid()) + if (!index.isValid()) return KBookmark(); const UrlFilterProxyModel *proxyModel = static_cast<const UrlFilterProxyModel*>(index.model()); diff --git a/src/bookmarks/bookmarkstoolbar.cpp b/src/bookmarks/bookmarkstoolbar.cpp index efa1e1cc..6fa8fdec 100644 --- a/src/bookmarks/bookmarkstoolbar.cpp +++ b/src/bookmarks/bookmarkstoolbar.cpp @@ -70,7 +70,7 @@ BookmarkMenu::~BookmarkMenu() KMenu * BookmarkMenu::contextMenu(QAction *act) { KBookmarkActionInterface* action = dynamic_cast<KBookmarkActionInterface *>(act); - if(!action) + if (!action) return 0; return new BookmarksContextMenu(action->bookmark(), manager(), static_cast<BookmarkOwner*>(owner())); } @@ -78,7 +78,7 @@ KMenu * BookmarkMenu::contextMenu(QAction *act) QAction * BookmarkMenu::actionForBookmark(const KBookmark &bookmark) { - if(bookmark.isGroup()) + if (bookmark.isGroup()) { KBookmarkActionMenu *actionMenu = new KBookmarkActionMenu(bookmark, this); BookmarkMenu *menu = new BookmarkMenu(manager(), owner(), actionMenu->menu(), bookmark.address()); @@ -86,7 +86,7 @@ QAction * BookmarkMenu::actionForBookmark(const KBookmark &bookmark) connect(actionMenu, SIGNAL(hovered()), menu, SLOT(slotAboutToShow())); return actionMenu; } - else if(bookmark.isSeparator()) + else if (bookmark.isSeparator()) { return KBookmarkMenu::actionForBookmark(bookmark); } @@ -105,10 +105,10 @@ void BookmarkMenu::refill() clear(); fillBookmarks(); - if(parentMenu()->actions().count() > 0) + if (parentMenu()->actions().count() > 0) parentMenu()->addSeparator(); - if(isRoot()) + if (isRoot()) { addAddBookmark(); addAddBookmarksList(); @@ -129,16 +129,16 @@ void BookmarkMenu::addOpenFolderInTabs() { KBookmarkGroup group = manager()->findByAddress(parentAddress()).toGroup(); - if(!group.first().isNull()) + if (!group.first().isNull()) { KBookmark bookmark = group.first(); - while(bookmark.isGroup() || bookmark.isSeparator()) + while (bookmark.isGroup() || bookmark.isSeparator()) { bookmark = group.next(bookmark); } - if(!bookmark.isNull()) + if (!bookmark.isNull()) { parentMenu()->addAction(rApp->bookmarkProvider()->bookmarkOwner()->createAction(group, BookmarkOwner::OPEN_FOLDER)); } @@ -149,7 +149,7 @@ void BookmarkMenu::addOpenFolderInTabs() void BookmarkMenu::actionHovered() { KBookmarkActionInterface* action = dynamic_cast<KBookmarkActionInterface *>(sender()); - if(action) + if (action) rApp->mainWindow()->notifyMessage(action->bookmark().url().url()); } @@ -173,7 +173,7 @@ BookmarkToolBar::BookmarkToolBar(KToolBar *toolBar, QObject *parent) toolBar->installEventFilter(this); toolBar->setShortcutEnabled(false); - if(toolBar->isVisible()) + if (toolBar->isVisible()) { rApp->bookmarkProvider()->fillBookmarkBar(this); m_filled = true; @@ -192,7 +192,7 @@ void BookmarkToolBar::contextMenu(const QPoint &point) KBookmarkActionInterface *action = dynamic_cast<KBookmarkActionInterface*>(toolBar()->actionAt(point)); KBookmark bookmark = rApp->bookmarkProvider()->bookmarkManager()->toolbar(); bool nullAction = true; - if(action) + if (action) { bookmark = action->bookmark(); nullAction = false; @@ -222,27 +222,27 @@ void BookmarkToolBar::menuHidden() void BookmarkToolBar::hideMenu() { - if(m_currentMenu) + if (m_currentMenu) m_currentMenu->hide(); } bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) { - if(m_currentMenu && m_currentMenu->isVisible() + if (m_currentMenu && m_currentMenu->isVisible() && !m_currentMenu->rect().contains(m_currentMenu->mapFromGlobal(QCursor::pos()))) { // To switch root folders as in a menubar KBookmarkActionMenu* act = dynamic_cast<KBookmarkActionMenu *>(toolBar()->actionAt(toolBar()->mapFromGlobal(QCursor::pos()))); - if(event->type() == QEvent::MouseMove && act && act->menu() != m_currentMenu) + if (event->type() == QEvent::MouseMove && act && act->menu() != m_currentMenu) { m_currentMenu->hide(); QPoint pos = toolBar()->mapToGlobal(toolBar()->widgetForAction(act)->pos()); act->menu()->popup(QPoint(pos.x(), pos.y() + toolBar()->widgetForAction(act)->height())); } - else if(event->type() == QEvent::MouseButtonPress && act) + else if (event->type() == QEvent::MouseButtonPress && act) { m_currentMenu->hide(); } @@ -250,11 +250,11 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) return QObject::eventFilter(watched, event); } - switch(event->type()) + switch (event->type()) { case QEvent::Show: { - if(!m_filled) + if (!m_filled) { rApp->bookmarkProvider()->fillBookmarkBar(this); m_filled = true; @@ -265,10 +265,10 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) case QEvent::ActionRemoved: { QActionEvent *actionEvent = static_cast<QActionEvent*>(event); - if(actionEvent && actionEvent->action() != m_dropAction) + if (actionEvent && actionEvent->action() != m_dropAction) { QWidget *widget = toolBar()->widgetForAction(actionEvent->action()); - if(widget) + if (widget) { widget->removeEventFilter(this); } @@ -279,10 +279,10 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) case QEvent::ParentChange: { QActionEvent *actionEvent = static_cast<QActionEvent*>(event); - if(actionEvent && actionEvent->action() != m_dropAction) + if (actionEvent && actionEvent->action() != m_dropAction) { QWidget *widget = toolBar()->widgetForAction(actionEvent->action()); - if(widget) + if (widget) { widget->removeEventFilter(this); } @@ -293,7 +293,7 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) case QEvent::DragEnter: { QDragEnterEvent *dragEvent = static_cast<QDragEnterEvent*>(event); - if(dragEvent->mimeData()->hasFormat("application/rekonq-bookmark") || dragEvent->mimeData()->hasFormat("text/uri-list") || dragEvent->mimeData()->hasFormat("text/plain")) + if (dragEvent->mimeData()->hasFormat("application/rekonq-bookmark") || dragEvent->mimeData()->hasFormat("text/uri-list") || dragEvent->mimeData()->hasFormat("text/plain")) { QFrame* dropIndicatorWidget = new QFrame(toolBar()); dropIndicatorWidget->setFrameShape(QFrame::VLine); @@ -308,7 +308,7 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) { QDragLeaveEvent *dragEvent = static_cast<QDragLeaveEvent*>(event); - if(m_checkedAction) + if (m_checkedAction) { m_checkedAction->setCheckable(false); m_checkedAction->setChecked(false); @@ -323,26 +323,26 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) case QEvent::DragMove: { QDragMoveEvent *dragEvent = static_cast<QDragMoveEvent*>(event); - if(dragEvent->mimeData()->hasFormat("application/rekonq-bookmark") || dragEvent->mimeData()->hasFormat("text/uri-list") || dragEvent->mimeData()->hasFormat("text/plain")) + if (dragEvent->mimeData()->hasFormat("application/rekonq-bookmark") || dragEvent->mimeData()->hasFormat("text/uri-list") || dragEvent->mimeData()->hasFormat("text/plain")) { QAction *overAction = toolBar()->actionAt(dragEvent->pos()); KBookmarkActionInterface *overActionBK = dynamic_cast<KBookmarkActionInterface*>(overAction); QWidget *widgetAction = toolBar()->widgetForAction(overAction); - if(overAction != m_dropAction && overActionBK && widgetAction && m_dropAction) + if (overAction != m_dropAction && overActionBK && widgetAction && m_dropAction) { toolBar()->removeAction(m_dropAction); - if(m_checkedAction) + if (m_checkedAction) { m_checkedAction->setCheckable(false); m_checkedAction->setChecked(false); } - if(!overActionBK->bookmark().isGroup()) + if (!overActionBK->bookmark().isGroup()) { - if((dragEvent->pos().x() - widgetAction->pos().x()) > (widgetAction->width() / 2)) + if ((dragEvent->pos().x() - widgetAction->pos().x()) > (widgetAction->width() / 2)) { - if(toolBar()->actions().count() > toolBar()->actions().indexOf(overAction) + 1) + if (toolBar()->actions().count() > toolBar()->actions().indexOf(overAction) + 1) { toolBar()->insertAction(toolBar()->actions().at(toolBar()->actions().indexOf(overAction) + 1), m_dropAction); } @@ -358,9 +358,9 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) } else { - if((dragEvent->pos().x() - widgetAction->pos().x()) >= (widgetAction->width() * 0.75)) + if ((dragEvent->pos().x() - widgetAction->pos().x()) >= (widgetAction->width() * 0.75)) { - if(toolBar()->actions().count() > toolBar()->actions().indexOf(overAction) + 1) + if (toolBar()->actions().count() > toolBar()->actions().indexOf(overAction) + 1) { toolBar()->insertAction(toolBar()->actions().at(toolBar()->actions().indexOf(overAction) + 1), m_dropAction); } @@ -369,7 +369,7 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) toolBar()->addAction(m_dropAction); } } - else if((dragEvent->pos().x() - widgetAction->pos().x()) <= (widgetAction->width() * 0.25)) + else if ((dragEvent->pos().x() - widgetAction->pos().x()) <= (widgetAction->width() * 0.25)) { toolBar()->insertAction(overAction, m_dropAction); } @@ -394,14 +394,14 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) KBookmark bookmark; KBookmarkGroup root = rApp->bookmarkProvider()->bookmarkManager()->toolbar(); - if(dropEvent->mimeData()->hasFormat("application/rekonq-bookmark")) + if (dropEvent->mimeData()->hasFormat("application/rekonq-bookmark")) { QByteArray addresses = dropEvent->mimeData()->data("application/rekonq-bookmark"); bookmark = rApp->bookmarkProvider()->bookmarkManager()->findByAddress(QString::fromLatin1(addresses.data())); - if(bookmark.isNull()) + if (bookmark.isNull()) return false; } - else if(dropEvent->mimeData()->hasFormat("text/uri-list")) + else if (dropEvent->mimeData()->hasFormat("text/uri-list")) { // DROP is URL QString url = dropEvent->mimeData()->urls().at(0).toString(); @@ -410,12 +410,12 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) : url; bookmark = root.addBookmark(title, url); } - else if(dropEvent->mimeData()->hasFormat("text/plain")) + else if (dropEvent->mimeData()->hasFormat("text/plain")) { // DROP is TEXT QString url = dropEvent->mimeData()->text(); KUrl u(url); - if(u.isValid()) + if (u.isValid()) { QString title = url.contains(rApp->mainWindow()->currentTab()->url().url()) ? rApp->mainWindow()->currentTab()->view()->title() @@ -429,9 +429,9 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) } QAction *destAction = toolBar()->actionAt(dropEvent->pos()); - if(destAction && destAction == m_dropAction) + if (destAction && destAction == m_dropAction) { - if(toolBar()->actions().indexOf(m_dropAction) > 0) + if (toolBar()->actions().indexOf(m_dropAction) > 0) { destAction = toolBar()->actions().at(toolBar()->actions().indexOf(m_dropAction) - 1); } @@ -441,19 +441,19 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) } } - if(destAction) + if (destAction) { KBookmarkActionInterface *destBookmarkAction = dynamic_cast<KBookmarkActionInterface *>(destAction); QWidget *widgetAction = toolBar()->widgetForAction(destAction); - if(destBookmarkAction && !destBookmarkAction->bookmark().isNull() && widgetAction + if (destBookmarkAction && !destBookmarkAction->bookmark().isNull() && widgetAction && bookmark.address() != destBookmarkAction->bookmark().address()) { KBookmark destBookmark = destBookmarkAction->bookmark(); - if(!destBookmark.isGroup()) + if (!destBookmark.isGroup()) { - if((dropEvent->pos().x() - widgetAction->pos().x()) >= (widgetAction->width() / 2)) + if ((dropEvent->pos().x() - widgetAction->pos().x()) >= (widgetAction->width() / 2)) { root.moveBookmark(bookmark, destBookmark); } @@ -464,11 +464,11 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) } else { - if((dropEvent->pos().x() - widgetAction->pos().x()) >= (widgetAction->width() * 0.75)) + if ((dropEvent->pos().x() - widgetAction->pos().x()) >= (widgetAction->width() * 0.75)) { root.moveBookmark(bookmark, destBookmark); } - else if((dropEvent->pos().x() - widgetAction->pos().x()) <= (widgetAction->width() * 0.25)) + else if ((dropEvent->pos().x() - widgetAction->pos().x()) <= (widgetAction->width() * 0.25)) { root.moveBookmark(bookmark, destBookmark.parentGroup().previous(destBookmark)); } @@ -486,7 +486,7 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) { root.deleteBookmark(bookmark); bookmark = root.addBookmark(bookmark); - if(dropEvent->pos().x() < toolBar()->widgetForAction(toolBar()->actions().first())->pos().x()) + if (dropEvent->pos().x() < toolBar()->widgetForAction(toolBar()->actions().first())->pos().x()) { root.moveBookmark(bookmark, KBookmark()); } @@ -502,22 +502,22 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) } // These events need to be handled only for Bookmark actions and not the bar - if(watched != toolBar()) + if (watched != toolBar()) { - switch(event->type()) + switch (event->type()) { case QEvent::MouseButtonPress: // drag handling { QPoint pos = toolBar()->mapFromGlobal(QCursor::pos()); KBookmarkActionInterface *action = dynamic_cast<KBookmarkActionInterface *>(toolBar()->actionAt(pos)); - if(action) + if (action) { m_dragAction = toolBar()->actionAt(pos); m_startDragPos = pos; // The menu is displayed only when the mouse button is released - if(action->bookmark().isGroup()) + if (action->bookmark().isGroup()) return true; } } @@ -526,7 +526,7 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) case QEvent::MouseMove: { int distance = (toolBar()->mapFromGlobal(QCursor::pos()) - m_startDragPos).manhattanLength(); - if(!m_currentMenu && distance >= QApplication::startDragDistance()) + if (!m_currentMenu && distance >= QApplication::startDragDistance()) { startDrag(); } @@ -538,7 +538,7 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) int distance = (toolBar()->mapFromGlobal(QCursor::pos()) - m_startDragPos).manhattanLength(); KBookmarkActionInterface *action = dynamic_cast<KBookmarkActionInterface *>(toolBar()->actionAt(m_startDragPos)); - if(action && action->bookmark().isGroup() && distance < QApplication::startDragDistance()) + if (action && action->bookmark().isGroup() && distance < QApplication::startDragDistance()) { KBookmarkActionMenu *menu = dynamic_cast<KBookmarkActionMenu *>(toolBar()->actionAt(m_startDragPos)); QPoint actionPos = toolBar()->mapToGlobal(toolBar()->widgetForAction(menu)->pos()); @@ -559,7 +559,7 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) void BookmarkToolBar::actionHovered() { KBookmarkActionInterface* action = dynamic_cast<KBookmarkActionInterface *>(sender()); - if(action) + if (action) rApp->mainWindow()->notifyMessage(action->bookmark().url().url()); } @@ -567,7 +567,7 @@ void BookmarkToolBar::actionHovered() void BookmarkToolBar::startDrag() { KBookmarkActionInterface *action = dynamic_cast<KBookmarkActionInterface *>(m_dragAction); - if(action) + if (action) { QMimeData *mimeData = new QMimeData; KBookmark bookmark = action->bookmark(); @@ -579,7 +579,7 @@ void BookmarkToolBar::startDrag() QDrag *drag = new QDrag(toolBar()); drag->setMimeData(mimeData); - if(bookmark.isGroup()) + if (bookmark.isGroup()) { drag->setPixmap(KIcon(bookmark.icon()).pixmap(24, 24)); } @@ -597,7 +597,7 @@ void BookmarkToolBar::startDrag() void BookmarkToolBar::dragDestroyed() { // A workaround to get rid of the checked state of the dragged action - if(m_dragAction) + if (m_dragAction) { m_dragAction->setVisible(false); m_dragAction->setVisible(true); diff --git a/src/bookmarks/bookmarkstreemodel.cpp b/src/bookmarks/bookmarkstreemodel.cpp index f29e866f..42cd7b28 100644 --- a/src/bookmarks/bookmarkstreemodel.cpp +++ b/src/bookmarks/bookmarkstreemodel.cpp @@ -58,45 +58,45 @@ BtmItem::~BtmItem() QVariant BtmItem::data(int role) const { - if(m_kbm.isNull()) + if (m_kbm.isNull()) return QVariant(); // should only happen for root item - if(role == Qt::DisplayRole) + if (role == Qt::DisplayRole) return m_kbm.text(); - if(role == Qt::DecorationRole) + if (role == Qt::DecorationRole) { // NOTE // this should be: // return KIcon(m_kbm.icon()); // but I cannot let it work :( // I really cannot understand how let this work properly... - if(m_kbm.isGroup() || m_kbm.isSeparator()) + if (m_kbm.isGroup() || m_kbm.isSeparator()) return KIcon(m_kbm.icon()); else return rApp->iconManager()->iconForUrl(KUrl(m_kbm.url())); } - if(role == Qt::UserRole) + if (role == Qt::UserRole) return m_kbm.url(); - if(role == Qt::ToolTipRole) + if (role == Qt::ToolTipRole) { QString tooltip = m_kbm.fullText(); - if(m_kbm.isGroup()) + if (m_kbm.isGroup()) tooltip += i18ncp("%1=Number of items in bookmark folder", " (1 item)", " (%1 items)", childCount()); QString url = m_kbm.url().url(); - if(!url.isEmpty()) + if (!url.isEmpty()) { - if(!tooltip.isEmpty()) + if (!tooltip.isEmpty()) tooltip += '\n'; tooltip += url; } - if(!m_kbm.description().isEmpty()) + if (!m_kbm.description().isEmpty()) { - if(!tooltip.isEmpty()) + if (!tooltip.isEmpty()) tooltip += '\n'; tooltip += m_kbm.description(); } @@ -110,7 +110,7 @@ QVariant BtmItem::data(int role) const int BtmItem::row() const { - if(m_parent) + if (m_parent) return m_parent->m_children.indexOf(const_cast< BtmItem* >(this)); return 0; } @@ -139,7 +139,7 @@ BtmItem* BtmItem::parent() const void BtmItem::appendChild(BtmItem *child) { - if(!child) + if (!child) return; child->m_parent = this; @@ -180,7 +180,7 @@ BookmarksTreeModel::~BookmarksTreeModel() int BookmarksTreeModel::rowCount(const QModelIndex &parent) const { BtmItem *parentItem = 0; - if(!parent.isValid()) + if (!parent.isValid()) { parentItem = m_root; } @@ -203,12 +203,12 @@ Qt::ItemFlags BookmarksTreeModel::flags(const QModelIndex &index) const { Qt::ItemFlags flags = QAbstractItemModel::flags(index); - if(!index.isValid()) + if (!index.isValid()) return flags | Qt::ItemIsDropEnabled; flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled; - if(bookmarkForIndex(index).isGroup()) + if (bookmarkForIndex(index).isGroup()) flags |= Qt::ItemIsDropEnabled; return flags; @@ -217,18 +217,18 @@ Qt::ItemFlags BookmarksTreeModel::flags(const QModelIndex &index) const QModelIndex BookmarksTreeModel::index(int row, int column, const QModelIndex &parent) const { - if(!hasIndex(row, column, parent)) + if (!hasIndex(row, column, parent)) return QModelIndex(); BtmItem *parentItem; - if(!parent.isValid()) + if (!parent.isValid()) parentItem = m_root; else parentItem = static_cast<BtmItem*>(parent.internalPointer()); BtmItem *childItem = parentItem->child(row); - if(childItem) + if (childItem) return createIndex(row, column, childItem); return QModelIndex(); @@ -237,13 +237,13 @@ QModelIndex BookmarksTreeModel::index(int row, int column, const QModelIndex &pa QModelIndex BookmarksTreeModel::parent(const QModelIndex &index) const { - if(!index.isValid()) + if (!index.isValid()) return QModelIndex(); BtmItem *childItem = static_cast<BtmItem*>(index.internalPointer()); BtmItem *parentItem = childItem->parent(); - if(parentItem == m_root) + if (parentItem == m_root) return QModelIndex(); return createIndex(parentItem->row(), 0, parentItem); @@ -252,20 +252,20 @@ QModelIndex BookmarksTreeModel::parent(const QModelIndex &index) const QVariant BookmarksTreeModel::data(const QModelIndex &index, int role) const { - if(!index.isValid()) + if (!index.isValid()) return QVariant(); BtmItem *node = static_cast<BtmItem*>(index.internalPointer()); - if(node && node == m_root) + if (node && node == m_root) { - if(role == Qt::DisplayRole) + if (role == Qt::DisplayRole) return i18n("Bookmarks"); - if(role == Qt::DecorationRole) + if (role == Qt::DecorationRole) return KIcon("bookmarks"); } else { - if(node) + if (node) return node->data(role); } @@ -281,21 +281,21 @@ QStringList BookmarksTreeModel::mimeTypes() const bool BookmarksTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) { - if(action != Qt::MoveAction || !data->hasFormat("application/rekonq-bookmark")) + if (action != Qt::MoveAction || !data->hasFormat("application/rekonq-bookmark")) return false; QByteArray addresses = data->data("application/rekonq-bookmark"); KBookmark bookmark = rApp->bookmarkProvider()->bookmarkManager()->findByAddress(QString::fromLatin1(addresses.data())); KBookmarkGroup root; - if(parent.isValid()) + if (parent.isValid()) root = bookmarkForIndex(parent).toGroup(); else root = rApp->bookmarkProvider()->rootGroup(); QModelIndex destIndex = index(row, column, parent); - if(destIndex.isValid() && row != -1) + if (destIndex.isValid() && row != -1) { root.moveBookmark(bookmark, root.previous(bookmarkForIndex(destIndex))); } @@ -331,7 +331,7 @@ QMimeData* BookmarksTreeModel::mimeData(const QModelIndexList &indexes) const void BookmarksTreeModel::bookmarksChanged(const QString &groupAddress) { - if(groupAddress.isEmpty()) + if (groupAddress.isEmpty()) { resetModel(); } @@ -347,10 +347,10 @@ void BookmarksTreeModel::bookmarksChanged(const QString &groupAddress) foreach(const QString & sIndex, indexChain) { i = sIndex.toInt(&ok); - if(!ok) + if (!ok) break; - if(i < 0 || i >= node->childCount()) + if (i < 0 || i >= node->childCount()) break; node = node->child(i); @@ -384,14 +384,14 @@ void BookmarksTreeModel::populate(BtmItem *node, KBookmarkGroup bmg) { node->clear(); - if(bmg.isNull()) + if (bmg.isNull()) return; KBookmark bm = bmg.first(); - while(!bm.isNull()) + while (!bm.isNull()) { BtmItem *newChild = new BtmItem(bm); - if(bm.isGroup()) + if (bm.isGroup()) populate(newChild, bm.toGroup()); node->appendChild(newChild); diff --git a/src/clicktoflash.cpp b/src/clicktoflash.cpp index 70825685..a1b0c5bb 100644 --- a/src/clicktoflash.cpp +++ b/src/clicktoflash.cpp @@ -61,16 +61,16 @@ void ClickToFlash::load() { QWidget *parent = parentWidget(); QWebView *view = 0; - while(parent) + while (parent) { - if(QWebView *aView = qobject_cast<QWebView*>(parent)) + if (QWebView *aView = qobject_cast<QWebView*>(parent)) { view = aView; break; } parent = parent->parentWidget(); } - if(!view) + if (!view) return; const QString selector = QL1S("%1[type=\"application/x-shockwave-flash\"]"); @@ -79,7 +79,7 @@ void ClickToFlash::load() QList<QWebFrame*> frames; frames.append(view->page()->mainFrame()); - while(!frames.isEmpty()) + while (!frames.isEmpty()) { QWebFrame *frame = frames.takeFirst(); QWebElement docElement = frame->documentElement(); @@ -90,7 +90,7 @@ void ClickToFlash::load() foreach(QWebElement element, elements) { - if(checkElement(element)) + if (checkElement(element)) { QWebElement substitute = element.clone(); emit signalLoadClickToFlash(true); @@ -112,19 +112,19 @@ bool ClickToFlash::checkElement(QWebElement el) checkString = QUrl(el.attribute("src")).toString(QUrl::RemoveQuery); urlString = m_url.toString(QUrl::RemoveQuery); - if(urlString.contains(checkString)) + if (urlString.contains(checkString)) return true; QWebElementCollection collec = el.findAll("*"); int i = 0; - while(i < collec.count()) + while (i < collec.count()) { QWebElement el = collec.at(i); checkString = QUrl(el.attribute("src")).toString(QUrl::RemoveQuery); urlString = m_url.toString(QUrl::RemoveQuery); - if(urlString.contains(checkString)) + if (urlString.contains(checkString)) return true; i++; diff --git a/src/downloaditem.cpp b/src/downloaditem.cpp index 9570e4f9..cc528275 100644 --- a/src/downloaditem.cpp +++ b/src/downloaditem.cpp @@ -79,7 +79,7 @@ QString DownloadItem::icon() const // update progress for the plain KIO::Job backend void DownloadItem::updateProgress(KJob *job, unsigned long value) { - if(m_shouldAbort) + if (m_shouldAbort) job->kill(KJob::EmitResult); emit downloadProgress(value); } @@ -88,7 +88,7 @@ void DownloadItem::updateProgress(KJob *job, unsigned long value) // emit downloadFinished signal in KJob case void DownloadItem::onFinished(KJob *job) { - if(!job->error()) + if (!job->error()) emit downloadProgress(100); emit downloadFinished(!job->error()); } @@ -117,35 +117,35 @@ void DownloadItem::setKGetTransferDbusPath(const QString &path) */ void DownloadItem::updateProgress() { - if(m_kGetPath.isEmpty()) + if (m_kGetPath.isEmpty()) return; QDBusInterface kgetTransfer(QL1S("org.kde.kget"), m_kGetPath, QL1S("org.kde.kget.transfer")); - if(!kgetTransfer.isValid()) + if (!kgetTransfer.isValid()) return; // Fetch percent from DBus QDBusMessage percentRes = kgetTransfer.call(QL1S("percent")); - if(percentRes.arguments().isEmpty()) + if (percentRes.arguments().isEmpty()) return; bool ok = false; const int percent = percentRes.arguments().first().toInt(&ok); - if(!ok) + if (!ok) return; // Fetch status from DBus QDBusMessage statusRes = kgetTransfer.call(QL1S("status")); - if(statusRes.arguments().isEmpty()) + if (statusRes.arguments().isEmpty()) return; ok = false; const int status = statusRes.arguments().first().toInt(&ok); - if(!ok) + if (!ok) return; emit downloadProgress(percent); // TODO: expose resume if stopped // special case for status 2 will come later when we have a way to support resume. - if(percent == 100 || status == 4 || status == 2) + if (percent == 100 || status == 4 || status == 2) { emit downloadFinished(true); QTimer *timer = qobject_cast<QTimer *>(sender()); - if(timer) + if (timer) timer->stop(); } } @@ -153,10 +153,10 @@ void DownloadItem::updateProgress() void DownloadItem::abort() const { - if(!m_kGetPath.isEmpty()) + if (!m_kGetPath.isEmpty()) { QDBusInterface kgetTransfer(QL1S("org.kde.kget"), m_kGetPath, QL1S("org.kde.kget.transfer")); - if(kgetTransfer.isValid()) + if (kgetTransfer.isValid()) kgetTransfer.call(QL1S("stop")); } else diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 25018a7d..490637bf 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -51,14 +51,14 @@ void DownloadManager::init() { QString downloadFilePath = KStandardDirs::locateLocal("appdata" , "downloads"); QFile downloadFile(downloadFilePath); - if(!downloadFile.open(QFile::ReadOnly)) + if (!downloadFile.open(QFile::ReadOnly)) { kDebug() << "Unable to open download file (READ mode).."; return; } QDataStream in(&downloadFile); - while(!in.atEnd()) + while (!in.atEnd()) { QString srcUrl; in >> srcUrl; @@ -75,11 +75,11 @@ void DownloadManager::init() DownloadItem* DownloadManager::addDownload(const QString &srcUrl, const QString &destUrl) { QWebSettings *globalSettings = QWebSettings::globalSettings(); - if(globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) + if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) return 0; QString downloadFilePath = KStandardDirs::locateLocal("appdata" , "downloads"); QFile downloadFile(downloadFilePath); - if(!downloadFile.open(QFile::WriteOnly | QFile::Append)) + if (!downloadFile.open(QFile::WriteOnly | QFile::Append)) { kDebug() << "Unable to open download file (WRITE mode).."; return 0; diff --git a/src/filterurljob.cpp b/src/filterurljob.cpp index e6fde179..ff017a07 100644 --- a/src/filterurljob.cpp +++ b/src/filterurljob.cpp @@ -39,7 +39,7 @@ FilterUrlJob::FilterUrlJob(WebView *view, const QString &urlString, QObject *par , _view(view) , _urlString(urlString) { - if(!s_uriFilter) + if (!s_uriFilter) s_uriFilter = KUriFilter::self(); } @@ -59,7 +59,7 @@ KUrl FilterUrlJob::url() void FilterUrlJob::run() { // Bookmarklets handling - if(_urlString.startsWith(QL1S("javascript:"))) + if (_urlString.startsWith(QL1S("javascript:"))) { _url = KUrl(_urlString); return; @@ -70,7 +70,7 @@ void FilterUrlJob::run() KUriFilterData data(_urlString); data.setCheckForExecutables(false); // if true, queries like "rekonq" or "dolphin" are considered as executables - if(s_uriFilter->filterUri(data) && data.uriType() != KUriFilterData::Error) + if (s_uriFilter->filterUri(data) && data.uriType() != KUriFilterData::Error) { QString tempUrlString = data.uri().url(); _url = KUrl(tempUrlString); diff --git a/src/findbar.cpp b/src/findbar.cpp index ae10de3a..26ec37a3 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -119,9 +119,9 @@ FindBar::FindBar(MainWindow *window) void FindBar::keyPressEvent(QKeyEvent *event) { - if(event->key() == Qt::Key_Return) + if (event->key() == Qt::Key_Return) { - if(event->modifiers() == Qt::ShiftModifier) + if (event->modifiers() == Qt::ShiftModifier) { m_mainWindow->findPrevious(); } @@ -148,7 +148,7 @@ bool FindBar::highlightAllState() const void FindBar::setVisible(bool visible) { - if(visible && m_mainWindow->currentTab()->page()->isOnRekonqPage() && m_mainWindow->currentTab()->part() != 0) + if (visible && m_mainWindow->currentTab()->page()->isOnRekonqPage() && m_mainWindow->currentTab()->part() != 0) { // findNext is the slot containing part integration code m_mainWindow->findNext(); @@ -157,20 +157,20 @@ void FindBar::setVisible(bool visible) QWidget::setVisible(visible); - if(visible) + if (visible) { const QString selectedText = m_mainWindow->selectedText(); - if(!hasFocus() && !selectedText.isEmpty()) + if (!hasFocus() && !selectedText.isEmpty()) { const QString previousText = m_lineEdit->text(); m_lineEdit->setText(selectedText); - if(m_lineEdit->text() != previousText) + if (m_lineEdit->text() != previousText) m_mainWindow->findPrevious(); else m_mainWindow->updateHighlight();; } - else if(selectedText.isEmpty()) + else if (selectedText.isEmpty()) { emit searchString(m_lineEdit->text()); } @@ -192,13 +192,13 @@ void FindBar::notifyMatch(bool match) QPalette p = m_lineEdit->palette(); KColorScheme colorScheme(p.currentColorGroup()); - if(m_lineEdit->text().isEmpty()) + if (m_lineEdit->text().isEmpty()) { p.setColor(QPalette::Base, colorScheme.background(KColorScheme::NormalBackground).color()); } else { - if(match) + if (match) { p.setColor(QPalette::Base, colorScheme.background(KColorScheme::PositiveBackground).color()); } diff --git a/src/history/autosaver.cpp b/src/history/autosaver.cpp index c490ac46..bb2a7683 100644 --- a/src/history/autosaver.cpp +++ b/src/history/autosaver.cpp @@ -50,7 +50,7 @@ AutoSaver::AutoSaver(QObject *parent) AutoSaver::~AutoSaver() { - if(m_timer->isActive()) + if (m_timer->isActive()) kDebug() << "AutoSaver: still active when destroyed, changes not saved."; delete m_firstChange; @@ -60,17 +60,17 @@ AutoSaver::~AutoSaver() void AutoSaver::saveIfNeccessary() { - if(m_timer->isActive()) + if (m_timer->isActive()) save(); } void AutoSaver::changeOccurred() { - if(m_firstChange->isNull()) + if (m_firstChange->isNull()) m_firstChange->start(); - if(m_firstChange->elapsed() > MAX_TIME_LIMIT) + if (m_firstChange->elapsed() > MAX_TIME_LIMIT) save(); else m_timer->start(AUTOSAVE_TIME, this); @@ -79,7 +79,7 @@ void AutoSaver::changeOccurred() void AutoSaver::timerEvent(QTimerEvent *event) { - if(event->timerId() == m_timer->timerId()) + if (event->timerId() == m_timer->timerId()) save(); else QObject::timerEvent(event); diff --git a/src/history/historymanager.cpp b/src/history/historymanager.cpp index 3b765e7d..0a29950e 100644 --- a/src/history/historymanager.cpp +++ b/src/history/historymanager.cpp @@ -98,13 +98,13 @@ bool HistoryManager::historyContains(const QString &url) const void HistoryManager::addHistoryEntry(const QString &url) { QWebSettings *globalSettings = QWebSettings::globalSettings(); - if(globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) + if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) return; QUrl cleanUrl(url); // don't store about: urls (home page related) - if(cleanUrl.scheme() == QString("about")) + if (cleanUrl.scheme() == QString("about")) return; cleanUrl.setPassword(QString()); @@ -116,7 +116,7 @@ void HistoryManager::addHistoryEntry(const QString &url) // NOTE // check if the url has just been visited. // if so, remove previous entry from history, update and prepend it - if(historyContains(checkUrlString)) + if (historyContains(checkUrlString)) { int index = m_historyFilterModel->historyLocation(checkUrlString); item = m_history.at(index); @@ -134,7 +134,7 @@ void HistoryManager::addHistoryEntry(const QString &url) m_history.prepend(item); emit entryAdded(item); - if(m_history.count() == 1) + if (m_history.count() == 1) checkForExpired(); } @@ -144,12 +144,12 @@ void HistoryManager::setHistory(const QList<HistoryItem> &history, bool loadedAn m_history = history; // verify that it is sorted by date - if(!loadedAndSorted) + if (!loadedAndSorted) qSort(m_history.begin(), m_history.end()); checkForExpired(); - if(loadedAndSorted) + if (loadedAndSorted) { m_lastSavedUrl = m_history.value(0).url; } @@ -164,17 +164,17 @@ void HistoryManager::setHistory(const QList<HistoryItem> &history, bool loadedAn void HistoryManager::checkForExpired() { - if(m_historyLimit < 0 || m_history.isEmpty()) + if (m_historyLimit < 0 || m_history.isEmpty()) return; QDateTime now = QDateTime::currentDateTime(); int nextTimeout = 0; - while(!m_history.isEmpty()) + while (!m_history.isEmpty()) { QDateTime checkForExpired = m_history.last().lastDateTimeVisit; checkForExpired.setDate(checkForExpired.date().addDays(m_historyLimit)); - if(now.daysTo(checkForExpired) > 7) + if (now.daysTo(checkForExpired) > 7) { // check at most in a week to prevent int overflows on the timer nextTimeout = 7 * 86400; @@ -183,7 +183,7 @@ void HistoryManager::checkForExpired() { nextTimeout = now.secsTo(checkForExpired); } - if(nextTimeout > 0) + if (nextTimeout > 0) break; HistoryItem item = m_history.takeLast(); // remove from saved file also @@ -191,7 +191,7 @@ void HistoryManager::checkForExpired() emit entryRemoved(item); } - if(nextTimeout > 0) + if (nextTimeout > 0) QTimer::singleShot(nextTimeout * 1000, this, SLOT(checkForExpired())); } @@ -200,22 +200,22 @@ void HistoryManager::updateHistoryEntry(const KUrl &url, const QString &title) { QString urlString = url.url(); urlString.remove(QL1S("www.")); - if(urlString.startsWith(QL1S("http")) && urlString.endsWith(QL1C('/'))) + if (urlString.startsWith(QL1S("http")) && urlString.endsWith(QL1C('/'))) urlString.remove(urlString.length() - 1, 1); - for(int i = 0; i < m_history.count(); ++i) + for (int i = 0; i < m_history.count(); ++i) { QString itemUrl = m_history.at(i).url; itemUrl.remove(QL1S("www.")); - if(itemUrl.startsWith(QL1S("http")) && itemUrl.endsWith(QL1C('/'))) + if (itemUrl.startsWith(QL1S("http")) && itemUrl.endsWith(QL1C('/'))) itemUrl.remove(itemUrl.length() - 1, 1); - if(urlString == itemUrl) + if (urlString == itemUrl) { m_history[i].title = title; m_history[i].url = url.url(); m_saveTimer->changeOccurred(); - if(m_lastSavedUrl.isEmpty()) + if (m_lastSavedUrl.isEmpty()) m_lastSavedUrl = m_history.at(i).url; emit entryUpdated(i); @@ -228,9 +228,9 @@ void HistoryManager::updateHistoryEntry(const KUrl &url, const QString &title) void HistoryManager::removeHistoryEntry(const KUrl &url, const QString &title) { HistoryItem item; - for(int i = 0; i < m_history.count(); ++i) + for (int i = 0; i < m_history.count(); ++i) { - if(url == m_history.at(i).url + if (url == m_history.at(i).url && (title.isEmpty() || title == m_history.at(i).title)) { item = m_history.at(i); @@ -257,14 +257,14 @@ QList<HistoryItem> HistoryManager::find(const QString &text) bool matches = true; foreach(const QString & word, words) { - if(!url.contains(word, Qt::CaseInsensitive) + if (!url.contains(word, Qt::CaseInsensitive) && !item.title.contains(word, Qt::CaseInsensitive)) { matches = false; break; } } - if(matches) + if (matches) list << item; } @@ -286,7 +286,7 @@ void HistoryManager::loadSettings() { int historyExpire = ReKonfig::expireHistory(); int days; - switch(historyExpire) + switch (historyExpire) { case 0: days = 1; @@ -320,9 +320,9 @@ void HistoryManager::load() QString historyFilePath = KStandardDirs::locateLocal("appdata" , "history"); QFile historyFile(historyFilePath); - if(!historyFile.exists()) + if (!historyFile.exists()) return; - if(!historyFile.open(QFile::ReadOnly)) + if (!historyFile.open(QFile::ReadOnly)) { kDebug() << "Unable to open history file" << historyFile.fileName(); return; @@ -337,7 +337,7 @@ void HistoryManager::load() QDataStream stream; QBuffer buffer; stream.setDevice(&buffer); - while(!historyFile.atEnd()) + while (!historyFile.atEnd()) { in >> data; buffer.close(); @@ -348,7 +348,7 @@ void HistoryManager::load() HistoryItem item; - switch(version) + switch (version) { case HISTORY_VERSION: // default case stream >> item.url; @@ -378,29 +378,29 @@ void HistoryManager::load() continue; }; - if(!item.lastDateTimeVisit.isValid()) + if (!item.lastDateTimeVisit.isValid()) continue; - if(item == lastInsertedItem) + if (item == lastInsertedItem) { - if(lastInsertedItem.title.isEmpty() && !list.isEmpty()) + if (lastInsertedItem.title.isEmpty() && !list.isEmpty()) list[0].title = item.title; continue; } - if(!needToSort && !list.isEmpty() && lastInsertedItem < item) + if (!needToSort && !list.isEmpty() && lastInsertedItem < item) needToSort = true; list.prepend(item); lastInsertedItem = item; } - if(needToSort) + if (needToSort) qSort(list.begin(), list.end()); setHistory(list, true); // If we had to sort re-write the whole history sorted - if(needToSort) + if (needToSort) { m_lastSavedUrl.clear(); m_saveTimer->changeOccurred(); @@ -412,19 +412,19 @@ void HistoryManager::save() { bool saveAll = m_lastSavedUrl.isEmpty(); int first = m_history.count() - 1; - if(!saveAll) + if (!saveAll) { // find the first one to save - for(int i = 0; i < m_history.count(); ++i) + for (int i = 0; i < m_history.count(); ++i) { - if(m_history.at(i).url == m_lastSavedUrl) + if (m_history.at(i).url == m_lastSavedUrl) { first = i - 1; break; } } } - if(first == m_history.count() - 1) + if (first == m_history.count() - 1) saveAll = true; QString historyFilePath = KStandardDirs::locateLocal("appdata" , "history"); @@ -434,7 +434,7 @@ void HistoryManager::save() QTemporaryFile tempFile; tempFile.setAutoRemove(false); bool open = false; - if(saveAll) + if (saveAll) { open = tempFile.open(); } @@ -443,7 +443,7 @@ void HistoryManager::save() open = historyFile.open(QFile::Append); } - if(!open) + if (!open) { kDebug() << "Unable to open history file for saving" << (saveAll ? tempFile.fileName() : historyFile.fileName()); @@ -451,7 +451,7 @@ void HistoryManager::save() } QDataStream out(saveAll ? &tempFile : &historyFile); - for(int i = first; i >= 0; --i) + for (int i = first; i >= 0; --i) { QByteArray data; QDataStream stream(&data, QIODevice::WriteOnly); @@ -461,13 +461,13 @@ void HistoryManager::save() } tempFile.close(); - if(saveAll) + if (saveAll) { - if(historyFile.exists() && !historyFile.remove()) + if (historyFile.exists() && !historyFile.remove()) { kDebug() << "History: error removing old history." << historyFile.errorString(); } - if(!tempFile.rename(historyFile.fileName())) + if (!tempFile.rename(historyFile.fileName())) { kDebug() << "History: error moving new history over old." << tempFile.errorString() << historyFile.fileName(); } diff --git a/src/history/historymodels.cpp b/src/history/historymodels.cpp index bddc34be..ed5eee20 100644 --- a/src/history/historymodels.cpp +++ b/src/history/historymodels.cpp @@ -92,10 +92,10 @@ void HistoryModel::entryUpdated(int offset) QVariant HistoryModel::headerData(int section, Qt::Orientation orientation, int role) const { - if(orientation == Qt::Horizontal + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { - switch(section) + switch (section) { case 0: return i18n("Title"); case 1: return i18n("Address"); @@ -108,11 +108,11 @@ QVariant HistoryModel::headerData(int section, Qt::Orientation orientation, int QVariant HistoryModel::data(const QModelIndex &index, int role) const { QList<HistoryItem> lst = m_historyManager->history(); - if(index.row() < 0 || index.row() >= lst.size()) + if (index.row() < 0 || index.row() >= lst.size()) return QVariant(); const HistoryItem &item = lst.at(index.row()); - switch(role) + switch (role) { case DateTimeRole: return item.lastDateTimeVisit; @@ -129,14 +129,14 @@ QVariant HistoryModel::data(const QModelIndex &index, int role) const case Qt::DisplayRole: case Qt::EditRole: { - switch(index.column()) + switch (index.column()) { case 0: // when there is no title try to generate one from the url - if(item.title.isEmpty()) + if (item.title.isEmpty()) { QString page = QFileInfo(QUrl(item.url).path()).fileName(); - if(!page.isEmpty()) + if (!page.isEmpty()) return page; return item.url; } @@ -146,13 +146,13 @@ QVariant HistoryModel::data(const QModelIndex &index, int role) const } } case Qt::DecorationRole: - if(index.column() == 0) + if (index.column() == 0) { return rApp->iconManager()->iconForUrl(item.url); } case Qt::ToolTipRole: QString tooltip = ""; - if(!item.title.isEmpty()) + if (!item.title.isEmpty()) tooltip = item.title + '\n'; tooltip += item.lastDateTimeVisit.toString(Qt::SystemLocaleShortDate) + '\n' + item.url; return tooltip; @@ -175,12 +175,12 @@ int HistoryModel::rowCount(const QModelIndex &parent) const bool HistoryModel::removeRows(int row, int count, const QModelIndex &parent) { - if(parent.isValid()) + if (parent.isValid()) return false; int lastRow = row + count - 1; beginRemoveRows(parent, row, lastRow); QList<HistoryItem> lst = m_historyManager->history(); - for(int i = lastRow; i >= row; --i) + for (int i = lastRow; i >= row; --i) lst.removeAt(i); disconnect(m_historyManager, SIGNAL(historyReset()), this, SLOT(historyReset())); m_historyManager->setHistory(lst); @@ -204,7 +204,7 @@ HistoryFilterModel::HistoryFilterModel(QAbstractItemModel *sourceModel, QObject int HistoryFilterModel::historyLocation(const QString &url) const { load(); - if(!m_historyHash.contains(url)) + if (!m_historyHash.contains(url)) return 0; return sourceModel()->rowCount() - m_historyHash.value(url); } @@ -218,7 +218,7 @@ QVariant HistoryFilterModel::data(const QModelIndex &index, int role) const void HistoryFilterModel::setSourceModel(QAbstractItemModel *newSourceModel) { - if(sourceModel()) + if (sourceModel()) { disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); disconnect(sourceModel(), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), @@ -231,7 +231,7 @@ void HistoryFilterModel::setSourceModel(QAbstractItemModel *newSourceModel) QAbstractProxyModel::setSourceModel(newSourceModel); - if(sourceModel()) + if (sourceModel()) { m_loaded = false; connect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); @@ -267,7 +267,7 @@ void HistoryFilterModel::sourceReset() int HistoryFilterModel::rowCount(const QModelIndex &parent) const { load(); - if(parent.isValid()) + if (parent.isValid()) return 0; return m_historyHash.count(); } @@ -291,7 +291,7 @@ QModelIndex HistoryFilterModel::mapFromSource(const QModelIndex &sourceIndex) co { load(); QString url = sourceIndex.data(HistoryModel::UrlStringRole).toString(); - if(!m_historyHash.contains(url)) + if (!m_historyHash.contains(url)) return QModelIndex(); // This can be done in a binary search, but we can't use qBinary find @@ -301,15 +301,15 @@ QModelIndex HistoryFilterModel::mapFromSource(const QModelIndex &sourceIndex) co int realRow = -1; int sourceModelRow = sourceModel()->rowCount() - sourceIndex.row(); - for(int i = 0; i < m_sourceRow.count(); ++i) + for (int i = 0; i < m_sourceRow.count(); ++i) { - if(m_sourceRow.at(i) == sourceModelRow) + if (m_sourceRow.at(i) == sourceModelRow) { realRow = i; break; } } - if(realRow == -1) + if (realRow == -1) return QModelIndex(); return createIndex(realRow, sourceIndex.column(), sourceModel()->rowCount() - sourceIndex.row()); @@ -319,7 +319,7 @@ QModelIndex HistoryFilterModel::mapFromSource(const QModelIndex &sourceIndex) co QModelIndex HistoryFilterModel::index(int row, int column, const QModelIndex &parent) const { load(); - if(row < 0 || row >= rowCount(parent) + if (row < 0 || row >= rowCount(parent) || column < 0 || column >= columnCount(parent)) return QModelIndex(); @@ -335,16 +335,16 @@ QModelIndex HistoryFilterModel::parent(const QModelIndex &) const void HistoryFilterModel::load() const { - if(m_loaded) + if (m_loaded) return; m_sourceRow.clear(); m_historyHash.clear(); m_historyHash.reserve(sourceModel()->rowCount()); - for(int i = 0; i < sourceModel()->rowCount(); ++i) + for (int i = 0; i < sourceModel()->rowCount(); ++i) { QModelIndex idx = sourceModel()->index(i, 0); QString url = idx.data(HistoryModel::UrlStringRole).toString(); - if(!m_historyHash.contains(url)) + if (!m_historyHash.contains(url)) { m_sourceRow.append(sourceModel()->rowCount() - i); m_historyHash[url] = sourceModel()->rowCount() - i; @@ -358,18 +358,18 @@ void HistoryFilterModel::sourceRowsInserted(const QModelIndex &parent, int start { Q_UNUSED(end); - if(start != 0) + if (start != 0) { kDebug() << "STARTING from a NON zero position..."; return; } - if(!m_loaded) + if (!m_loaded) return; QModelIndex idx = sourceModel()->index(start, 0, parent); QString url = idx.data(HistoryModel::UrlStringRole).toString(); - if(m_historyHash.contains(url)) + if (m_historyHash.contains(url)) { int sourceRow = sourceModel()->rowCount() - m_historyHash[url]; int realRow = mapFromSource(sourceModel()->index(sourceRow, 0)).row(); @@ -399,7 +399,7 @@ void HistoryFilterModel::sourceRowsRemoved(const QModelIndex &, int start, int e */ bool HistoryFilterModel::removeRows(int row, int count, const QModelIndex &parent) { - if(row < 0 || count <= 0 || row + count > rowCount(parent) || parent.isValid()) + if (row < 0 || count <= 0 || row + count > rowCount(parent) || parent.isValid()) return false; int lastRow = row + count - 1; disconnect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), @@ -413,7 +413,7 @@ bool HistoryFilterModel::removeRows(int row, int count, const QModelIndex &paren connect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); m_loaded = false; - if(oldCount - count != rowCount()) + if (oldCount - count != rowCount()) reset(); return true; } @@ -437,38 +437,38 @@ QVariant HistoryTreeModel::headerData(int section, Qt::Orientation orientation, QVariant HistoryTreeModel::data(const QModelIndex &index, int role) const { - if(role == Qt::EditRole || role == Qt::DisplayRole) + if (role == Qt::EditRole || role == Qt::DisplayRole) { int start = index.internalId(); - if(start == 0) + if (start == 0) { int offset = sourceDateRow(index.row()); - if(index.column() == 0) + if (index.column() == 0) { QModelIndex idx = sourceModel()->index(offset, 0); QDate date = idx.data(HistoryModel::DateRole).toDate(); - if(date == QDate::currentDate()) + if (date == QDate::currentDate()) return i18n("Earlier Today"); return date.toString(QL1S("dddd, MMMM d, yyyy")); } - if(index.column() == 1) + if (index.column() == 1) { return i18np("1 item", "%1 items", rowCount(index.sibling(index.row(), 0))); } } } - if(role == Qt::DecorationRole && index.column() == 0 && !index.parent().isValid()) + if (role == Qt::DecorationRole && index.column() == 0 && !index.parent().isValid()) return KIcon("view-history"); - if(role == HistoryModel::DateRole && index.column() == 0 && index.internalId() == 0) + if (role == HistoryModel::DateRole && index.column() == 0 && index.internalId() == 0) { int offset = sourceDateRow(index.row()); QModelIndex idx = sourceModel()->index(offset, 0); return idx.data(HistoryModel::DateRole); } - if(role == HistoryModel::FirstDateTimeVisitRole && index.column() == 0 && index.internalId() == 0) + if (role == HistoryModel::FirstDateTimeVisitRole && index.column() == 0 && index.internalId() == 0) { int offset = sourceDateRow(index.row()); QModelIndex idx = sourceModel()->index(offset, 0); @@ -487,24 +487,24 @@ int HistoryTreeModel::columnCount(const QModelIndex &parent) const int HistoryTreeModel::rowCount(const QModelIndex &parent) const { - if(parent.internalId() != 0 + if (parent.internalId() != 0 || parent.column() > 0 || !sourceModel()) return 0; // row count OF dates - if(!parent.isValid()) + if (!parent.isValid()) { - if(!m_sourceRowCache.isEmpty()) + if (!m_sourceRowCache.isEmpty()) return m_sourceRowCache.count(); QDate currentDate; int rows = 0; int totalRows = sourceModel()->rowCount(); - for(int i = 0; i < totalRows; ++i) + for (int i = 0; i < totalRows; ++i) { QDate rowDate = sourceModel()->index(i, 0).data(HistoryModel::DateRole).toDate(); - if(rowDate != currentDate) + if (rowDate != currentDate) { m_sourceRowCache.append(i); currentDate = rowDate; @@ -525,15 +525,15 @@ int HistoryTreeModel::rowCount(const QModelIndex &parent) const // Translate the top level date row into the offset where that date starts int HistoryTreeModel::sourceDateRow(int row) const { - if(row <= 0) + if (row <= 0) return 0; - if(m_sourceRowCache.isEmpty()) + if (m_sourceRowCache.isEmpty()) rowCount(QModelIndex()); - if(row >= m_sourceRowCache.count()) + if (row >= m_sourceRowCache.count()) { - if(!sourceModel()) + if (!sourceModel()) return 0; return sourceModel()->rowCount(); } @@ -544,7 +544,7 @@ int HistoryTreeModel::sourceDateRow(int row) const QModelIndex HistoryTreeModel::mapToSource(const QModelIndex &proxyIndex) const { int offset = proxyIndex.internalId(); - if(offset == 0) + if (offset == 0) return QModelIndex(); int startDateRow = sourceDateRow(offset - 1); return sourceModel()->index(startDateRow + proxyIndex.row(), proxyIndex.column()); @@ -553,12 +553,12 @@ QModelIndex HistoryTreeModel::mapToSource(const QModelIndex &proxyIndex) const QModelIndex HistoryTreeModel::index(int row, int column, const QModelIndex &parent) const { - if(row < 0 + if (row < 0 || column < 0 || column >= columnCount(parent) || parent.column() > 0) return QModelIndex(); - if(!parent.isValid()) + if (!parent.isValid()) return createIndex(row, column, 0); return createIndex(row, column, parent.row() + 1); } @@ -567,7 +567,7 @@ QModelIndex HistoryTreeModel::index(int row, int column, const QModelIndex &pare QModelIndex HistoryTreeModel::parent(const QModelIndex &index) const { int offset = index.internalId(); - if(offset == 0 || !index.isValid()) + if (offset == 0 || !index.isValid()) return QModelIndex(); return createIndex(offset - 1, 0, 0); } @@ -576,7 +576,7 @@ QModelIndex HistoryTreeModel::parent(const QModelIndex &index) const bool HistoryTreeModel::hasChildren(const QModelIndex &parent) const { QModelIndex grandparent = parent.parent(); - if(!grandparent.isValid()) + if (!grandparent.isValid()) return true; return false; } @@ -584,7 +584,7 @@ bool HistoryTreeModel::hasChildren(const QModelIndex &parent) const Qt::ItemFlags HistoryTreeModel::flags(const QModelIndex &index) const { - if(!index.isValid()) + if (!index.isValid()) return Qt::NoItemFlags; return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled; } @@ -592,10 +592,10 @@ Qt::ItemFlags HistoryTreeModel::flags(const QModelIndex &index) const bool HistoryTreeModel::removeRows(int row, int count, const QModelIndex &parent) { - if(row < 0 || count <= 0 || row + count > rowCount(parent)) + if (row < 0 || count <= 0 || row + count > rowCount(parent)) return false; - if(parent.isValid()) + if (parent.isValid()) { // removing pages int offset = sourceDateRow(parent.row()); @@ -604,11 +604,11 @@ bool HistoryTreeModel::removeRows(int row, int count, const QModelIndex &parent) else { // removing whole dates - for(int i = row + count - 1; i >= row; --i) + for (int i = row + count - 1; i >= row; --i) { QModelIndex dateParent = index(i, 0); int offset = sourceDateRow(dateParent.row()); - if(!sourceModel()->removeRows(offset, rowCount(dateParent))) + if (!sourceModel()->removeRows(offset, rowCount(dateParent))) return false; } } @@ -618,7 +618,7 @@ bool HistoryTreeModel::removeRows(int row, int count, const QModelIndex &parent) void HistoryTreeModel::setSourceModel(QAbstractItemModel *newSourceModel) { - if(sourceModel()) + if (sourceModel()) { disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); disconnect(sourceModel(), SIGNAL(layoutChanged()), this, SLOT(sourceReset())); @@ -630,7 +630,7 @@ void HistoryTreeModel::setSourceModel(QAbstractItemModel *newSourceModel) QAbstractProxyModel::setSourceModel(newSourceModel); - if(newSourceModel) + if (newSourceModel) { connect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); connect(sourceModel(), SIGNAL(layoutChanged()), this, SLOT(sourceReset())); @@ -655,7 +655,7 @@ void HistoryTreeModel::sourceRowsInserted(const QModelIndex &parent, int start, { Q_UNUSED(parent); // Avoid warnings when compiling release Q_ASSERT(!parent.isValid()); - if(start != 0 || start != end) + if (start != 0 || start != end) { m_sourceRowCache.clear(); reset(); @@ -665,7 +665,7 @@ void HistoryTreeModel::sourceRowsInserted(const QModelIndex &parent, int start, m_sourceRowCache.clear(); QModelIndex treeIndex = mapFromSource(sourceModel()->index(start, 0)); QModelIndex treeParent = treeIndex.parent(); - if(rowCount(treeParent) == 1) + if (rowCount(treeParent) == 1) { beginInsertRows(QModelIndex(), 0, 0); endInsertRows(); @@ -680,15 +680,15 @@ void HistoryTreeModel::sourceRowsInserted(const QModelIndex &parent, int start, QModelIndex HistoryTreeModel::mapFromSource(const QModelIndex &sourceIndex) const { - if(!sourceIndex.isValid()) + if (!sourceIndex.isValid()) return QModelIndex(); - if(m_sourceRowCache.isEmpty()) + if (m_sourceRowCache.isEmpty()) rowCount(QModelIndex()); QList<int>::iterator it; it = qLowerBound(m_sourceRowCache.begin(), m_sourceRowCache.end(), sourceIndex.row()); - if(*it != sourceIndex.row()) + if (*it != sourceIndex.row()) --it; int dateRow = qMax(0, it - m_sourceRowCache.begin()); @@ -701,28 +701,28 @@ void HistoryTreeModel::sourceRowsRemoved(const QModelIndex &parent, int start, i { Q_UNUSED(parent); // Avoid warnings when compiling release Q_ASSERT(!parent.isValid()); - if(m_sourceRowCache.isEmpty()) + if (m_sourceRowCache.isEmpty()) return; - for(int i = end; i >= start;) + for (int i = end; i >= start;) { QList<int>::iterator it; it = qLowerBound(m_sourceRowCache.begin(), m_sourceRowCache.end(), i); // playing it safe - if(it == m_sourceRowCache.end()) + if (it == m_sourceRowCache.end()) { m_sourceRowCache.clear(); reset(); return; } - if(*it != i) + if (*it != i) --it; int row = qMax(0, it - m_sourceRowCache.begin()); int offset = m_sourceRowCache[row]; QModelIndex dateParent = index(row, 0); // If we can remove all the rows in the date do that and skip over them int rc = rowCount(dateParent); - if(i - rc + 1 == offset && start <= i - rc + 1) + if (i - rc + 1 == offset && start <= i - rc + 1) { beginRemoveRows(QModelIndex(), row, row); m_sourceRowCache.removeAt(row); @@ -734,7 +734,7 @@ void HistoryTreeModel::sourceRowsRemoved(const QModelIndex &parent, int start, i ++row; --i; } - for(int j = row; j < m_sourceRowCache.count(); ++j) + for (int j = row; j < m_sourceRowCache.count(); ++j) --m_sourceRowCache[j]; endRemoveRows(); } diff --git a/src/history/historypanel.cpp b/src/history/historypanel.cpp index e792783c..8ba963e7 100644 --- a/src/history/historypanel.cpp +++ b/src/history/historypanel.cpp @@ -108,26 +108,26 @@ void HistoryPanel::contextMenuEmpty(const QPoint& /*pos*/) void HistoryPanel::openAll() { QModelIndex index = panelTreeView()->currentIndex(); - if(!index.isValid()) + if (!index.isValid()) return; QList<KUrl> allChild; - for(int i = 0; i < index.model()->rowCount(index); i++) + for (int i = 0; i < index.model()->rowCount(index); i++) allChild << qVariantValue<KUrl>(index.child(i, 0).data(Qt::UserRole)); - if(allChild.length() > 8) + if (allChild.length() > 8) { - if(!(KMessageBox::warningContinueCancel(this, - i18ncp("%1=Number of tabs. Value is always >=8", - "You are about to open %1 tabs.\nAre you sure?", - "You are about to open %1 tabs.\nAre you sure?", - allChild.length())) == KMessageBox::Continue) - ) + if (!(KMessageBox::warningContinueCancel(this, + i18ncp("%1=Number of tabs. Value is always >=8", + "You are about to open %1 tabs.\nAre you sure?", + "You are about to open %1 tabs.\nAre you sure?", + allChild.length())) == KMessageBox::Continue) + ) return; } - for(int i = 0; i < allChild.length(); i++) + for (int i = 0; i < allChild.length(); i++) emit openUrl(allChild.at(i).url(), Rekonq::NewTab); } diff --git a/src/iconmanager.cpp b/src/iconmanager.cpp index a96962c7..3ca74b2c 100644 --- a/src/iconmanager.cpp +++ b/src/iconmanager.cpp @@ -58,32 +58,32 @@ IconManager::IconManager(QObject *parent) KIcon IconManager::iconForUrl(const KUrl &url) { // first things first.. avoid infinite loop at startup - if(url.isEmpty() || rApp->mainWindowList().isEmpty()) + if (url.isEmpty() || rApp->mainWindowList().isEmpty()) return KIcon("text-html"); QByteArray encodedUrl = url.toEncoded(); // rekonq icons.. - if(encodedUrl == QByteArray("about:home")) + if (encodedUrl == QByteArray("about:home")) return KIcon("go-home"); - if(encodedUrl == QByteArray("about:closedTabs")) + if (encodedUrl == QByteArray("about:closedTabs")) return KIcon("tab-close"); - if(encodedUrl == QByteArray("about:history")) + if (encodedUrl == QByteArray("about:history")) return KIcon("view-history"); - if(encodedUrl == QByteArray("about:bookmarks")) + if (encodedUrl == QByteArray("about:bookmarks")) return KIcon("bookmarks"); - if(encodedUrl == QByteArray("about:favorites")) + if (encodedUrl == QByteArray("about:favorites")) return KIcon("emblem-favorite"); - if(encodedUrl == QByteArray("about:downloads")) + if (encodedUrl == QByteArray("about:downloads")) return KIcon("download"); // TODO: return other mimetype icons - if(url.isLocalFile()) + if (url.isLocalFile()) { return KIcon("folder"); } QString i = KMimeType::favIconForUrl(url); - if(!i.isEmpty()) + if (!i.isEmpty()) { QString faviconDir = KStandardDirs::locateLocal("cache" , "" , true); return KIcon(faviconDir + i); @@ -97,25 +97,25 @@ KIcon IconManager::iconForUrl(const KUrl &url) void IconManager::provideIcon(QWebPage *page, const KUrl &url, bool notify) { // provide icons just for http/https sites - if(!url.scheme().startsWith(QL1S("http"))) + if (!url.scheme().startsWith(QL1S("http"))) { - if(notify) + if (notify) emit iconChanged(); return; } // do not load new icons in private browsing.. - if(QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) + if (QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) { - if(notify) + if (notify) emit iconChanged(); return; } // check if icon exists - if(!KMimeType::favIconForUrl(url).isEmpty()) + if (!KMimeType::favIconForUrl(url).isEmpty()) { - if(notify) + if (notify) emit iconChanged(); return; } @@ -129,13 +129,13 @@ void IconManager::provideIcon(QWebPage *page, const KUrl &url, bool notify) QWebElement root = page->mainFrame()->documentElement(); QWebElement e = root.findFirst(QL1S("link[rel~=\"icon\"]")); QString relUrlString = e.attribute(QL1S("href")); - if(relUrlString.isEmpty()) + if (relUrlString.isEmpty()) { e = root.findFirst(QL1S("link[rel~=\"shortcut icon\"]")); relUrlString = e.attribute(QL1S("href")); } - if(!relUrlString.isEmpty()) + if (!relUrlString.isEmpty()) { faviconUrl = relUrlString.startsWith(QL1S("http")) ? KUrl(relUrlString) @@ -147,7 +147,7 @@ void IconManager::provideIcon(QWebPage *page, const KUrl &url, bool notify) // download icon KIO::FileCopyJob *job = KIO::file_copy(faviconUrl, destUrl, -1, KIO::HideProgressInfo); - if(notify) + if (notify) connect(job, SIGNAL(result(KJob*)), this, SLOT(notifyLastStuffs(KJob *))); else connect(job, SIGNAL(result(KJob*)), this, SLOT(doLastStuffs(KJob *))); @@ -173,7 +173,7 @@ void IconManager::clearIconCache() void IconManager::doLastStuffs(KJob *j) { - if(j->error()) + if (j->error()) { kDebug() << "FAVICON JOB ERROR"; return; @@ -184,14 +184,14 @@ void IconManager::doLastStuffs(KJob *j) QString s = dest.url().remove(QL1S("file://")); QFile fav(s); - if(!fav.exists()) + if (!fav.exists()) { kDebug() << "FAVICON DOES NOT EXISTS"; fav.remove(); return; } - if(fav.size() == 0) + if (fav.size() == 0) { kDebug() << "SIZE ZERO FAVICON"; fav.remove(); @@ -199,13 +199,13 @@ void IconManager::doLastStuffs(KJob *j) } QPixmap px; - if(!px.load(s)) + if (!px.load(s)) { kDebug() << "PIXMAP NOT LOADED"; return; } - if(px.isNull()) + if (px.isNull()) { kDebug() << "PIXMAP IS NULL"; fav.remove(); @@ -213,7 +213,7 @@ void IconManager::doLastStuffs(KJob *j) } px = px.scaled(16, 16); - if(!px.save(s)) + if (!px.save(s)) { kDebug() << "PIXMAP NOT SAVED"; return; diff --git a/src/main.cpp b/src/main.cpp index bde1e2f5..422025aa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -199,7 +199,7 @@ extern "C" KDE_EXPORT int kdemain(int argc, char **argv) // Add options from Application class Application::addCmdLineOptions(); - if(!Application::start()) + if (!Application::start()) { kWarning() << "rekonq is already running!"; return 0; diff --git a/src/mainview.cpp b/src/mainview.cpp index 14b86704..ca5ae654 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -103,7 +103,7 @@ void MainView::postLaunch() QStringList list = rApp->sessionManager()->closedSites(); Q_FOREACH(const QString & line, list) { - if(line.startsWith(QL1S("about"))) + if (line.startsWith(QL1S("about"))) break; QString title = line; QString url = title; @@ -139,7 +139,7 @@ WebTab *MainView::currentWebTab() const { int i = currentIndex(); WebTab *b = webTab(i); - if(b) + if (b) return b; kDebug() << "We failed to find the current tab!!! Let's go sure with the first one..."; @@ -149,15 +149,15 @@ WebTab *MainView::currentWebTab() const void MainView::updateTabBar() { - if(ReKonfig::alwaysShowTabBar() || count() > 1) + if (ReKonfig::alwaysShowTabBar() || count() > 1) { - if(tabBar()->isHidden()) + if (tabBar()->isHidden()) { tabBar()->show(); } // this to ensure tab button visibility also on new window creation - if(m_addTabButton->isHidden()) + if (m_addTabButton->isHidden()) { m_addTabButton->show(); } @@ -176,16 +176,16 @@ void MainView::updateTabBar() int tabWidgetWidth = frameSize().width(); int tabBarWidth = tabBar()->tabSizeHint(0).width() * tabBar()->count(); - if(tabBarWidth + m_addTabButton->width() > tabWidgetWidth) + if (tabBarWidth + m_addTabButton->width() > tabWidgetWidth) { - if(ButtonInCorner) + if (ButtonInCorner) return; setCornerWidget(m_addTabButton); ButtonInCorner = true; } else { - if(ButtonInCorner) + if (ButtonInCorner) { setCornerWidget(0); ButtonInCorner = false; @@ -194,7 +194,7 @@ void MainView::updateTabBar() // detecting X position int newPosX = tabBarWidth; int tabWidthHint = tabBar()->tabSizeHint(0).width(); - if(tabWidthHint < sizeHint().width() / 4) + if (tabWidthHint < sizeHint().width() / 4) newPosX = tabWidgetWidth - m_addTabButton->width(); m_addTabButton->move(newPosX, 0); @@ -205,7 +205,7 @@ void MainView::updateTabBar() void MainView::webReload() { WebTab *webTab = currentWebTab(); - if(webTab->view()->url().scheme() != QL1S("about")) + if (webTab->view()->url().scheme() != QL1S("about")) { QAction *action = webTab->view()->page()->action(QWebPage::Reload); action->trigger(); @@ -228,9 +228,9 @@ void MainView::webStop() // When index is -1 index chooses the current tab void MainView::reloadTab(int index) { - if(index < 0) + if (index < 0) index = currentIndex(); - if(index < 0 || index >= count()) + if (index < 0 || index >= count()) return; webTab(index)->view()->reload(); @@ -242,7 +242,7 @@ void MainView::currentChanged(int index) { // retrieve the webview related to the index WebTab *tab = this->webTab(index); - if(!tab) + if (!tab) return; // retrieve the old webview (that where we move from) @@ -251,7 +251,7 @@ void MainView::currentChanged(int index) // set current index m_currentTabIndex = index; - if(oldTab) + if (oldTab) { // disconnecting webpage from mainview disconnect(oldTab->page(), SIGNAL(statusBarMessage(const QString&)), @@ -275,7 +275,7 @@ void MainView::currentChanged(int index) emit browserTabLoading(tab->isPageLoading()); // set focus to the current webview - if(tab->url().scheme() == QL1S("about")) + if (tab->url().scheme() == QL1S("about")) m_widgetBar->currentWidget()->setFocus(); else tab->view()->setFocus(); @@ -289,7 +289,7 @@ void MainView::currentChanged(int index) WebTab *MainView::webTab(int index) const { WebTab *tab = qobject_cast<WebTab *>(this->widget(index)); - if(tab) + if (tab) { return tab; } @@ -316,7 +316,7 @@ WebTab *MainView::newWebTab(bool focused) connect(tab->page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested())); connect(tab->page(), SIGNAL(printRequested(QWebFrame *)), this, SIGNAL(printRequested(QWebFrame *))); - if(ReKonfig::openTabsNearCurrent()) + if (ReKonfig::openTabsNearCurrent()) { insertTab(currentIndex() + 1, tab, i18n("(Untitled)")); temporaryUglyHackString = tabText(currentIndex() + 1); @@ -330,7 +330,7 @@ WebTab *MainView::newWebTab(bool focused) } updateTabBar(); - if(focused) + if (focused) { setCurrentWidget(tab); } @@ -351,7 +351,7 @@ void MainView::newTab() currentUrlBar()->setFocus(); - switch(ReKonfig::newTabsBehaviour()) + switch (ReKonfig::newTabsBehaviour()) { case 0: // new tab page w->load(KUrl("about:home")); @@ -370,7 +370,7 @@ void MainView::newTab() void MainView::reloadAllTabs() { - for(int i = 0; i < count(); ++i) + for (int i = 0; i < count(); ++i) { webTab(i)->view()->reload(); } @@ -383,9 +383,9 @@ void MainView::windowCloseRequested() WebView *view = qobject_cast<WebView *>(page->view()); int index = indexOf(view->parentWidget()); - if(index >= 0) + if (index >= 0) { - if(count() == 1) + if (count() == 1) { m_parentWindow->close(); } @@ -400,17 +400,17 @@ void MainView::windowCloseRequested() void MainView::closeOtherTabs(int index) { - if(index < 0) + if (index < 0) index = currentIndex(); - if(index < 0 || index >= count()) + if (index < 0 || index >= count()) return; - for(int i = count() - 1; i > index; --i) + for (int i = count() - 1; i > index; --i) { closeTab(i); } - for(int i = index - 1; i >= 0; --i) + for (int i = index - 1; i >= 0; --i) { closeTab(i); } @@ -421,9 +421,9 @@ void MainView::closeOtherTabs(int index) void MainView::cloneTab(int index) { - if(index < 0) + if (index < 0) index = currentIndex(); - if(index < 0 || index >= count()) + if (index < 0 || index >= count()) return; KUrl url = webTab(index)->url(); @@ -438,14 +438,14 @@ void MainView::cloneTab(int index) void MainView::closeTab(int index, bool del) { // open default homePage if just one tab is opened - if(count() == 1) + if (count() == 1) { WebView *w = currentWebTab()->view(); - if(currentWebTab()->url().protocol() == QL1S("about")) + if (currentWebTab()->url().protocol() == QL1S("about")) return; - switch(ReKonfig::newTabsBehaviour()) + switch (ReKonfig::newTabsBehaviour()) { case 0: // new tab page case 1: // blank page @@ -461,36 +461,36 @@ void MainView::closeTab(int index, bool del) return; } - if(index < 0) + if (index < 0) index = currentIndex(); - if(index < 0 || index >= count()) + if (index < 0 || index >= count()) return; WebTab *tabToClose = webTab(index); - if(!tabToClose) + if (!tabToClose) return; - if(tabToClose->view()->isModified()) + if (tabToClose->view()->isModified()) { int risp = KMessageBox::warningContinueCancel(this, i18n("This tab contains changes that have not been submitted.\n" "Closing the tab will discard these changes.\n" "Do you really want to close this tab?\n"), i18n("Closing Modified Tab"), KGuiItem(i18n("Close &Tab"), "tab-close"), KStandardGuiItem::cancel()); - if(risp != KMessageBox::Continue) + if (risp != KMessageBox::Continue) return; } - if(!tabToClose->url().isEmpty() + if (!tabToClose->url().isEmpty() && !QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled) - ) + ) { const int recentlyClosedTabsLimit = 10; QString title = tabToClose->view()->title(); QString url = tabToClose->url().prettyUrl(); HistoryItem item(url, QDateTime(), title); m_recentlyClosedTabs.removeAll(item); - if(m_recentlyClosedTabs.count() == recentlyClosedTabsLimit) + if (m_recentlyClosedTabs.count() == recentlyClosedTabsLimit) m_recentlyClosedTabs.removeLast(); m_recentlyClosedTabs.prepend(item); } @@ -501,13 +501,13 @@ void MainView::closeTab(int index, bool del) m_widgetBar->removeWidget(tabToClose->urlBar()); m_widgetBar->setCurrentIndex(m_currentTabIndex); - if(del) + if (del) { tabToClose->deleteLater(); } // if tab was not focused, current index does not change... - if(index != currentIndex()) + if (index != currentIndex()) emit tabsChanged(); } @@ -516,22 +516,22 @@ void MainView::webViewLoadStarted() { WebView *view = qobject_cast<WebView *>(sender()); int index = indexOf(view->parentWidget()); - if(-1 != index) + if (-1 != index) { QLabel *label = animatedLoading(index, true); - if(label->movie()) + if (label->movie()) { label->movie()->start(); } } - if(index != currentIndex()) + if (index != currentIndex()) return; emit browserTabLoading(true); emit showStatusBarMessage(i18n("Loading..."), Rekonq::Info); - if(view == currentWebTab()->view() && view->url().scheme() != QL1S("about")) + if (view == currentWebTab()->view() && view->url().scheme() != QL1S("about")) { view->setFocus(); } @@ -542,14 +542,14 @@ void MainView::webViewLoadFinished(bool ok) { WebView *view = qobject_cast<WebView *>(sender()); int index = -1; - if(view) + if (view) index = indexOf(view->parentWidget()); - if(-1 != index) + if (-1 != index) { QLabel *label = animatedLoading(index, true); QMovie *movie = label->movie(); - if(movie) + if (movie) movie->stop(); } @@ -557,12 +557,12 @@ void MainView::webViewLoadFinished(bool ok) emit browserTabLoading(false); // don't display messages for background tabs - if(index != currentIndex()) + if (index != currentIndex()) { return; } - if(ok) + if (ok) emit showStatusBarMessage(i18n("Done"), Rekonq::Info); // else // emit showStatusBarMessage(i18n("Failed to load"), Rekonq::Error); @@ -575,7 +575,7 @@ void MainView::webViewIconChanged() WebTab *tab = qobject_cast<WebTab *>(view->parent()); int index = indexOf(tab); - if(-1 != index) + if (-1 != index) { KIcon icon = rApp->iconManager()->iconForUrl(tab->url()); QLabel *label = animatedLoading(index, false); @@ -595,21 +595,21 @@ void MainView::webViewTitleChanged(const QString &title) WebTab *tab = qobject_cast<WebTab *>(sender()); int index = indexOf(tab); - if(-1 != index) + if (-1 != index) { setTabText(index, tabTitle); } - if(currentIndex() == index) + if (currentIndex() == index) { emit currentTitle(viewTitle); } else { - if(tabTitle != temporaryUglyHackString) + if (tabTitle != temporaryUglyHackString) tabBar()->setTabHighlighted(index); } rApp->historyManager()->updateHistoryEntry(tab->url(), tabTitle); - if(ReKonfig::hoveringTabOption() == 1) + if (ReKonfig::hoveringTabOption() == 1) tabBar()->setTabToolTip(index, tabTitle.remove('&')); } @@ -618,11 +618,11 @@ void MainView::webViewUrlChanged(const QUrl &url) { WebView *view = qobject_cast<WebView *>(sender()); int index = indexOf(view->parentWidget()); - if(-1 != index) + if (-1 != index) { tabBar()->setTabData(index, url); } - if(ReKonfig::hoveringTabOption() == 2) + if (ReKonfig::hoveringTabOption() == 2) tabBar()->setTabToolTip(index, webTab(index)->url().toMimeDataString()); emit tabsChanged(); @@ -632,7 +632,7 @@ void MainView::webViewUrlChanged(const QUrl &url) void MainView::nextTab() { int next = currentIndex() + 1; - if(next == count()) + if (next == count()) next = 0; setCurrentIndex(next); } @@ -641,7 +641,7 @@ void MainView::nextTab() void MainView::previousTab() { int next = currentIndex() - 1; - if(next < 0) + if (next < 0) next = count() - 1; setCurrentIndex(next); } @@ -649,7 +649,7 @@ void MainView::previousTab() void MainView::openLastClosedTab() { - if(m_recentlyClosedTabs.isEmpty()) + if (m_recentlyClosedTabs.isEmpty()) return; const HistoryItem item = m_recentlyClosedTabs.takeFirst(); @@ -660,7 +660,7 @@ void MainView::openLastClosedTab() void MainView::openClosedTab() { KAction *action = qobject_cast<KAction *>(sender()); - if(action) + if (action) { rApp->loadUrl(action->data().toUrl(), Rekonq::NewTab); @@ -674,7 +674,7 @@ void MainView::openClosedTab() void MainView::switchToTab(const int index) { - if(index <= 0 || index > count()) + if (index <= 0 || index > count()) return; setCurrentIndex(index - 1); } @@ -683,7 +683,7 @@ void MainView::switchToTab(const int index) void MainView::loadFavorite(const int index) { QStringList urls = ReKonfig::previewUrls(); - if(index < 0 || index > urls.length()) + if (index < 0 || index > urls.length()) return; KUrl url = KUrl(urls.at(index - 1)); rApp->loadUrl(url); @@ -692,15 +692,15 @@ void MainView::loadFavorite(const int index) QLabel *MainView::animatedLoading(int index, bool addMovie) { - if(index == -1) + if (index == -1) return 0; QLabel *label = qobject_cast<QLabel* >(tabBar()->tabButton(index, QTabBar::LeftSide)); - if(!label) + if (!label) { label = new QLabel(this); } - if(addMovie && !label->movie()) + if (addMovie && !label->movie()) { QMovie *movie = new QMovie(m_loadingGitPath, QByteArray(), label); movie->setSpeed(50); @@ -722,14 +722,14 @@ void MainView::resizeEvent(QResizeEvent *event) void MainView::detachTab(int index, MainWindow *toWindow) { - if(index < 0) + if (index < 0) index = currentIndex(); - if(index < 0 || index >= count()) + if (index < 0 || index >= count()) return; WebTab *tab = webTab(index); KUrl u = tab->url(); - if(u.scheme() == QL1S("about")) + if (u.scheme() == QL1S("about")) { closeTab(index); rApp->loadUrl(u, Rekonq::NewWindow); @@ -741,7 +741,7 @@ void MainView::detachTab(int index, MainWindow *toWindow) closeTab(index, false); MainWindow *w; - if(toWindow == NULL) + if (toWindow == NULL) w = rApp->newMainWindow(false); else w = toWindow; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e4bddd1a..c0ca149e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -195,10 +195,10 @@ void MainWindow::setupToolbars() void MainWindow::initBookmarkBar() { KToolBar *XMLGUIBkBar = toolBar("bookmarkToolBar"); - if(!XMLGUIBkBar) + if (!XMLGUIBkBar) return; - if(m_bookmarksBar) + if (m_bookmarksBar) { rApp->bookmarkProvider()->removeBookmarkBar(m_bookmarksBar); delete m_bookmarksBar; @@ -210,7 +210,7 @@ void MainWindow::initBookmarkBar() void MainWindow::configureToolbars() { - if(autoSaveSettings()) + if (autoSaveSettings()) saveAutoSaveSettings(); KEditToolBar dlg(factory(), this); @@ -222,7 +222,7 @@ void MainWindow::configureToolbars() void MainWindow::updateToolsMenu() { - if(m_toolsMenu->isEmpty()) + if (m_toolsMenu->isEmpty()) { m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Open))); m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::SaveAs))); @@ -250,7 +250,7 @@ void MainWindow::updateToolsMenu() m_developerMenu->addAction(actionByName(QL1S("set_editable"))); m_toolsMenu->addAction(m_developerMenu); - if(!ReKonfig::showDeveloperTools()) + if (!ReKonfig::showDeveloperTools()) m_developerMenu->setVisible(false); m_toolsMenu->addSeparator(); @@ -339,7 +339,7 @@ QSize MainWindow::sizeHint() const void MainWindow::changeWindowIcon(int index) { - if(ReKonfig::useFavicon()) + if (ReKonfig::useFavicon()) { KUrl url = mainView()->webTab(index)->url(); QIcon icon = rApp->iconManager()->iconForUrl(url).pixmap(QSize(32, 32)); @@ -486,7 +486,7 @@ void MainWindow::setupActions() QSignalMapper *tabSignalMapper = new QSignalMapper(this); // shortcuts for quickly switching to a tab - for(int i = 1; i <= 9; i++) + for (int i = 1; i <= 9; i++) { a = new KAction(i18n("Switch to Tab %1", i), this); a->setShortcut(KShortcut(QString("Alt+%1").arg(i))); @@ -498,7 +498,7 @@ void MainWindow::setupActions() // shortcuts for loading favorite pages QSignalMapper *favoritesSignalMapper = new QSignalMapper(this); - for(int i = 1; i <= 9; ++i) + for (int i = 1; i <= 9; ++i) { a = new KAction(i18n("Switch to Favorite Page %1", i), this); a->setShortcut(KShortcut(QString("Ctrl+%1").arg(i))); @@ -637,7 +637,7 @@ void MainWindow::setupPanels() void MainWindow::openLocation() { - if(isFullScreen()) + if (isFullScreen()) { setWidgetsVisible(true); } @@ -655,26 +655,26 @@ void MainWindow::fileSaveAs() QString name = w->page()->suggestedFileName(); // Second, with KUrl fileName... - if(name.isEmpty()) + if (name.isEmpty()) { name = srcUrl.fileName(); } // Last chance... - if(name.isEmpty()) + if (name.isEmpty()) { name = srcUrl.host() + QString(".html"); } const QString destUrl = KFileDialog::getSaveFileName(name, QString(), this); - if(destUrl.isEmpty()) + if (destUrl.isEmpty()) return; - if(w->page()->isContentEditable()) + if (w->page()->isContentEditable()) { QString code = w->page()->mainFrame()->toHtml(); QFile file(destUrl); - if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) return; QTextStream out(&file); @@ -694,7 +694,7 @@ void MainWindow::preferences() { // an instance the dialog could be already created and could be cached, // in which case you want to display the cached dialog - if(SettingsDialog::showDialog("rekonfig")) + if (SettingsDialog::showDialog("rekonfig")) return; // we didn't find an instance of this dialog, so lets create it @@ -713,7 +713,7 @@ void MainWindow::updateActions() bool rekonqPage = currentTab()->page()->isOnRekonqPage(); QAction *historyBackAction = actionByName(KStandardAction::name(KStandardAction::Back)); - if(rekonqPage && currentTab()->view()->history()->count() > 0) + if (rekonqPage && currentTab()->view()->history()->count() > 0) historyBackAction->setEnabled(true); else historyBackAction->setEnabled(currentTab()->view()->history()->canGoBack()); @@ -726,9 +726,9 @@ void MainWindow::updateActions() void MainWindow::updateWindowTitle(const QString &title) { QWebSettings *settings = QWebSettings::globalSettings(); - if(title.isEmpty()) + if (title.isEmpty()) { - if(settings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) + if (settings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) { setWindowTitle(i18nc("Window title when private browsing is activated", "rekonq (Private Browsing)")); } @@ -739,7 +739,7 @@ void MainWindow::updateWindowTitle(const QString &title) } else { - if(settings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) + if (settings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) { setWindowTitle(i18nc("window title, %1 = title of the active website", "%1 – rekonq (Private Browsing)", title)); } @@ -759,7 +759,7 @@ void MainWindow::fileOpen() this, i18n("Open Web Resource")); - if(filePath.isEmpty()) + if (filePath.isEmpty()) return; rApp->loadUrl(filePath); @@ -768,17 +768,17 @@ void MainWindow::fileOpen() void MainWindow::printRequested(QWebFrame *frame) { - if(!currentTab()) + if (!currentTab()) return; - if(currentTab()->page()->isOnRekonqPage()) + if (currentTab()->page()->isOnRekonqPage()) { // trigger print part action instead of ours.. KParts::ReadOnlyPart *p = currentTab()->part(); - if(p) + if (p) { KParts::BrowserExtension *ext = p->browserExtension(); - if(ext) + if (ext) { KParts::BrowserExtension::ActionSlotMap *actionSlotMap = KParts::BrowserExtension::actionSlotMapPtr(); @@ -791,7 +791,7 @@ void MainWindow::printRequested(QWebFrame *frame) } QWebFrame *printFrame = 0; - if(frame == 0) + if (frame == 0) { printFrame = currentTab()->page()->mainFrame(); } @@ -811,7 +811,7 @@ void MainWindow::printRequested(QWebFrame *frame) void MainWindow::find(const QString & search) { - if(!currentTab()) + if (!currentTab()) return; m_lastSearch = search; @@ -822,7 +822,7 @@ void MainWindow::find(const QString & search) void MainWindow::matchCaseUpdate() { - if(!currentTab()) + if (!currentTab()) return; currentTab()->view()->findText(m_lastSearch, QWebPage::FindBackward); @@ -833,14 +833,14 @@ void MainWindow::matchCaseUpdate() void MainWindow::findNext() { - if(!currentTab()) + if (!currentTab()) return; - if(currentTab()->page()->isOnRekonqPage()) + if (currentTab()->page()->isOnRekonqPage()) { // trigger part find action KParts::ReadOnlyPart *p = currentTab()->part(); - if(p) + if (p) { connect(this, SIGNAL(triggerPartFind()), p, SLOT(slotFind())); emit triggerPartFind(); @@ -848,7 +848,7 @@ void MainWindow::findNext() } } - if(m_findBar->isHidden()) + if (m_findBar->isHidden()) { QPoint previous_position = currentTab()->view()->page()->currentFrame()->scrollPosition(); currentTab()->view()->page()->focusNextPrevChild(true); @@ -857,13 +857,13 @@ void MainWindow::findNext() } QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument; - if(m_findBar->matchCase()) + if (m_findBar->matchCase()) options |= QWebPage::FindCaseSensitively; bool found = currentTab()->view()->findText(m_lastSearch, options); m_findBar->notifyMatch(found); - if(!found) + if (!found) { QPoint previous_position = currentTab()->view()->page()->currentFrame()->scrollPosition(); currentTab()->view()->page()->focusNextPrevChild(true); @@ -874,11 +874,11 @@ void MainWindow::findNext() void MainWindow::findPrevious() { - if(!currentTab()) + if (!currentTab()) return; QWebPage::FindFlags options = QWebPage::FindBackward | QWebPage::FindWrapsAroundDocument; - if(m_findBar->matchCase()) + if (m_findBar->matchCase()) options |= QWebPage::FindCaseSensitively; bool found = currentTab()->view()->findText(m_lastSearch, options); @@ -888,16 +888,16 @@ void MainWindow::findPrevious() void MainWindow::updateHighlight() { - if(!currentTab()) + if (!currentTab()) return; QWebPage::FindFlags options = QWebPage::HighlightAllOccurrences; currentTab()->view()->findText("", options); //Clear an existing highlight - if(m_findBar->highlightAllState() && !m_findBar->isHidden()) + if (m_findBar->highlightAllState() && !m_findBar->isHidden()) { - if(m_findBar->matchCase()) + if (m_findBar->matchCase()) options |= QWebPage::FindCaseSensitively; currentTab()->view()->findText(m_lastSearch, options); @@ -928,10 +928,10 @@ void MainWindow::setWidgetsVisible(bool makeVisible) KToolBar *mainBar = toolBar("mainToolBar"); KToolBar *bookBar = toolBar("bookmarksToolBar"); - if(!makeVisible) + if (!makeVisible) { // save current state, if in windowed mode - if(!isFullScreen()) + if (!isFullScreen()) { bookmarksToolBarFlag = bookBar->isHidden(); historyPanelFlag = m_historyPanel->isHidden(); @@ -953,11 +953,11 @@ void MainWindow::setWidgetsVisible(bool makeVisible) m_view->tabBar()->show(); // restore state of windowed mode - if(!bookmarksToolBarFlag) + if (!bookmarksToolBarFlag) bookBar->show(); - if(!historyPanelFlag) + if (!historyPanelFlag) m_historyPanel->show(); - if(!bookmarksPanelFlag) + if (!bookmarksPanelFlag) m_bookmarksPanel->show(); } } @@ -965,7 +965,7 @@ void MainWindow::setWidgetsVisible(bool makeVisible) QString MainWindow::selectedText() const { - if(!currentTab()) + if (!currentTab()) return QString(); return currentTab()->view()->selectedText(); @@ -976,7 +976,7 @@ void MainWindow::viewPageSource() { WebTab * w = currentTab(); - if(!w) + if (!w) return; KUrl url = w->url(); @@ -990,7 +990,7 @@ void MainWindow::viewPageSource() QFile temp(filePath); - if(temp.open(QFile::WriteOnly | QFile::Truncate)) + if (temp.open(QFile::WriteOnly | QFile::Truncate)) { QTextStream out(&temp); out << code; @@ -1007,7 +1007,7 @@ void MainWindow::homePage(Qt::MouseButtons mouseButtons, Qt::KeyboardModifiers k ? KUrl(QL1S("about:home")) : KUrl(ReKonfig::homePage()); - if(mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier) + if (mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier) rApp->loadUrl(homeUrl, Rekonq::NewTab); else currentTab()->view()->load(homeUrl); @@ -1024,7 +1024,7 @@ void MainWindow::browserLoading(bool v) { QAction *stop = actionCollection()->action(QL1S("stop")); QAction *reload = actionCollection()->action(QL1S("view_redisplay")); - if(v) + if (v) { disconnect(m_stopReloadAction, SIGNAL(triggered(bool)), reload , SIGNAL(triggered(bool))); m_stopReloadAction->setIcon(KIcon("process-stop")); @@ -1052,22 +1052,22 @@ void MainWindow::openPrevious(Qt::MouseButtons mouseButtons, Qt::KeyboardModifie QWebHistory *history = currentTab()->view()->history(); QWebHistoryItem *item = 0; - if(currentTab()->page()->isOnRekonqPage()) + if (currentTab()->page()->isOnRekonqPage()) { item = new QWebHistoryItem(history->currentItem()); } else { - if(history->canGoBack()) + if (history->canGoBack()) { item = new QWebHistoryItem(history->backItem()); } } - if(!item) + if (!item) return; - if(mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier) + if (mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier) { rApp->loadUrl(item->url(), Rekonq::NewTab); } @@ -1085,22 +1085,22 @@ void MainWindow::openNext(Qt::MouseButtons mouseButtons, Qt::KeyboardModifiers k QWebHistory *history = currentTab()->view()->history(); QWebHistoryItem *item = 0; - if(currentTab()->view()->page()->isOnRekonqPage()) + if (currentTab()->view()->page()->isOnRekonqPage()) { item = new QWebHistoryItem(history->currentItem()); } else { - if(history->canGoForward()) + if (history->canGoForward()) { item = new QWebHistoryItem(history->forwardItem()); } } - if(!item) + if (!item) return; - if(mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier) + if (mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier) { rApp->loadUrl(item->url(), Rekonq::NewTab); } @@ -1116,14 +1116,14 @@ void MainWindow::openNext(Qt::MouseButtons mouseButtons, Qt::KeyboardModifiers k void MainWindow::keyPressEvent(QKeyEvent *event) { // ctrl + tab action - if((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_Tab)) + if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_Tab)) { emit ctrlTabPressed(); return; } // shift + ctrl + tab action - if((event->modifiers() == Qt::ControlModifier + Qt::ShiftModifier) && (event->key() == Qt::Key_Backtab)) + if ((event->modifiers() == Qt::ControlModifier + Qt::ShiftModifier) && (event->key() == Qt::Key_Backtab)) { emit shiftCtrlTabPressed(); return; @@ -1136,13 +1136,13 @@ void MainWindow::keyPressEvent(QKeyEvent *event) bool MainWindow::event(QEvent *event) { // Avoid a conflict with window-global actions - if(event->type() == QEvent::ShortcutOverride || event->type() == QEvent::KeyPress) + if (event->type() == QEvent::ShortcutOverride || event->type() == QEvent::KeyPress) { QKeyEvent *kev = static_cast<QKeyEvent *>(event); - if(kev->key() == Qt::Key_Escape) + if (kev->key() == Qt::Key_Escape) { // if zoombar is visible, hide it - if(m_zoomBar->isVisible()) + if (m_zoomBar->isVisible()) { m_zoomBar->hide(); event->accept(); @@ -1151,7 +1151,7 @@ bool MainWindow::event(QEvent *event) } // if findbar is visible, hide it - if(m_findBar->isVisible()) + if (m_findBar->isVisible()) { m_findBar->hide(); event->accept(); @@ -1166,13 +1166,13 @@ bool MainWindow::event(QEvent *event) void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status) { - if(this != QApplication::activeWindow()) + if (this != QApplication::activeWindow()) { return; } // deleting popus if empty msgs - if(msg.isEmpty()) + if (msg.isEmpty()) { m_hidePopupTimer->start(250); return; @@ -1181,7 +1181,7 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status) m_hidePopupTimer->stop(); - switch(status) + switch (status) { case Rekonq::Url: break; @@ -1204,7 +1204,7 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status) QLabel *label = new QLabel(msg); m_popup->setView(label); QSize labelSize(label->fontMetrics().width(msg) + 2 * margin, label->fontMetrics().height() + 2 * margin); - if(labelSize.width() > width()) + if (labelSize.width() > width()) { labelSize.setWidth(width()); label->setText(label->fontMetrics().elidedText(msg, Qt::ElideMiddle, width())); @@ -1217,7 +1217,7 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status) WebTab *tab = m_view->currentWebTab(); // fix crash on window close - if(!tab || !tab->page()) + if (!tab || !tab->page()) return; bool horizontalScrollbarIsVisible = tab->page()->currentFrame()->scrollBarMaximum(Qt::Horizontal); @@ -1234,13 +1234,13 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status) int x = mapToGlobal(QPoint(0, 0)).x(); int y = webViewOrigin.y() + tab->page()->viewportSize().height() - labelSize.height() - hScrollbarSize; - if(QRect(x, y, labelSize.width() , labelSize.height()).contains(mousePos)) + if (QRect(x, y, labelSize.width() , labelSize.height()).contains(mousePos)) { // settings popup on the right x = mapToGlobal(QPoint(- labelSize.width() + tab->page()->viewportSize().width(), 0)).x() - vScrollbarSize; } - if(QRect(x , y , labelSize.width() , labelSize.height()).contains(mousePos)) + if (QRect(x , y , labelSize.width() , labelSize.height()).contains(mousePos)) { // setting popup above the mouse y -= labelSize.height(); @@ -1272,7 +1272,7 @@ void MainWindow::clearPrivateData() dialog->setMainWidget(&widget); dialog->exec(); - if(dialog->result() == QDialog::Accepted) + if (dialog->result() == QDialog::Accepted) { //Save current state ReKonfig::setClearHistory(clearWidget.clearHistory->isChecked()); @@ -1282,34 +1282,34 @@ void MainWindow::clearPrivateData() ReKonfig::setClearWebIcons(clearWidget.clearWebIcons->isChecked()); ReKonfig::setClearHomePageThumbs(clearWidget.homePageThumbs->isChecked()); - if(clearWidget.clearHistory->isChecked()) + if (clearWidget.clearHistory->isChecked()) { rApp->historyManager()->clear(); } - if(clearWidget.clearDownloads->isChecked()) + if (clearWidget.clearDownloads->isChecked()) { rApp->downloadManager()->clearDownloadsHistory(); } - if(clearWidget.clearCookies->isChecked()) + if (clearWidget.clearCookies->isChecked()) { QDBusInterface kcookiejar("org.kde.kded", "/modules/kcookiejar", "org.kde.KCookieServer"); QDBusReply<void> reply = kcookiejar.call("deleteAllCookies"); } - if(clearWidget.clearCachedPages->isChecked()) + if (clearWidget.clearCachedPages->isChecked()) { KProcess::startDetached(KStandardDirs::findExe("kio_http_cache_cleaner"), QStringList(QL1S("--clear-all"))); } - if(clearWidget.clearWebIcons->isChecked()) + if (clearWidget.clearWebIcons->isChecked()) { rApp->iconManager()->clearIconCache(); } - if(clearWidget.homePageThumbs->isChecked()) + if (clearWidget.homePageThumbs->isChecked()) { QString path = KStandardDirs::locateLocal("cache", QString("thumbs/rekonq"), true); path.remove("rekonq"); @@ -1329,7 +1329,7 @@ void MainWindow::clearPrivateData() void MainWindow::aboutToShowBackMenu() { m_historyBackMenu->clear(); - if(!currentTab()) + if (!currentTab()) return; QWebHistory *history = currentTab()->view()->history(); int pivot = history->currentItemIndex(); @@ -1337,10 +1337,10 @@ void MainWindow::aboutToShowBackMenu() const int maxItemNumber = 8; // no more than 8 elements in the Back History Menu! QList<QWebHistoryItem> historyList = history->backItems(maxItemNumber); int listCount = historyList.count(); - if(pivot >= maxItemNumber) + if (pivot >= maxItemNumber) offset = pivot - maxItemNumber; - if(currentTab()->view()->page()->isOnRekonqPage()) + if (currentTab()->view()->page()->isOnRekonqPage()) { QWebHistoryItem item = history->currentItem(); KAction *action = new KAction(this); @@ -1351,7 +1351,7 @@ void MainWindow::aboutToShowBackMenu() m_historyBackMenu->addAction(action); } - for(int i = listCount - 1; i >= 0; --i) + for (int i = listCount - 1; i >= 0; --i) { QWebHistoryItem item = historyList.at(i); KAction *action = new KAction(this); @@ -1368,7 +1368,7 @@ void MainWindow::aboutToShowForwardMenu() { m_historyForwardMenu->clear(); - if(!currentTab()) + if (!currentTab()) return; QWebHistory *history = currentTab()->view()->history(); @@ -1378,10 +1378,10 @@ void MainWindow::aboutToShowForwardMenu() QList<QWebHistoryItem> historyList = history->forwardItems(maxItemNumber); int listCount = historyList.count(); - if(pivot >= maxItemNumber) + if (pivot >= maxItemNumber) offset = pivot - maxItemNumber; - if(currentTab()->view()->page()->isOnRekonqPage()) + if (currentTab()->view()->page()->isOnRekonqPage()) { QWebHistoryItem item = history->currentItem(); KAction *action = new KAction(this); @@ -1392,7 +1392,7 @@ void MainWindow::aboutToShowForwardMenu() m_historyForwardMenu->addAction(action); } - for(int i = 1; i <= listCount; i++) + for (int i = 1; i <= listCount; i++) { QWebHistoryItem item = historyList.at(i - 1); KAction *action = new KAction(this); @@ -1408,12 +1408,12 @@ void MainWindow::aboutToShowForwardMenu() void MainWindow::aboutToShowTabListMenu() { m_tabListMenu->clear(); - for(int i = 0; i < m_view->count(); ++i) + for (int i = 0; i < m_view->count(); ++i) { KAction *action = new KAction(m_view->tabText(i), this); action->setIcon(rApp->iconManager()->iconForUrl(m_view->webTab(i)->url()).pixmap(16, 16)); action->setData(i); - if(mainView()->tabBar()->currentIndex() == i) + if (mainView()->tabBar()->currentIndex() == i) { QFont font = action->font(); font.setBold(true); @@ -1430,7 +1430,7 @@ void MainWindow::openActionUrl(QAction *action) int index = action->data().toInt(); QWebHistory *history = currentTab()->view()->history(); - if(!history->itemAt(index).isValid()) + if (!history->itemAt(index).isValid()) { kDebug() << "Invalid Index!: " << index; return; @@ -1442,7 +1442,7 @@ void MainWindow::openActionUrl(QAction *action) void MainWindow::openActionTab(QAction* action) { int index = action->data().toInt(); - if(index < 0 || index >= m_view->count()) + if (index < 0 || index >= m_view->count()) { kDebug() << "Invalid Index!: " << index; return; @@ -1487,7 +1487,7 @@ void MainWindow::populateUserAgentMenu() QStringList UAlist = uaInfo.availableUserAgents(); int uaIndex = uaInfo.uaIndexForHost(currentTab()->url().host()); - for(int i = 0; i < UAlist.count(); ++i) + for (int i = 0; i < UAlist.count(); ++i) { QString uaDesc = UAlist.at(i); @@ -1496,7 +1496,7 @@ void MainWindow::populateUserAgentMenu() a->setCheckable(true); connect(a, SIGNAL(triggered(bool)), this, SLOT(setUserAgent())); - if(i == uaIndex) + if (i == uaIndex) { a->setChecked(true); defaultUA = false; @@ -1520,14 +1520,14 @@ void MainWindow::enableNetworkAnalysis(bool b) bool MainWindow::queryClose() { // this should fux bug 240432 - if(rApp->sessionSaving()) + if (rApp->sessionSaving()) return true; // smooth private browsing mode - if(QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) + if (QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) return true; - if(rApp->mainWindowList().count() > 1) + if (rApp->mainWindowList().count() > 1) { int answer = KMessageBox::questionYesNoCancel( this, @@ -1539,7 +1539,7 @@ bool MainWindow::queryClose() "confirmClosingMultipleWindows" ); - switch(answer) + switch (answer) { case KMessageBox::Yes: return true; @@ -1568,13 +1568,13 @@ void MainWindow::setupBookmarksAndToolsShortcuts() KToolBar *mainBar = toolBar("mainToolBar"); QToolButton *bookmarksButton = qobject_cast<QToolButton*>(mainBar->widgetForAction(actionByName(QL1S("bookmarksActionMenu")))); - if(bookmarksButton) + if (bookmarksButton) { connect(actionByName(QL1S("bookmarksActionMenu")), SIGNAL(triggered()), bookmarksButton, SLOT(showMenu())); } QToolButton *toolsButton = qobject_cast<QToolButton*>(mainBar->widgetForAction(actionByName(QL1S("rekonq_tools")))); - if(toolsButton) + if (toolsButton) { connect(actionByName(QL1S("rekonq_tools")), SIGNAL(triggered()), toolsButton, SLOT(showMenu())); } @@ -1597,9 +1597,9 @@ void MainWindow::showUserAgentSettings() void MainWindow::moveEvent(QMoveEvent *event) { - if(m_hidePopupTimer) + if (m_hidePopupTimer) m_hidePopupTimer->stop(); - if(m_popup) + if (m_popup) m_popup->hide(); KMainWindow::moveEvent(event); @@ -1608,9 +1608,9 @@ void MainWindow::moveEvent(QMoveEvent *event) void MainWindow::resizeEvent(QResizeEvent *event) { - if(m_hidePopupTimer) + if (m_hidePopupTimer) m_hidePopupTimer->stop(); - if(m_popup) + if (m_popup) m_popup->hide(); KMainWindow::resizeEvent(event); diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index 3c03657c..21377dd9 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -44,9 +44,9 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) : AccessManager(parent) { QString c = KGlobal::locale()->country(); - if(c == QL1S("C")) + if (c == QL1S("C")) c = QL1S("en_US"); - if(c != QL1S("en_US")) + if (c != QL1S("en_US")) c.append(QL1S(", en_US")); _acceptLanguage = c.toLatin1(); @@ -64,7 +64,7 @@ QNetworkReply *NetworkAccessManager::createRequest(QNetworkAccessManager::Operat req.setRawHeader("Accept-Language", _acceptLanguage); KIO::CacheControl cc = KProtocolManager::cacheControl(); - switch(cc) + switch (cc) { case KIO::CC_CacheOnly: // Fail request if not in cache. req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysCache); @@ -86,14 +86,14 @@ QNetworkReply *NetworkAccessManager::createRequest(QNetworkAccessManager::Operat } // Handle GET operations with AdBlock - if(op == QNetworkAccessManager::GetOperation) + if (op == QNetworkAccessManager::GetOperation) reply = rApp->adblockManager()->block(req, parentPage); - if(!reply) + if (!reply) reply = AccessManager::createRequest(op, req, outgoingData); - if(parentPage && parentPage->hasNetworkAnalyzerEnabled()) + if (parentPage && parentPage->hasNetworkAnalyzerEnabled()) emit networkData(op, req, reply); return reply; diff --git a/src/newtabpage.cpp b/src/newtabpage.cpp index 082070bb..6de35038 100644 --- a/src/newtabpage.cpp +++ b/src/newtabpage.cpp @@ -65,7 +65,7 @@ NewTabPage::NewTabPage(QWebFrame *frame) QFile file(htmlFilePath); bool isOpened = file.open(QIODevice::ReadOnly); - if(!isOpened) + if (!isOpened) { kDebug() << "Couldn't open the home.html file"; } @@ -79,9 +79,9 @@ NewTabPage::NewTabPage(QWebFrame *frame) void NewTabPage::generate(const KUrl &url) { - if(KUrl("about:preview").isParentOf(url)) + if (KUrl("about:preview").isParentOf(url)) { - if(url.fileName() == QL1S("add")) + if (url.fileName() == QL1S("add")) { QStringList names = ReKonfig::previewNames(); QStringList urls = ReKonfig::previewUrls(); @@ -98,25 +98,25 @@ void NewTabPage::generate(const KUrl &url) generate(KUrl("about:favorites")); return; } - if(url.directory() == QL1S("preview/remove")) + if (url.directory() == QL1S("preview/remove")) { removePreview(url.fileName().toInt()); return; } - if(url.directory() == QL1S("preview/modify")) + if (url.directory() == QL1S("preview/modify")) { int index = url.fileName().toInt(); rApp->mainWindow()->currentTab()->createPreviewSelectorBar(index); return; } } - if(url.fileName() == QL1S("clear")) + if (url.fileName() == QL1S("clear")) { rApp->mainWindow()->actionByName("clear_private_data")->trigger(); generate(QString(QL1S("about:") + url.directory())); return; } - if(url == KUrl("about:bookmarks/edit")) + if (url == KUrl("about:bookmarks/edit")) { rApp->bookmarkProvider()->bookmarkManager()->slotEditBookmarks(); return; @@ -132,27 +132,27 @@ void NewTabPage::generate(const KUrl &url) QString title; QByteArray encodedUrl = url.toEncoded(); - if(encodedUrl == QByteArray("about:favorites")) + if (encodedUrl == QByteArray("about:favorites")) { favoritesPage(); title = i18n("Favorites"); } - else if(encodedUrl == QByteArray("about:closedTabs")) + else if (encodedUrl == QByteArray("about:closedTabs")) { closedTabsPage(); title = i18n("Closed Tabs"); } - else if(encodedUrl == QByteArray("about:history")) + else if (encodedUrl == QByteArray("about:history")) { historyPage(); title = i18n("History"); } - else if(encodedUrl == QByteArray("about:bookmarks")) + else if (encodedUrl == QByteArray("about:bookmarks")) { bookmarksPage(); title = i18n("Bookmarks"); } - else if(encodedUrl == QByteArray("about:downloads")) + else if (encodedUrl == QByteArray("about:downloads")) { downloadsPage(); title = i18n("Downloads"); @@ -175,21 +175,21 @@ void NewTabPage::favoritesPage() QStringList names = ReKonfig::previewNames(); QStringList urls = ReKonfig::previewUrls(); - if(urls.isEmpty()) + if (urls.isEmpty()) { m_root.addClass(QL1S("empty")); m_root.setPlainText(i18n("You can add a favorite by clicking the \"Add Favorite\" button in the top-right corner of this page")); return; } - for(int i = 0; i < urls.count() ; ++i) + for (int i = 0; i < urls.count() ; ++i) { KUrl url = KUrl(urls.at(i)); QWebElement prev; - if(url.isEmpty()) + if (url.isEmpty()) prev = emptyPreview(i); - else if(!WebSnap::existsImage(url)) + else if (!WebSnap::existsImage(url)) prev = loadingPreview(i, url); else prev = validPreview(i, url, QString::number(i + 1) + " - " + names.at(i)); @@ -287,27 +287,27 @@ void NewTabPage::setupPreview(QWebElement e, int index) void NewTabPage::snapFinished() { // Update page, but only if open - if(m_root.document().findAll(QL1S("#rekonq-newtabpage")).count() == 0) + if (m_root.document().findAll(QL1S("#rekonq-newtabpage")).count() == 0) return; - if(m_root.findAll(QL1S(".favorites")).count() == 0 && m_root.findAll(QL1S(".closedTabs")).count() == 0) + if (m_root.findAll(QL1S(".favorites")).count() == 0 && m_root.findAll(QL1S(".closedTabs")).count() == 0) return; QStringList urls = ReKonfig::previewUrls(); QStringList names = ReKonfig::previewNames(); - for(int i = 0; i < urls.count(); i++) + for (int i = 0; i < urls.count(); i++) { KUrl url = KUrl(urls.at(i)); QString title = names.at(i); - if(WebSnap::existsImage(url)) + if (WebSnap::existsImage(url)) { QWebElement prev = m_root.findFirst(QL1S("#preview") + QVariant(i).toString()); - if(KUrl(prev.findFirst("a").attribute(QL1S("href"))) == url) + if (KUrl(prev.findFirst("a").attribute(QL1S("href"))) == url) { QWebElement newPrev = validPreview(i, url, title); - if(m_root.findAll(QL1S(".closedTabs")).count() != 0) + if (m_root.findAll(QL1S(".closedTabs")).count() != 0) hideControls(newPrev); prev.replace(newPrev); @@ -373,9 +373,9 @@ void NewTabPage::browsingMenu(const KUrl ¤tUrl) const QString aTagString(QL1C('a')); const QString hrefAttributeString(QL1S("href")); - if(it.findFirst(aTagString).attribute(hrefAttributeString) == currentUrl.toMimeDataString()) + if (it.findFirst(aTagString).attribute(hrefAttributeString) == currentUrl.toMimeDataString()) it.addClass(QL1S("current")); - else if(currentUrl == QL1S("about:home") && it.findFirst(aTagString).attribute(hrefAttributeString) == QL1S("about:favorites")) + else if (currentUrl == QL1S("about:home") && it.findFirst(aTagString).attribute(hrefAttributeString) == QL1S("about:favorites")) it.addClass(QL1S("current")); m_root.document().findFirst(QL1S("#navigation")).appendInside(it); } @@ -394,7 +394,7 @@ void NewTabPage::historyPage() HistoryTreeModel *model = rApp->historyManager()->historyTreeModel(); - if(model->rowCount() == 0) + if (model->rowCount() == 0) { m_root.addClass(QL1S("empty")); m_root.setPlainText(i18n("Your browsing history is empty")); @@ -407,18 +407,18 @@ void NewTabPage::historyPage() do { QModelIndex index = model->index(i, 0, QModelIndex()); - if(model->hasChildren(index)) + if (model->hasChildren(index)) { m_root.appendInside(markup(QL1S("h3"))); m_root.lastChild().setPlainText(index.data().toString()); - for(int j = 0; j < model->rowCount(index); ++j) + for (int j = 0; j < model->rowCount(index); ++j) { QModelIndex son = model->index(j, 0, index); KUrl u = son.data(HistoryModel::UrlStringRole).toUrl(); QString b = faviconsDir + u.host() + QL1S(".png"); - if(QFile::exists(b)) + if (QFile::exists(b)) icon = QL1S("file://") + b; m_root.appendInside(son.data(HistoryModel::DateTimeRole).toDateTime().toString("hh:mm")); @@ -436,7 +436,7 @@ void NewTabPage::historyPage() } i++; } - while(model->hasIndex(i , 0 , QModelIndex())); + while (model->hasIndex(i , 0 , QModelIndex())); } @@ -451,7 +451,7 @@ void NewTabPage::bookmarksPage() m_root.document().findFirst(QL1S("#actions")).appendInside(editBookmarks); KBookmarkGroup bookGroup = rApp->bookmarkProvider()->rootGroup(); - if(bookGroup.isNull()) + if (bookGroup.isNull()) { m_root.addClass(QL1S("empty")); m_root.setPlainText(i18n("You have no bookmarks")); @@ -459,7 +459,7 @@ void NewTabPage::bookmarksPage() } KBookmark bookmark = bookGroup.first(); - while(!bookmark.isNull()) + while (!bookmark.isNull()) { createBookItem(bookmark, m_root); bookmark = bookGroup.next(bookmark); @@ -471,27 +471,27 @@ void NewTabPage::createBookItem(const KBookmark &bookmark, QWebElement parent) { QString cacheDir = QL1S("file://") + KStandardDirs::locateLocal("cache" , "" , true); QString icon = QL1S("file://") + KGlobal::dirs()->findResource("icon", "oxygen/16x16/mimetypes/text-html.png"); - if(bookmark.isGroup()) + if (bookmark.isGroup()) { KBookmarkGroup group = bookmark.toGroup(); KBookmark bm = group.first(); parent.appendInside(markup(QL1S("h3"))); parent.lastChild().setPlainText(group.fullText()); parent.appendInside(markup(QL1S(".bookfolder"))); - while(!bm.isNull()) + while (!bm.isNull()) { createBookItem(bm, parent.lastChild()); // it is .bookfolder bm = group.next(bm); } } - else if(bookmark.isSeparator()) + else if (bookmark.isSeparator()) { parent.appendInside(QL1S("<hr />")); } else { QString b = bookmark.icon(); - if(b.contains(QL1S("favicons"))) + if (b.contains(QL1S("favicons"))) icon = cacheDir + bookmark.icon() + QL1S(".png"); parent.appendInside(markup(QL1S("img"))); @@ -513,19 +513,19 @@ void NewTabPage::closedTabsPage() QList<HistoryItem> links = rApp->mainWindow()->mainView()->recentlyClosedTabs(); - if(links.isEmpty()) + if (links.isEmpty()) { m_root.addClass(QL1S("empty")); m_root.setPlainText(i18n("There are no recently closed tabs")); return; } - for(int i = 0; i < links.count(); ++i) + for (int i = 0; i < links.count(); ++i) { HistoryItem item = links.at(i); QWebElement prev; - if(item.url.isEmpty()) + if (item.url.isEmpty()) continue; prev = WebSnap::existsImage(KUrl(item.url)) @@ -542,7 +542,7 @@ void NewTabPage::closedTabsPage() QString NewTabPage::checkTitle(const QString &title) { QString t(title); - if(t.length() > 23) + if (t.length() > 23) { t.truncate(20); t += QL1S("..."); @@ -563,7 +563,7 @@ void NewTabPage::downloadsPage() DownloadList list = rApp->downloadManager()->downloads(); - if(list.isEmpty()) + if (list.isEmpty()) { m_root.addClass(QL1S("empty")); m_root.setPlainText(i18n("There are no recently downloaded files to show")); diff --git a/src/opensearch/opensearchengine.cpp b/src/opensearch/opensearchengine.cpp index f48118ca..d5c64d68 100644 --- a/src/opensearch/opensearchengine.cpp +++ b/src/opensearch/opensearchengine.cpp @@ -51,7 +51,7 @@ OpenSearchEngine::OpenSearchEngine(QObject *parent) OpenSearchEngine::~OpenSearchEngine() { - if(m_parser) + if (m_parser) { delete m_parser; } @@ -66,7 +66,7 @@ QString OpenSearchEngine::parseTemplate(const QString &searchTerm, const QString QString country = language; country = (country.remove(0, country.indexOf(QL1C('-')) + 1)).toLower(); const int firstDashPosition = country.indexOf(QL1C('-')); - if(firstDashPosition >= 0) + if (firstDashPosition >= 0) country = country.mid(firstDashPosition + 1); QString result = searchTemplate; @@ -121,7 +121,7 @@ void OpenSearchEngine::setSearchUrlTemplate(const QString &searchUrlTemplate) KUrl OpenSearchEngine::searchUrl(const QString &searchTerm) const { - if(m_searchUrlTemplate.isEmpty()) + if (m_searchUrlTemplate.isEmpty()) { return KUrl(); } @@ -129,7 +129,7 @@ KUrl OpenSearchEngine::searchUrl(const QString &searchTerm) const KUrl retVal = KUrl::fromEncoded(parseTemplate(searchTerm, m_searchUrlTemplate).toUtf8()); QList<Parameter>::const_iterator i; - for(i = m_searchParameters.constBegin(); i != m_searchParameters.constEnd(); ++i) + for (i = m_searchParameters.constBegin(); i != m_searchParameters.constEnd(); ++i) { retVal.addQueryItem(i->first, parseTemplate(searchTerm, i->second)); } @@ -158,7 +158,7 @@ void OpenSearchEngine::setSuggestionsUrlTemplate(const QString &suggestionsUrlTe KUrl OpenSearchEngine::suggestionsUrl(const QString &searchTerm) const { - if(m_suggestionsUrlTemplate.isEmpty()) + if (m_suggestionsUrlTemplate.isEmpty()) { return KUrl(); } @@ -166,7 +166,7 @@ KUrl OpenSearchEngine::suggestionsUrl(const QString &searchTerm) const KUrl retVal = KUrl::fromEncoded(parseTemplate(searchTerm, m_suggestionsUrlTemplate).toUtf8()); QList<Parameter>::const_iterator i; - for(i = m_suggestionsParameters.constBegin(); i != m_suggestionsParameters.constEnd(); ++i) + for (i = m_suggestionsParameters.constBegin(); i != m_suggestionsParameters.constEnd(); ++i) { retVal.addQueryItem(i->first, parseTemplate(searchTerm, i->second)); } @@ -255,7 +255,7 @@ bool OpenSearchEngine::operator<(const OpenSearchEngine &other) const ResponseList OpenSearchEngine::parseSuggestion(const QString &searchTerm, const QByteArray &resp) { QFile file(suggestionPathFor(searchTerm)); - if(file.open(QIODevice::WriteOnly | QIODevice::Text)) + if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { file.write(resp, resp.size()); file.close(); @@ -267,10 +267,10 @@ ResponseList OpenSearchEngine::parseSuggestion(const QString &searchTerm, const ResponseList OpenSearchEngine::parseSuggestion(const QByteArray &resp) { - if(!m_parser) + if (!m_parser) return ResponseList(); - if(resp.isEmpty()) + if (resp.isEmpty()) return ResponseList(); return m_parser->parse(resp); @@ -299,11 +299,11 @@ bool OpenSearchEngine::hasCachedSuggestionsFor(const QString &searchTerm) ResponseList OpenSearchEngine::cachedSuggestionsFor(const QString &searchTerm) { QFile file(suggestionPathFor(searchTerm)); - if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) return ResponseList(); QByteArray resp; - while(!file.atEnd()) + while (!file.atEnd()) { resp += file.readLine(); } diff --git a/src/opensearch/opensearchmanager.cpp b/src/opensearch/opensearchmanager.cpp index ea2ace32..05c2e116 100644 --- a/src/opensearch/opensearchmanager.cpp +++ b/src/opensearch/opensearchmanager.cpp @@ -76,17 +76,17 @@ void OpenSearchManager::setSearchProvider(const QString &searchProvider) { m_activeEngine = 0; - if(!m_engineCache.contains(searchProvider)) + if (!m_engineCache.contains(searchProvider)) { const QString fileName = KGlobal::dirs()->findResource("data", "rekonq/opensearch/" + trimmedEngineName(searchProvider) + ".xml"); kDebug() << searchProvider << " trimmed name: " << trimmedEngineName(searchProvider) << " file name path: " << fileName; - if(fileName.isEmpty()) + if (fileName.isEmpty()) { return; } QFile file(fileName); - if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { return; } @@ -94,7 +94,7 @@ void OpenSearchManager::setSearchProvider(const QString &searchProvider) OpenSearchReader reader; OpenSearchEngine *engine = reader.read(&file); - if(engine) + if (engine) { m_engineCache.insert(searchProvider, engine); } @@ -120,7 +120,7 @@ void OpenSearchManager::addOpenSearchEngine(const KUrl &url, const QString &titl m_shortcut = shortcut; - if(m_state != IDLE) + if (m_state != IDLE) { idleJob(); } @@ -134,10 +134,10 @@ void OpenSearchManager::addOpenSearchEngine(const KUrl &url, const QString &titl void OpenSearchManager::requestSuggestion(const QString &searchText) { - if(!m_activeEngine) + if (!m_activeEngine) return; - if(m_state != IDLE) + if (m_state != IDLE) { // NOTE: // changing OpenSearchManager behavior @@ -146,7 +146,7 @@ void OpenSearchManager::requestSuggestion(const QString &searchText) idleJob(); } - if(m_activeEngine->hasCachedSuggestionsFor(searchText)) + if (m_activeEngine->hasCachedSuggestionsFor(searchText)) { emit suggestionsReceived(searchText, m_activeEngine->cachedSuggestionsFor(searchText)); } @@ -172,14 +172,14 @@ void OpenSearchManager::dataReceived(KIO::Job *job, const QByteArray &data) void OpenSearchManager::jobFinished(KJob *job) { // Do NOT parse if job had same errors or the typed string is empty - if(job->error() || _typedText.isEmpty()) + if (job->error() || _typedText.isEmpty()) { emit suggestionsReceived(_typedText, ResponseList()); m_state = IDLE; return; // just silently return } - if(m_state == REQ_SUGGESTION) + if (m_state == REQ_SUGGESTION) { const ResponseList suggestionsList = m_activeEngine->parseSuggestion(_typedText, m_jobData); Q_FOREACH(const Response & r, suggestionsList) @@ -191,18 +191,18 @@ void OpenSearchManager::jobFinished(KJob *job) return; } - if(m_state == REQ_DESCRIPTION) + if (m_state == REQ_DESCRIPTION) { OpenSearchReader reader; OpenSearchEngine *engine = reader.read(m_jobData); - if(engine) + if (engine) { m_engineCache.insert(engine->name(), engine); m_engines.insert(m_jobUrl, trimmedEngineName(engine->name())); saveEngines(); QString path; - if(engine->providesSuggestions()) //save opensearch description only if it provides suggestions + if (engine->providesSuggestions()) //save opensearch description only if it provides suggestions { OpenSearchWriter writer; path = KGlobal::dirs()->findResource("data", "rekonq/opensearch/"); @@ -246,14 +246,14 @@ void OpenSearchManager::jobFinished(KJob *job) void OpenSearchManager::loadEngines() { QFile file(KStandardDirs::locate("appdata", "opensearch/db_opensearch.json")); - if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { return; } QString fileContent = QString::fromUtf8(file.readAll()); QScriptEngine reader; - if(!reader.canEvaluate(fileContent)) + if (!reader.canEvaluate(fileContent)) { return; } @@ -274,7 +274,7 @@ void OpenSearchManager::loadEngines() void OpenSearchManager::saveEngines() { QFile file(KStandardDirs::locateLocal("appdata", "opensearch/db_opensearch.json")); - if(!file.open(QIODevice::WriteOnly)) + if (!file.open(QIODevice::WriteOnly)) { return; } @@ -286,7 +286,7 @@ void OpenSearchManager::saveEngines() { out << "[\"" << url.url() << "\",\"" << m_engines.value(url) << "\"]"; i++; - if(i != urls.size()) + if (i != urls.size()) { out << ",\n"; } @@ -302,7 +302,7 @@ void OpenSearchManager::removeDeletedEngines() Q_FOREACH(const KUrl & url, m_engines.keys()) { service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(m_engines.value(url))); - if(!service) + if (!service) { QString path = KStandardDirs::locateLocal("appdata", "opensearch/" + trimmedEngineName(m_engines.value(url)) + ".xml"); QFile::remove(path + trimmedEngineName(m_engines.value(url)) + ".xml"); @@ -323,15 +323,15 @@ QString OpenSearchManager::trimmedEngineName(const QString &engineName) const { QString trimmed; QString::ConstIterator constIter = engineName.constBegin(); - while(constIter != engineName.constEnd()) + while (constIter != engineName.constEnd()) { - if(constIter->isSpace()) + if (constIter->isSpace()) { trimmed.append('_'); } else { - if(*constIter != '.') + if (*constIter != '.') { trimmed.append(constIter->toLower()); } @@ -345,7 +345,7 @@ QString OpenSearchManager::trimmedEngineName(const QString &engineName) const void OpenSearchManager::idleJob() { - if(m_currentJob) + if (m_currentJob) { disconnect(m_currentJob); m_currentJob->kill(); diff --git a/src/opensearch/opensearchreader.cpp b/src/opensearch/opensearchreader.cpp index a789c413..c2bf0f09 100644 --- a/src/opensearch/opensearchreader.cpp +++ b/src/opensearch/opensearchreader.cpp @@ -60,7 +60,7 @@ OpenSearchEngine *OpenSearchReader::read(QIODevice *device) { clear(); - if(!device->isOpen()) + if (!device->isOpen()) { device->open(QIODevice::ReadOnly); } @@ -74,56 +74,56 @@ OpenSearchEngine *OpenSearchReader::read() { OpenSearchEngine *engine = new OpenSearchEngine(); - while(!isStartElement() && !atEnd()) + while (!isStartElement() && !atEnd()) { readNext(); } - if(name() != QL1S("OpenSearchDescription") + if (name() != QL1S("OpenSearchDescription") || namespaceUri() != QL1S("http://a9.com/-/spec/opensearch/1.1/") - ) + ) { raiseError(i18n("The file is not an OpenSearch 1.1 file.")); return engine; } - while(!(isEndElement() && name() == QL1S("OpenSearchDescription")) && !atEnd()) + while (!(isEndElement() && name() == QL1S("OpenSearchDescription")) && !atEnd()) { readNext(); - if(!isStartElement()) + if (!isStartElement()) continue; // ShortName - if(name() == QL1S("ShortName")) + if (name() == QL1S("ShortName")) { engine->setName(readElementText()); continue; } // Description - if(name() == QL1S("Description")) + if (name() == QL1S("Description")) { engine->setDescription(readElementText()); continue; } // Url - if(name() == QL1S("Url")) + if (name() == QL1S("Url")) { QString type = attributes().value(QL1S("type")).toString(); QString url = attributes().value(QL1S("template")).toString(); - if(url.isEmpty()) + if (url.isEmpty()) continue; QList<OpenSearchEngine::Parameter> parameters; readNext(); - while(!(isEndElement() && name() == QL1S("Url"))) + while (!(isEndElement() && name() == QL1S("Url"))) { - if(!isStartElement() + if (!isStartElement() || (name() != QL1S("Param") && name() != QL1S("Parameter"))) { @@ -134,32 +134,32 @@ OpenSearchEngine *OpenSearchReader::read() QString key = attributes().value(QL1S("name")).toString(); QString value = attributes().value(QL1S("value")).toString(); - if(!key.isEmpty() && !value.isEmpty()) + if (!key.isEmpty() && !value.isEmpty()) { parameters.append(OpenSearchEngine::Parameter(key, value)); } - while(!isEndElement()) + while (!isEndElement()) { readNext(); } } - if(type == QL1S("text/html")) + if (type == QL1S("text/html")) { engine->setSearchUrlTemplate(url); engine->setSearchParameters(parameters); } else { - if(engine->suggestionsUrlTemplate().isEmpty() + if (engine->suggestionsUrlTemplate().isEmpty() && type == QL1S("application/x-suggestions+json")) //note: xml is preferred { engine->setSuggestionsUrlTemplate(url); engine->setSuggestionsParameters(parameters); engine->setSuggestionParser(new JSONParser()); } - else if(type == QL1S("application/x-suggestions+xml")) + else if (type == QL1S("application/x-suggestions+xml")) { engine->setSuggestionsUrlTemplate(url); engine->setSuggestionsParameters(parameters); @@ -171,19 +171,19 @@ OpenSearchEngine *OpenSearchReader::read() } // Image - if(name() == QL1S("Image")) + if (name() == QL1S("Image")) { engine->setImageUrl(readElementText()); continue; } // Engine check - if(!engine->name().isEmpty() + if (!engine->name().isEmpty() && !engine->description().isEmpty() && !engine->suggestionsUrlTemplate().isEmpty() && !engine->searchUrlTemplate().isEmpty() && !engine->imageUrl().isEmpty() - ) + ) { break; } diff --git a/src/opensearch/opensearchwriter.cpp b/src/opensearch/opensearchwriter.cpp index d6a34f54..0b50ca6a 100644 --- a/src/opensearch/opensearchwriter.cpp +++ b/src/opensearch/opensearchwriter.cpp @@ -45,10 +45,10 @@ OpenSearchWriter::OpenSearchWriter() bool OpenSearchWriter::write(QIODevice *device, OpenSearchEngine *engine) { - if(!engine) + if (!engine) return false; - if(!device->isOpen()) + if (!device->isOpen()) device->open(QIODevice::WriteOnly); setDevice(device); @@ -63,29 +63,29 @@ void OpenSearchWriter::write(OpenSearchEngine *engine) writeStartElement(QL1S("OpenSearchDescription")); writeDefaultNamespace(QL1S("http://a9.com/-/spec/opensearch/1.1/")); - if(!engine->name().isEmpty()) + if (!engine->name().isEmpty()) { writeTextElement(QL1S("ShortName"), engine->name()); } - if(!engine->description().isEmpty()) + if (!engine->description().isEmpty()) { writeTextElement(QL1S("Description"), engine->description()); } - if(!engine->searchUrlTemplate().isEmpty()) + if (!engine->searchUrlTemplate().isEmpty()) { writeStartElement(QL1S("Url")); writeAttribute(QL1S("method"), QL1S("get")); writeAttribute(QL1S("template"), engine->searchUrlTemplate()); - if(!engine->searchParameters().empty()) + if (!engine->searchParameters().empty()) { writeNamespace(QL1S("http://a9.com/-/spec/opensearch/extensions/parameters/1.0/"), QL1S("p")); QList<OpenSearchEngine::Parameter>::const_iterator end = engine->searchParameters().constEnd(); QList<OpenSearchEngine::Parameter>::const_iterator i = engine->searchParameters().constBegin(); - for(; i != end; ++i) + for (; i != end; ++i) { writeStartElement(QL1S("p:Parameter")); writeAttribute(QL1S("name"), i->first); @@ -97,20 +97,20 @@ void OpenSearchWriter::write(OpenSearchEngine *engine) writeEndElement(); } - if(!engine->suggestionsUrlTemplate().isEmpty()) + if (!engine->suggestionsUrlTemplate().isEmpty()) { writeStartElement(QL1S("Url")); writeAttribute(QL1S("method"), QL1S("get")); writeAttribute(QL1S("type"), engine->type()); writeAttribute(QL1S("template"), engine->suggestionsUrlTemplate()); - if(!engine->suggestionsParameters().empty()) + if (!engine->suggestionsParameters().empty()) { writeNamespace(QL1S("http://a9.com/-/spec/opensearch/extensions/parameters/1.0/"), QL1S("p")); QList<OpenSearchEngine::Parameter>::const_iterator end = engine->suggestionsParameters().constEnd(); QList<OpenSearchEngine::Parameter>::const_iterator i = engine->suggestionsParameters().constBegin(); - for(; i != end; ++i) + for (; i != end; ++i) { writeStartElement(QL1S("p:Parameter")); writeAttribute(QL1S("name"), i->first); @@ -122,7 +122,7 @@ void OpenSearchWriter::write(OpenSearchEngine *engine) writeEndElement(); } - if(!engine->imageUrl().isEmpty()) + if (!engine->imageUrl().isEmpty()) writeTextElement(QL1S("Image"), engine->imageUrl()); writeEndElement(); diff --git a/src/opensearch/searchengine.cpp b/src/opensearch/searchengine.cpp index 224a8d56..b54d9434 100644 --- a/src/opensearch/searchengine.cpp +++ b/src/opensearch/searchengine.cpp @@ -64,7 +64,7 @@ void SearchEngine::reload() Q_FOREACH(const QString & engine, favoriteEngines) { service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(engine)); - if(service) + if (service) { QUrl url = service->property("Query").toUrl(); rApp->iconManager()->downloadIconFromUrl(url); @@ -84,7 +84,7 @@ void SearchEngine::reload() QString SearchEngine::delimiter() { - if(!d->isLoaded) + if (!d->isLoaded) reload(); return d->delimiter; @@ -93,7 +93,7 @@ QString SearchEngine::delimiter() KService::List SearchEngine::favorites() { - if(!d->isLoaded) + if (!d->isLoaded) reload(); return d->favorites; @@ -102,7 +102,7 @@ KService::List SearchEngine::favorites() KService::Ptr SearchEngine::defaultEngine() { - if(!d->isLoaded) + if (!d->isLoaded) reload(); return d->defaultEngine; @@ -115,13 +115,13 @@ KService::Ptr SearchEngine::fromString(const QString &text) int i = 0; bool found = false; KService::Ptr service; - while(!found && i < providers.size()) + while (!found && i < providers.size()) { QStringList list = providers.at(i)->property("Keys").toStringList(); Q_FOREACH(const QString & key, list) { const QString searchPrefix = key + delimiter(); - if(text.startsWith(searchPrefix)) + if (text.startsWith(searchPrefix)) { service = providers.at(i); found = true; @@ -136,7 +136,7 @@ KService::Ptr SearchEngine::fromString(const QString &text) QString SearchEngine::buildQuery(KService::Ptr engine, const QString &text) { - if(!engine) + if (!engine) return QString(); QString query = engine->property("Query").toString(); query = query.replace("\\{@}", KUrl::toPercentEncoding(text)); diff --git a/src/opensearch/suggestionparser.cpp b/src/opensearch/suggestionparser.cpp index 6b467353..3c5350bf 100644 --- a/src/opensearch/suggestionparser.cpp +++ b/src/opensearch/suggestionparser.cpp @@ -51,14 +51,14 @@ ResponseList XMLParser::parse(const QByteArray &resp) m_reader.clear(); m_reader.addData(resp); - while(!m_reader.atEnd() && !m_reader.hasError()) + while (!m_reader.atEnd() && !m_reader.hasError()) { m_reader.readNext(); - if(m_reader.isStartDocument()) + if (m_reader.isStartDocument()) continue; - if(m_reader.isStartElement() && m_reader.name() == QL1S("Item")) + if (m_reader.isStartElement() && m_reader.name() == QL1S("Item")) { QString title; QString description; @@ -69,24 +69,24 @@ ResponseList XMLParser::parse(const QByteArray &resp) m_reader.readNext(); - while(!(m_reader.isEndElement() && m_reader.name() == QL1S("Item"))) + while (!(m_reader.isEndElement() && m_reader.name() == QL1S("Item"))) { - if(m_reader.isStartElement()) + if (m_reader.isStartElement()) { - if(m_reader.name() == QL1S("Text")) + if (m_reader.name() == QL1S("Text")) title = m_reader.readElementText(); - if(m_reader.name() == QL1S("Url")) + if (m_reader.name() == QL1S("Url")) url = m_reader.readElementText(); - if(m_reader.name() == QL1S("Image")) + if (m_reader.name() == QL1S("Image")) { image = m_reader.attributes().value("source").toString(); image_width = m_reader.attributes().value("width").toString().toInt(); image_height = m_reader.attributes().value("height").toString().toInt(); } - if(m_reader.name() == QL1S("Description")) + if (m_reader.name() == QL1S("Description")) description = m_reader.readElementText(); } @@ -105,22 +105,22 @@ ResponseList JSONParser::parse(const QByteArray &resp) QString response = QString::fromLocal8Bit(resp); response = response.trimmed(); - if(response.isEmpty()) + if (response.isEmpty()) { // RESPONSE IS EMPTY return ResponseList(); } - if(!response.startsWith(QL1C('[')) + if (!response.startsWith(QL1C('[')) || !response.endsWith(QL1C(']')) - ) + ) { // RESPONSE is NOT well FORMED return ResponseList(); } // Evaluate the JSON response using QtScript. - if(!m_reader.canEvaluate(response)) + if (!m_reader.canEvaluate(response)) { // m_reader cannot evaluate the response return ResponseList(); @@ -128,7 +128,7 @@ ResponseList JSONParser::parse(const QByteArray &resp) QScriptValue responseParts = m_reader.evaluate(response); - if(!responseParts.property(1).isArray()) + if (!responseParts.property(1).isArray()) { // RESPONSE is not an array return ResponseList(); diff --git a/src/paneltreeview.cpp b/src/paneltreeview.cpp index 1c727d78..d183035a 100644 --- a/src/paneltreeview.cpp +++ b/src/paneltreeview.cpp @@ -58,22 +58,22 @@ void PanelTreeView::mousePressEvent(QMouseEvent *event) // A change of an item expansion is handle by mouseReleaseEvent() // So toggle again the item - if(expanded != isExpanded(index)) + if (expanded != isExpanded(index)) setExpanded(index, !isExpanded(index)); - if(!index.isValid()) + if (!index.isValid()) { clearSelection(); setCurrentIndex(QModelIndex()); - if(event->button() == Qt::RightButton) + if (event->button() == Qt::RightButton) emit contextMenuEmptyRequested(event->pos()); return; } - if(event->button() == Qt::RightButton) + if (event->button() == Qt::RightButton) { - if(model()->rowCount(index) == 0) + if (model()->rowCount(index) == 0) { // An empty group needs to be handle by the panels emit contextMenuItemRequested(event->pos()); @@ -91,15 +91,15 @@ void PanelTreeView::mouseReleaseEvent(QMouseEvent *event) QTreeView::mouseReleaseEvent(event); const QModelIndex index = indexAt(event->pos()); - if(!index.isValid()) + if (!index.isValid()) return; - if(event->button() == Qt::MidButton || event->modifiers() == Qt::ControlModifier) + if (event->button() == Qt::MidButton || event->modifiers() == Qt::ControlModifier) emit openUrl(qVariantValue< KUrl >(index.data(Qt::UserRole)), Rekonq::NewTab); - else if(event->button() == Qt::LeftButton) + else if (event->button() == Qt::LeftButton) { - if(model()->rowCount(index) == 0) + if (model()->rowCount(index) == 0) emit openUrl(qVariantValue< KUrl >(index.data(Qt::UserRole))); else setExpanded(index, !isExpanded(index)); @@ -112,18 +112,18 @@ void PanelTreeView::keyPressEvent(QKeyEvent *event) QTreeView::keyPressEvent(event); QModelIndex index = currentIndex(); - if(!index.isValid()) + if (!index.isValid()) return; - if(event->key() == Qt::Key_Return) + if (event->key() == Qt::Key_Return) { - if(model()->rowCount(index) == 0) + if (model()->rowCount(index) == 0) openUrl(qVariantValue< KUrl >(index.data(Qt::UserRole))); else setExpanded(index, !isExpanded(index)); } - else if(event->key() == Qt::Key_Delete) + else if (event->key() == Qt::Key_Delete) { emit delKeyPressed(); } @@ -134,7 +134,7 @@ void PanelTreeView::mouseMoveEvent(QMouseEvent *event) { QTreeView::mouseMoveEvent(event); const QModelIndex index = indexAt(event->pos()); - if(!index.isValid()) + if (!index.isValid()) { emit itemHovered(""); return; @@ -146,7 +146,7 @@ void PanelTreeView::mouseMoveEvent(QMouseEvent *event) void PanelTreeView::openInCurrentTab() { QModelIndex index = currentIndex(); - if(!index.isValid()) + if (!index.isValid()) return; emit openUrl(qVariantValue< KUrl >(index.data(Qt::UserRole))); @@ -156,7 +156,7 @@ void PanelTreeView::openInCurrentTab() void PanelTreeView::copyToClipboard() { QModelIndex index = currentIndex(); - if(!index.isValid()) + if (!index.isValid()) return; QClipboard *cb = QApplication::clipboard(); @@ -167,7 +167,7 @@ void PanelTreeView::copyToClipboard() void PanelTreeView::openInNewTab() { QModelIndex index = currentIndex(); - if(!index.isValid()) + if (!index.isValid()) return; emit openUrl(qVariantValue< KUrl >(index.data(Qt::UserRole)), Rekonq::NewTab); @@ -177,7 +177,7 @@ void PanelTreeView::openInNewTab() void PanelTreeView::openInNewWindow() { QModelIndex index = currentIndex(); - if(!index.isValid()) + if (!index.isValid()) return; emit openUrl(qVariantValue< KUrl >(index.data(Qt::UserRole)), Rekonq::NewWindow); diff --git a/src/previewselectorbar.cpp b/src/previewselectorbar.cpp index b242846d..8eecffb9 100644 --- a/src/previewselectorbar.cpp +++ b/src/previewselectorbar.cpp @@ -73,7 +73,7 @@ PreviewSelectorBar::PreviewSelectorBar(int index, QWidget* parent) void PreviewSelectorBar::verifyUrl() { - if(rApp->mainWindow()->currentTab()->page()->mainFrame()->url().scheme() != "about") + if (rApp->mainWindow()->currentTab()->page()->mainFrame()->url().scheme() != "about") { m_insertAction->setEnabled(true); m_insertAction->setToolTip(""); @@ -106,7 +106,7 @@ void PreviewSelectorBar::clicked() { WebPage *page = rApp->mainWindow()->currentTab()->page(); - if(page) + if (page) { KUrl url = page->mainFrame()->url(); QStringList names = ReKonfig::previewNames(); diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index 93f7bc37..2af4214f 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -70,7 +70,7 @@ static KFileItemList sortFileList(const KFileItemList &list) // order dirs before files.. Q_FOREACH(const KFileItem & item, list) { - if(item.isDir()) + if (item.isDir()) dirList << item; else fileList << item; @@ -102,10 +102,10 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra _frame = frame; // javascript handling - if(_url.protocol() == QL1S("javascript")) + if (_url.protocol() == QL1S("javascript")) { QString scriptSource = _url.authority(); - if(scriptSource.isEmpty()) + if (scriptSource.isEmpty()) { // if javascript:<code here> then authority() returns // an empty string. Extract the source manually @@ -115,7 +115,7 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra // fromPercentEncoding() is used to decode all the % encoded // characters to normal, so that it is treated as valid javascript scriptSource = QUrl::fromPercentEncoding(_url.url().mid(11).toAscii()); - if(scriptSource.isEmpty()) + if (scriptSource.isEmpty()) return false; } @@ -124,25 +124,25 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra } // "abp" handling - if(_url.protocol() == QL1S("abp")) + if (_url.protocol() == QL1S("abp")) { abpHandling(); return true; } // "about" handling - if(_url.protocol() == QL1S("about")) + if (_url.protocol() == QL1S("about")) { QByteArray encodedUrl = _url.toEncoded(); // let webkit manage the about:blank url... - if(encodedUrl == QByteArray("about:blank")) + if (encodedUrl == QByteArray("about:blank")) { return false; } - if(encodedUrl == QByteArray("about:home")) + if (encodedUrl == QByteArray("about:home")) { - switch(ReKonfig::newTabStartPage()) + switch (ReKonfig::newTabStartPage()) { case 0: // favorites _url = KUrl("about:favorites"); @@ -173,7 +173,7 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra } // let webkit try to load a known (or missing) protocol... - if(KProtocolInfo::isKnownProtocol(_url)) + if (KProtocolInfo::isKnownProtocol(_url)) return false; // Error Message, for those protocols we cannot handle @@ -189,12 +189,12 @@ bool ProtocolHandler::postHandling(const QNetworkRequest &request, QWebFrame *fr _frame = frame; // "http(s)" (fast) handling - if(_url.protocol() == QL1S("http") || _url.protocol() == QL1S("https")) + if (_url.protocol() == QL1S("http") || _url.protocol() == QL1S("https")) return false; // "mailto" handling: It needs to be handled both here(mail links clicked) // and in prehandling (mail url launched) - if(_url.protocol() == QL1S("mailto")) + if (_url.protocol() == QL1S("mailto")) { KToolInvocation::invokeMailer(_url); return true; @@ -205,7 +205,7 @@ bool ProtocolHandler::postHandling(const QNetworkRequest &request, QWebFrame *fr // My idea is: webkit cannot handle in any way ftp. So we have surely to return true here. // We start trying to guess what the url represent: it's a dir? show its contents (and download them). // it's a file? download it. It's another thing? beat me, but I don't know what to do... - if(_url.protocol() == QL1S("ftp")) + if (_url.protocol() == QL1S("ftp")) { KIO::StatJob *job = KIO::stat(_url); connect(job, SIGNAL(result(KJob*)), this, SLOT(slotMostLocalUrlResult(KJob*))); @@ -213,10 +213,10 @@ bool ProtocolHandler::postHandling(const QNetworkRequest &request, QWebFrame *fr } // "file" handling. This is quite trivial :) - if(_url.protocol() == QL1S("file")) + if (_url.protocol() == QL1S("file")) { QFileInfo fileInfo(_url.path()); - if(fileInfo.isDir()) + if (fileInfo.isDir()) { connect(_lister, SIGNAL(newItems(const KFileItemList &)), this, SLOT(showResults(const KFileItemList &))); _lister->openUrl(_url); @@ -227,7 +227,7 @@ bool ProtocolHandler::postHandling(const QNetworkRequest &request, QWebFrame *fr // we cannot handle this protocol in any way. // Try KRunning it... - if(KProtocolInfo::isKnownProtocol(_url)) + if (KProtocolInfo::isKnownProtocol(_url)) { (void)new KRun(_url, rApp->mainWindow(), 0, _url.isLocalFile()); return true; @@ -242,7 +242,7 @@ bool ProtocolHandler::postHandling(const QNetworkRequest &request, QWebFrame *fr void ProtocolHandler::showResults(const KFileItemList &list) { - if(!_lister->rootItem().isNull() && _lister->rootItem().isReadable() && _lister->rootItem().isFile()) + if (!_lister->rootItem().isNull() && _lister->rootItem().isReadable() && _lister->rootItem().isFile()) { emit downloadUrl(_lister->rootItem().url()); } @@ -261,7 +261,7 @@ void ProtocolHandler::showResults(const KFileItemList &list) QString ProtocolHandler::dirHandling(const KFileItemList &list) { - if(!_lister) + if (!_lister) { return QString("rekonq error, sorry :("); } @@ -274,7 +274,7 @@ QString ProtocolHandler::dirHandling(const KFileItemList &list) QFile file(infoFilePath); bool isOpened = file.open(QIODevice::ReadOnly); - if(!isOpened) + if (!isOpened) { return QString("rekonq error, sorry :("); } @@ -283,7 +283,7 @@ QString ProtocolHandler::dirHandling(const KFileItemList &list) QString msg = i18nc("%1=an URL", "<h1>Index of %1</h1>", _url.prettyUrl()); - if(rootUrl.cd("..")) + if (rootUrl.cd("..")) { QString path = rootUrl.prettyUrl(); QString uparrow = KIconLoader::global()->iconPath("arrow-up", KIconLoader::Small); @@ -309,7 +309,7 @@ QString ProtocolHandler::dirHandling(const KFileItemList &list) msg += "</td>"; msg += "<td align=\"right\">"; - if(item.isFile()) + if (item.isFile()) { msg += KGlobal::locale()->formatByteSize(item.size(), 1); } @@ -335,7 +335,7 @@ QString ProtocolHandler::dirHandling(const KFileItemList &list) void ProtocolHandler::slotMostLocalUrlResult(KJob *job) { - if(job->error()) + if (job->error()) { // TODO } @@ -343,7 +343,7 @@ void ProtocolHandler::slotMostLocalUrlResult(KJob *job) { KIO::StatJob *statJob = static_cast<KIO::StatJob*>(job); KIO::UDSEntry entry = statJob->statResult(); - if(entry.isDir()) + if (entry.isDir()) { connect(_lister, SIGNAL(newItems(const KFileItemList &)), this, SLOT(showResults(const KFileItemList &))); _lister->openUrl(_url); @@ -363,7 +363,7 @@ void ProtocolHandler::slotMostLocalUrlResult(KJob *job) void ProtocolHandler::abpHandling() { QString path = _url.path(); - if(path != QL1S("subscribe")) + if (path != QL1S("subscribe")) return; QMap<QString, QString> map = _url.queryItems(KUrl::CaseInsensitiveKeys); @@ -374,7 +374,7 @@ void ProtocolHandler::abpHandling() QString requirestitle = map.value(QL1S("requirestitle")); QString info; - if(requirestitle.isEmpty() || requireslocation.isEmpty()) + if (requirestitle.isEmpty() || requireslocation.isEmpty()) { info = title; } @@ -383,15 +383,15 @@ void ProtocolHandler::abpHandling() info = i18n("\n %1,\n %2 (required by %3)\n", title, requirestitle, title); } - if(KMessageBox::questionYesNo(0, - i18n("Do you want to add the following subscriptions to your adblock settings?\n") + info, - i18n("Add automatic subscription to the adblock"), - KGuiItem(i18n("Add")), - KGuiItem(i18n("Discard")) - ) - ) + if (KMessageBox::questionYesNo(0, + i18n("Do you want to add the following subscriptions to your adblock settings?\n") + info, + i18n("Add automatic subscription to the adblock"), + KGuiItem(i18n("Add")), + KGuiItem(i18n("Discard")) + ) + ) { - if(!requireslocation.isEmpty() && !requirestitle.isEmpty()) + if (!requireslocation.isEmpty() && !requirestitle.isEmpty()) { rApp->adblockManager()->addSubscription(requirestitle, requireslocation); } diff --git a/src/sessionmanager.cpp b/src/sessionmanager.cpp index 0cd036ec..d6889cff 100644 --- a/src/sessionmanager.cpp +++ b/src/sessionmanager.cpp @@ -54,13 +54,13 @@ SessionManager::SessionManager(QObject *parent) void SessionManager::saveSession() { - if(!m_safe || QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) + if (!m_safe || QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) return; m_safe = false; QFile sessionFile(m_sessionFilePath); - if(!sessionFile.open(QFile::WriteOnly | QFile::Truncate)) + if (!sessionFile.open(QFile::WriteOnly | QFile::Truncate)) { kDebug() << "Unable to open session file" << sessionFile.fileName(); return; @@ -71,7 +71,7 @@ void SessionManager::saveSession() { out << "window\n"; MainView *mv = w.data()->mainView(); - for(int i = 0 ; i < mv->count() ; i++) + for (int i = 0 ; i < mv->count() ; i++) { out << mv->webTab(i)->url().toEncoded() << "\n"; } @@ -89,9 +89,9 @@ void SessionManager::saveSession() bool SessionManager::restoreSession() { QFile sessionFile(m_sessionFilePath); - if(!sessionFile.exists()) + if (!sessionFile.exists()) return false; - if(!sessionFile.open(QFile::ReadOnly)) + if (!sessionFile.open(QFile::ReadOnly)) { kDebug() << "Unable to open session file" << sessionFile.fileName(); return false; @@ -103,10 +103,10 @@ bool SessionManager::restoreSession() do { line = in.readLine(); - if(line == QL1S("window")) + if (line == QL1S("window")) { line = in.readLine(); - if(windowAlreadyOpen) + if (windowAlreadyOpen) { rApp->loadUrl(KUrl(line), Rekonq::CurrentTab); windowAlreadyOpen = false; @@ -118,16 +118,16 @@ bool SessionManager::restoreSession() } else { - if(line == QL1S("currenttab")) + if (line == QL1S("currenttab")) { line = in.readLine(); bool ok; int idx = line.toInt(&ok); - if(ok) + if (ok) { // Get last mainwindow created which will be first one in mainwindow list MainWindowList wl = rApp->mainWindowList(); - if(wl.count() > 0) + if (wl.count() > 0) { MainView *mv = wl[0].data()->mainView(); emit mv->tabBar()->setCurrentIndex(idx); @@ -140,7 +140,7 @@ bool SessionManager::restoreSession() } } } - while(!line.isEmpty()); + while (!line.isEmpty()); return true; } @@ -151,9 +151,9 @@ QStringList SessionManager::closedSites() QStringList list; QFile sessionFile(m_sessionFilePath); - if(!sessionFile.exists()) + if (!sessionFile.exists()) return list; - if(!sessionFile.open(QFile::ReadOnly)) + if (!sessionFile.open(QFile::ReadOnly)) { kDebug() << "Unable to open session file" << sessionFile.fileName(); return list; @@ -164,9 +164,9 @@ QStringList SessionManager::closedSites() do { line = in.readLine(); - if(line != QL1S("window")) + if (line != QL1S("window")) { - if(line == QL1S("currenttab")) + if (line == QL1S("currenttab")) { in.readLine(); // drop out the next field, containing the index of the current tab.. } @@ -176,7 +176,7 @@ QStringList SessionManager::closedSites() } } } - while(!line.isEmpty()); + while (!line.isEmpty()); return list; } diff --git a/src/settings/adblockwidget.cpp b/src/settings/adblockwidget.cpp index 12a18fc0..ad8bd599 100644 --- a/src/settings/adblockwidget.cpp +++ b/src/settings/adblockwidget.cpp @@ -92,7 +92,7 @@ void AdBlockWidget::slotInfoLinkActivated(const QString &url) void AdBlockWidget::insertRule() { QString rule = addFilterLineEdit->text(); - if(rule.isEmpty()) + if (rule.isEmpty()) return; listWidget->addItem(rule); @@ -168,7 +168,7 @@ void AdBlockWidget::save() QStringList localRules; n = listWidget->count(); - for(int i = 0; i < n; ++i) + for (int i = 0; i < n; ++i) { QListWidgetItem *item = listWidget->item(i); localRules << item->text(); diff --git a/src/settings/generalwidget.cpp b/src/settings/generalwidget.cpp index 98d0d708..42f1f921 100644 --- a/src/settings/generalwidget.cpp +++ b/src/settings/generalwidget.cpp @@ -54,7 +54,7 @@ GeneralWidget::GeneralWidget(QWidget *parent) checkKGetPresence(); KConfigGroup cg = KConfigGroup(KSharedConfig::openConfig("kioslaverc", KConfig::NoGlobals), QString()); - doNotTrackCheckBox->setChecked( cg.readEntry("DoNotTrack", false) ); + doNotTrackCheckBox->setChecked(cg.readEntry("DoNotTrack", false)); connect(doNotTrackCheckBox, SIGNAL(clicked()), this, SLOT(hasChanged())); } @@ -85,7 +85,7 @@ void GeneralWidget::setHomeToCurrentPage() { MainWindow *mw = rApp->mainWindow(); WebTab *webTab = mw->currentTab(); - if(webTab) + if (webTab) { kcfg_homePage->setText(webTab->url().prettyUrl()); } @@ -101,7 +101,7 @@ void GeneralWidget::disableHomeSettings(bool b) void GeneralWidget::checkKGetPresence() { - if(KStandardDirs::findExe("kget").isNull()) + if (KStandardDirs::findExe("kget").isNull()) { kcfg_kgetDownload->setDisabled(true); kcfg_kgetList->setDisabled(true); diff --git a/src/settings/settingsdialog.cpp b/src/settings/settingsdialog.cpp index 8afb61d7..a8d5f5b0 100644 --- a/src/settings/settingsdialog.cpp +++ b/src/settings/settingsdialog.cpp @@ -132,7 +132,7 @@ Private::Private(SettingsDialog *parent) ebrowsingModule = new KCModuleProxy(ebrowsingInfo, parent); pageItem = parent->addPage(ebrowsingModule, i18n("Search Engines")); KIcon wsIcon("edit-web-search"); - if(wsIcon.isNull()) + if (wsIcon.isNull()) { wsIcon = KIcon("preferences-web-browser-shortcuts"); } @@ -189,7 +189,7 @@ void SettingsDialog::readConfig() // we need this function to SAVE settings in rc file.. void SettingsDialog::saveSettings() { - if(!hasChanged()) + if (!hasChanged()) return; ReKonfig::self()->writeConfig(); @@ -230,7 +230,7 @@ bool SettingsDialog::isDefault() { bool isDef = KConfigDialog::isDefault(); - if(isDef) + if (isDef) { // check our private widget values isDef = d->appearanceWidg->isDefault(); diff --git a/src/sslinfodialog.cpp b/src/sslinfodialog.cpp index 2bdf1425..f4c7d871 100644 --- a/src/sslinfodialog.cpp +++ b/src/sslinfodialog.cpp @@ -86,20 +86,20 @@ void SslInfoDialog::showCertificateInfo(QSslCertificate subjectCert, const QStri c += QL1S("</ul>"); ui.certInfoLabel->setText(c); - ui.subjectCN->setText( Qt::escape(subjectCert.subjectInfo(QSslCertificate::CommonName)) ); - ui.subjectO->setText( Qt::escape(subjectCert.subjectInfo(QSslCertificate::Organization)) ); - ui.subjectOU->setText( Qt::escape(subjectCert.subjectInfo(QSslCertificate::OrganizationalUnitName)) ); - ui.subjectSN->setText( Qt::escape(subjectCert.serialNumber()) ); + ui.subjectCN->setText(Qt::escape(subjectCert.subjectInfo(QSslCertificate::CommonName))); + ui.subjectO->setText(Qt::escape(subjectCert.subjectInfo(QSslCertificate::Organization))); + ui.subjectOU->setText(Qt::escape(subjectCert.subjectInfo(QSslCertificate::OrganizationalUnitName))); + ui.subjectSN->setText(Qt::escape(subjectCert.serialNumber())); - ui.issuerCN->setText( Qt::escape(subjectCert.issuerInfo(QSslCertificate::CommonName)) ); - ui.issuerO->setText( Qt::escape(subjectCert.issuerInfo(QSslCertificate::Organization)) ); - ui.issuerOU->setText( Qt::escape(subjectCert.issuerInfo(QSslCertificate::OrganizationalUnitName)) ); + ui.issuerCN->setText(Qt::escape(subjectCert.issuerInfo(QSslCertificate::CommonName))); + ui.issuerO->setText(Qt::escape(subjectCert.issuerInfo(QSslCertificate::Organization))); + ui.issuerOU->setText(Qt::escape(subjectCert.issuerInfo(QSslCertificate::OrganizationalUnitName))); - ui.issuedOn->setText( Qt::escape(subjectCert.effectiveDate().date().toString(Qt::SystemLocaleShortDate)) ); - ui.expiresOn->setText( Qt::escape(subjectCert.expiryDate().date().toString(Qt::SystemLocaleShortDate)) ); + ui.issuedOn->setText(Qt::escape(subjectCert.effectiveDate().date().toString(Qt::SystemLocaleShortDate))); + ui.expiresOn->setText(Qt::escape(subjectCert.expiryDate().date().toString(Qt::SystemLocaleShortDate))); - ui.md5->setText( Qt::escape(subjectCert.digest(QCryptographicHash::Md5).toHex()) ); - ui.sha1->setText( Qt::escape(subjectCert.digest(QCryptographicHash::Sha1).toHex()) ); + ui.md5->setText(Qt::escape(subjectCert.digest(QCryptographicHash::Md5).toHex())); + ui.sha1->setText(Qt::escape(subjectCert.digest(QCryptographicHash::Sha1).toHex())); } @@ -110,7 +110,7 @@ void SslInfoDialog::displayFromChain(int i) QStringList errors = SslInfoDialog::errorsFromString(m_info.certificateErrors()).at(i); - if(cert.isValid() && errors.isEmpty()) + if (cert.isValid() && errors.isEmpty()) { QStringList certInfo; certInfo << i18n("The Certificate is Valid!"); @@ -136,7 +136,7 @@ void SslInfoDialog::exportCert() QString certPath = KFileDialog::getSaveFileName(name, QString(), this); QFile file(certPath); - if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) return; QTextStream out(&file); @@ -159,7 +159,7 @@ QList<QStringList> SslInfoDialog::errorsFromString(const QString &s) { bool didConvert; KSslError::Error error = static_cast<KSslError::Error>(s.trimmed().toInt(&didConvert)); - if(didConvert) + if (didConvert) { errors << KSslError(error).errorString(); } diff --git a/src/sslinfodialog.h b/src/sslinfodialog.h index 3544c62c..b40ce4f0 100644 --- a/src/sslinfodialog.h +++ b/src/sslinfodialog.h @@ -56,7 +56,7 @@ public: explicit SslInfoDialog(const QString &host, const WebSslInfo &info, QWidget *parent = 0); static QList<QStringList> errorsFromString(const QString &s); - + private Q_SLOTS: void displayFromChain(int); void exportCert(); diff --git a/src/tabbar.cpp b/src/tabbar.cpp index edcb3a9c..48a0ad70 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -102,13 +102,13 @@ QSize TabBar::tabSizeHint(int index) const int minWidth = view->sizeHint().width() / minWidthDivisor; int w; - if(baseWidth * count() < tabBarWidth) + if (baseWidth * count() < tabBarWidth) { w = baseWidth; } else { - if(count() > 0 && tabBarWidth / count() > minWidth) + if (count() > 0 && tabBarWidth / count() > minWidth) { w = tabBarWidth / count(); } @@ -162,7 +162,7 @@ void TabBar::detachTab() void TabBar::showTabPreview() { - if(m_isFirstTimeOnTab) + if (m_isFirstTimeOnTab) m_isFirstTimeOnTab = false; //delete previous tab preview @@ -175,11 +175,11 @@ void TabBar::showTabPreview() WebTab *currentTab = mv->webTab(currentIndex()); // check if view && currentView exist before using them :) - if(!currentTab || !indexedTab) + if (!currentTab || !indexedTab) return; // no previews during load - if(indexedTab->isPageLoading()) + if (indexedTab->isPageLoading()) return; int w = (mv->sizeHint().width() / baseWidthDivisor); @@ -189,11 +189,11 @@ void TabBar::showTabPreview() int tabBarWidth = mv->size().width(); int leftIndex = tabRect(m_currentTabPreviewIndex).x() + (tabRect(m_currentTabPreviewIndex).width() - w) / 2; - if(leftIndex < 0) + if (leftIndex < 0) { leftIndex = 0; } - else if(leftIndex + w > tabBarWidth) + else if (leftIndex + w > tabBarWidth) { leftIndex = tabBarWidth - w; } @@ -205,7 +205,7 @@ void TabBar::showTabPreview() void TabBar::hideEvent(QHideEvent *event) { - if(!event->spontaneous()) + if (!event->spontaneous()) { qobject_cast<MainView *>(parent())->addTabButton()->hide(); } @@ -216,7 +216,7 @@ void TabBar::hideEvent(QHideEvent *event) void TabBar::showEvent(QShowEvent *event) { KTabBar::showEvent(event); - if(!event->spontaneous()) + if (!event->spontaneous()) { qobject_cast<MainView *>(parent())->addTabButton()->show(); } @@ -225,24 +225,24 @@ void TabBar::showEvent(QShowEvent *event) void TabBar::mouseMoveEvent(QMouseEvent *event) { - if(count() == 1) + if (count() == 1) { return; } KTabBar::mouseMoveEvent(event); - if(ReKonfig::hoveringTabOption() == 0) + if (ReKonfig::hoveringTabOption() == 0) { //Find the tab under the mouse const int tabIndex = tabAt(event->pos()); // if found and not the current tab then show tab preview - if(tabIndex != -1 + if (tabIndex != -1 && tabIndex != currentIndex() && m_currentTabPreviewIndex != tabIndex && event->buttons() == Qt::NoButton - ) + ) { m_currentTabPreviewIndex = tabIndex; @@ -253,9 +253,9 @@ void TabBar::mouseMoveEvent(QMouseEvent *event) } // if current tab or not found then hide previous tab preview - if(tabIndex == currentIndex() || tabIndex == -1) + if (tabIndex == currentIndex() || tabIndex == -1) { - if(!m_previewPopup.isNull()) + if (!m_previewPopup.isNull()) { m_previewPopup.data()->hide(); } @@ -267,10 +267,10 @@ void TabBar::mouseMoveEvent(QMouseEvent *event) void TabBar::leaveEvent(QEvent *event) { - if(ReKonfig::hoveringTabOption() == 0) + if (ReKonfig::hoveringTabOption() == 0) { //if leave tabwidget then hide previous tab preview - if(!m_previewPopup.isNull()) + if (!m_previewPopup.isNull()) { m_previewPopup.data()->hide(); } @@ -284,9 +284,9 @@ void TabBar::leaveEvent(QEvent *event) void TabBar::mousePressEvent(QMouseEvent *event) { - if(ReKonfig::hoveringTabOption() == 0) + if (ReKonfig::hoveringTabOption() == 0) { - if(!m_previewPopup.isNull()) + if (!m_previewPopup.isNull()) { m_previewPopup.data()->hide(); } @@ -294,7 +294,7 @@ void TabBar::mousePressEvent(QMouseEvent *event) } // just close tab on middle mouse click - if(event->button() == Qt::MidButton) + if (event->button() == Qt::MidButton) return; KTabBar::mousePressEvent(event); @@ -319,7 +319,7 @@ void TabBar::contextMenu(int tab, const QPoint &pos) menu.addAction(mainWindow->actionByName(QL1S("new_tab"))); menu.addAction(mainWindow->actionByName(QL1S("clone_tab"))); - if(count() > 1) + if (count() > 1) menu.addAction(mainWindow->actionByName(QL1S("detach_tab"))); menu.addAction(mainWindow->actionByName(QL1S("open_last_closed_tab"))); menu.addAction(mainWindow->actionByName(QL1S("closed_tab_menu"))); @@ -348,7 +348,7 @@ void TabBar::emptyAreaContextMenu(const QPoint &pos) menu.addAction(mainWindow->actionByName(QL1S("reload_all_tabs"))); KToolBar *mainBar = mainWindow->toolBar("mainToolBar"); - if(!mainBar->isVisible()) + if (!mainBar->isVisible()) { menu.addAction(mainBar->toggleViewAction()); } @@ -359,16 +359,16 @@ void TabBar::emptyAreaContextMenu(const QPoint &pos) void TabBar::tabRemoved(int index) { - if(ReKonfig::hoveringTabOption() == 0) + if (ReKonfig::hoveringTabOption() == 0) { - if(!m_previewPopup.isNull()) + if (!m_previewPopup.isNull()) { m_previewPopup.data()->hide(); } m_currentTabPreviewIndex = -1; } - if(ReKonfig::animatedTabHighlighting()) + if (ReKonfig::animatedTabHighlighting()) removeAnimation(index); } @@ -383,16 +383,16 @@ void TabBar::setupHistoryActions() // update closed tabs menu KActionMenu *am = qobject_cast<KActionMenu *>(w->actionByName(QL1S("closed_tab_menu"))); - if(!am) + if (!am) return; bool isEnabled = (mv->recentlyClosedTabs().size() > 0); am->setEnabled(isEnabled); - if(am->menu()) + if (am->menu()) am->menu()->clear(); - if(!isEnabled) + if (!isEnabled) return; Q_FOREACH(const HistoryItem & item, mv->recentlyClosedTabs()) @@ -418,9 +418,9 @@ void TabBar::setTabHighlighted(int index) const QByteArray propertyName = highlightPropertyName(index); const QColor highlightColor = KColorScheme(QPalette::Active, KColorScheme::Window).foreground(KColorScheme::PositiveText).color(); - if(tabTextColor(index) != highlightColor) + if (tabTextColor(index) != highlightColor) { - if(ReKonfig::animatedTabHighlighting()) + if (ReKonfig::animatedTabHighlighting()) { m_tabHighlightEffect->setEnabled(true); m_tabHighlightEffect->setProperty(propertyName, qreal(0.9)); @@ -445,7 +445,7 @@ void TabBar::setTabHighlighted(int index) void TabBar::resetTabHighlighted(int index) { - if(ReKonfig::animatedTabHighlighting()) + if (ReKonfig::animatedTabHighlighting()) removeAnimation(index); setTabTextColor(index, palette().text().color()); @@ -461,14 +461,14 @@ void TabBar::removeAnimation(int index) m_animationMapper->removeMappings(anim); delete anim; - if(m_highlightAnimation.isEmpty()) + if (m_highlightAnimation.isEmpty()) m_tabHighlightEffect->setEnabled(false); } void TabBar::setAnimatedTabHighlighting(bool enabled) { - if(enabled) + if (enabled) m_tabHighlightEffect->setEnabled(true); else { @@ -476,7 +476,7 @@ void TabBar::setAnimatedTabHighlighting(bool enabled) //cleanup QHashIterator<QByteArray, QPropertyAnimation*> i(m_highlightAnimation); - while(i.hasNext()) + while (i.hasNext()) { i.next(); m_tabHighlightEffect->setProperty(i.key(), QVariant()); //destroy the property diff --git a/src/tabhighlighteffect.cpp b/src/tabhighlighteffect.cpp index a6441f04..b6f191d8 100644 --- a/src/tabhighlighteffect.cpp +++ b/src/tabhighlighteffect.cpp @@ -49,21 +49,21 @@ void TabHighlightEffect::draw(QPainter *painter) { const QPixmap &pixmap = sourcePixmap(); - if(pixmap.isNull()) + if (pixmap.isNull()) return; painter->drawPixmap(QPoint(0, 0), pixmap); Q_FOREACH(const QByteArray & propertyName, dynamicPropertyNames()) { - if(!propertyName.startsWith(prep)) + if (!propertyName.startsWith(prep)) continue; int index = propertyName.right(propertyName.size() - prep.size()).toInt(); qreal opacity = property(propertyName).toReal(); QRect textRect = m_tabBar->tabTextRect(index); - if(!boundingRect().contains(textRect)) + if (!boundingRect().contains(textRect)) continue; QString tabText = m_tabBar->fontMetrics().elidedText(m_tabBar->tabText(index), Qt::ElideRight, @@ -78,11 +78,11 @@ void TabHighlightEffect::draw(QPainter *painter) bool TabHighlightEffect::event(QEvent* event) { - if(event->type() == QEvent::DynamicPropertyChange) + if (event->type() == QEvent::DynamicPropertyChange) { QDynamicPropertyChangeEvent *pChangeEv = dynamic_cast<QDynamicPropertyChangeEvent*>(event); - if(pChangeEv->propertyName().startsWith(prep)) + if (pChangeEv->propertyName().startsWith(prep)) { update(); return true; 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<ListItem *>(QString::number(0))->activate(); //activate first listitem sizeAndPosition(); - if(!isVisible()) + if (!isVisible()) show(); } @@ -141,7 +138,7 @@ void CompletionWidget::up() // deactivate previous findChild<ListItem *>(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<ListItem *>(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<QWidget*>(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<QKeyEvent *>(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<UrlBar *>(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<ListItem *>(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<QWidget *>(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 "<b>" and "</b>" 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("</b>")); bold = true; } - else if(bold && !boldSections.testBit(i)) + else if (bold && !boldSections.testBit(i)) { ret.insert(i + 1, QL1S("<b>")); bold = false; } } - if(bold) + if (bold) ret.insert(0, QL1S("<b>")); 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("<i>")); - 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("<i>") + t + QL1S("</i>"); 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("<i>")); - if(wasItalic) + if (wasItalic) t.remove(QRegExp("<[/ib]*>")); - if(wasItalic) + if (wasItalic) t = QL1S("<i>") + t + QL1S("</i>"); 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<QAction *> 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<void> 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:") + "<br /><br /> <a href=\"" + url + "\">" + url + "</a>")); @@ -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.") + "<br /><br /> <a href=\"" + url + "\">" + url + "</a>")); 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<QSslCertificate> certList = m_info.certificateChain(); QSslCertificate cert; if (!certList.isEmpty()) - cert = certList.first(); + cert = certList.first(); QList<QStringList> 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<UrlBar*>(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<IconButton *>(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()); } diff --git a/src/urlfilterproxymodel.cpp b/src/urlfilterproxymodel.cpp index c3b4beea..aa9ac7a6 100644 --- a/src/urlfilterproxymodel.cpp +++ b/src/urlfilterproxymodel.cpp @@ -45,13 +45,13 @@ bool UrlFilterProxyModel::filterAcceptsRow(const int source_row, const QModelInd bool UrlFilterProxyModel::recursiveMatch(const QModelIndex &index) const { - if(index.data().toString().contains(filterRegExp())) + if (index.data().toString().contains(filterRegExp())) return true; int numChildren = sourceModel()->rowCount(index); - for(int childRow = 0; childRow < numChildren; ++childRow) + for (int childRow = 0; childRow < numChildren; ++childRow) { - if(recursiveMatch(sourceModel()->index(childRow, 0, index))) + if (recursiveMatch(sourceModel()->index(childRow, 0, index))) return true; } diff --git a/src/urlpanel.cpp b/src/urlpanel.cpp index 8d88eddd..c4860bfd 100644 --- a/src/urlpanel.cpp +++ b/src/urlpanel.cpp @@ -56,7 +56,7 @@ UrlPanel::UrlPanel(const QString &title, QWidget *parent, Qt::WindowFlags flags) void UrlPanel::showing(bool b) { - if(!_loaded && b) + if (!_loaded && b) { setup(); _loaded = true; diff --git a/src/useragent/useragentinfo.cpp b/src/useragent/useragentinfo.cpp index 1d473ad8..82871108 100644 --- a/src/useragent/useragentinfo.cpp +++ b/src/useragent/useragentinfo.cpp @@ -61,7 +61,7 @@ UserAgentInfo::UserAgentInfo() QString UserAgentInfo::userAgentString(int i) { - if(i < 0 || !providerExists(i)) + if (i < 0 || !providerExists(i)) { kDebug() << "oh oh... wrong index on the user agent choice! INDEX = " << i; return QL1S("Default"); @@ -77,12 +77,12 @@ QString UserAgentInfo::userAgentString(int i) tmp.replace(QL1S("appMachineType"), QString(utsn.machine)); QStringList languageList = KGlobal::locale()->languageList(); - if(languageList.count()) + if (languageList.count()) { int ind = languageList.indexOf(QL1S("C")); - if(ind >= 0) + if (ind >= 0) { - if(languageList.contains(QL1S("en"))) + if (languageList.contains(QL1S("en"))) languageList.removeAt(ind); else languageList.value(ind) = QL1S("en"); @@ -98,7 +98,7 @@ QString UserAgentInfo::userAgentString(int i) QString UserAgentInfo::userAgentName(int i) { - if(i < 0 || !providerExists(i)) + if (i < 0 || !providerExists(i)) { kDebug() << "oh oh... wrong index on the user agent choice! INDEX = " << i; return QL1S("Default"); @@ -110,7 +110,7 @@ QString UserAgentInfo::userAgentName(int i) QString UserAgentInfo::userAgentVersion(int i) { - if(i < 0 || !providerExists(i)) + if (i < 0 || !providerExists(i)) { kDebug() << "oh oh... wrong index on the user agent choice! INDEX = " << i; return QL1S("Default"); @@ -122,7 +122,7 @@ QString UserAgentInfo::userAgentVersion(int i) QString UserAgentInfo::userAgentDescription(int i) { - if(i < 0 || !providerExists(i)) + if (i < 0 || !providerExists(i)) { kDebug() << "oh oh... wrong index on the user agent choice! INDEX = " << i; return QL1S("Default"); @@ -139,7 +139,7 @@ QStringList UserAgentInfo::availableUserAgents() { QStringList UAs; int n = m_providers.count(); - for(int i = 0; i < n; ++i) + for (int i = 0; i < n; ++i) { UAs << userAgentDescription(i); } @@ -154,9 +154,9 @@ bool UserAgentInfo::setUserAgentForHost(int uaIndex, const QString &host) QStringList modifiedHosts = config.groupList(); KConfigGroup hostGroup(&config, host); - if(uaIndex == -1) + if (uaIndex == -1) { - if(!hostGroup.exists()) + if (!hostGroup.exists()) { kDebug() << "Host does NOT exists!"; return false; @@ -178,10 +178,10 @@ int UserAgentInfo::uaIndexForHost(const QString &host) QString KDEUserAgent = KProtocolManager::userAgentForHost(host); int n = m_providers.count(); - for(int i = 0; i < n; ++i) + for (int i = 0; i < n; ++i) { QString rekonqUserAgent = userAgentString(i); - if(KDEUserAgent == rekonqUserAgent) + if (KDEUserAgent == rekonqUserAgent) return i; } return -1; @@ -191,7 +191,7 @@ int UserAgentInfo::uaIndexForHost(const QString &host) bool UserAgentInfo::providerExists(int i) { KService::Ptr s = m_providers.at(i); - if(s.isNull()) + if (s.isNull()) { //FIXME Add me when string freeze has been reopened: KMessageBox::error(...) return false; diff --git a/src/useragent/useragentwidget.cpp b/src/useragent/useragentwidget.cpp index 031a387f..92ba3ce4 100644 --- a/src/useragent/useragentwidget.cpp +++ b/src/useragent/useragentwidget.cpp @@ -60,7 +60,7 @@ UserAgentWidget::UserAgentWidget(QWidget *parent) void UserAgentWidget::deleteUserAgent() { QTreeWidgetItem *item = sitePolicyTreeWidget->currentItem(); - if(!item) + if (!item) return; sitePolicyTreeWidget->takeTopLevelItem(sitePolicyTreeWidget->indexOfTopLevelItem(item)); @@ -69,7 +69,7 @@ void UserAgentWidget::deleteUserAgent() KConfig config("kio_httprc", KConfig::NoGlobals); KConfigGroup group(&config, host); - if(group.exists()) + if (group.exists()) { group.deleteGroup(); KProtocolManager::reparseConfiguration(); diff --git a/src/webicon.cpp b/src/webicon.cpp index c313ef1b..9527be04 100644 --- a/src/webicon.cpp +++ b/src/webicon.cpp @@ -58,7 +58,7 @@ void WebIcon::load() void WebIcon::saveIcon(bool b) { - if(b) + if (b) rApp->iconManager()->provideIcon(&m_page, m_url, false); this->deleteLater(); diff --git a/src/webinspectorpanel.cpp b/src/webinspectorpanel.cpp index 20c9d8f1..b3454ccb 100644 --- a/src/webinspectorpanel.cpp +++ b/src/webinspectorpanel.cpp @@ -57,10 +57,10 @@ void WebInspectorPanel::toggle(bool enable) { MainWindow *w = qobject_cast<MainWindow *>(parent()); w->actionByName(QL1S("web_inspector"))->setChecked(enable); - if(enable) + if (enable) { w->currentTab()->page()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); - if(!_inspector) + if (!_inspector) { _inspector = new QWebInspector(this); _inspector->setPage(w->currentTab()->page()); diff --git a/src/webpage.cpp b/src/webpage.cpp index 3986fafb..a7baac6d 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -87,19 +87,19 @@ // Returns true if the scheme and domain of the two urls match... static bool domainSchemeMatch(const QUrl& u1, const QUrl& u2) { - if(u1.scheme() != u2.scheme()) + if (u1.scheme() != u2.scheme()) return false; QStringList u1List = u1.host().split(QL1C('.'), QString::SkipEmptyParts); QStringList u2List = u2.host().split(QL1C('.'), QString::SkipEmptyParts); - if(qMin(u1List.count(), u2List.count()) < 2) + if (qMin(u1List.count(), u2List.count()) < 2) return false; // better safe than sorry... - while(u1List.count() > 2) + while (u1List.count() > 2) u1List.removeFirst(); - while(u2List.count() > 2) + while (u2List.count() > 2) u2List.removeFirst(); return (u1List == u2List); @@ -115,31 +115,31 @@ static void extractSuggestedFileName(const QNetworkReply* reply, QString& fileNa { fileName.clear(); const KIO::MetaData& metaData = reply->attribute(static_cast<QNetworkRequest::Attribute>(KIO::AccessManager::MetaData)).toMap(); - if(metaData.value(QL1S("content-disposition-type")).compare(QL1S("attachment"), Qt::CaseInsensitive) == 0) + if (metaData.value(QL1S("content-disposition-type")).compare(QL1S("attachment"), Qt::CaseInsensitive) == 0) fileName = metaData.value(QL1S("content-disposition-filename")); - if(!fileName.isEmpty()) + if (!fileName.isEmpty()) return; - if(!reply->hasRawHeader("Content-Disposition")) + if (!reply->hasRawHeader("Content-Disposition")) return; const QString value(QL1S(reply->rawHeader("Content-Disposition").simplified().constData())); - if(value.startsWith(QL1S("attachment"), Qt::CaseInsensitive) || value.startsWith(QL1S("inline"), Qt::CaseInsensitive)) + if (value.startsWith(QL1S("attachment"), Qt::CaseInsensitive) || value.startsWith(QL1S("inline"), Qt::CaseInsensitive)) { const int length = value.size(); int pos = value.indexOf(QL1S("filename"), 0, Qt::CaseInsensitive); - if(pos > -1) + if (pos > -1) { pos += 9; - while(pos < length && (value.at(pos) == QL1C(' ') || value.at(pos) == QL1C('=') || value.at(pos) == QL1C('"'))) + while (pos < length && (value.at(pos) == QL1C(' ') || value.at(pos) == QL1C('=') || value.at(pos) == QL1C('"'))) pos++; int endPos = pos; - while(endPos < length && value.at(endPos) != QL1C('"') && value.at(endPos) != QL1C(';')) + while (endPos < length && value.at(endPos) != QL1C('"') && value.at(endPos) != QL1C(';')) endPos++; - if(endPos > pos) + if (endPos > pos) fileName = value.mid(pos, (endPos - pos)).trimmed(); } } @@ -150,18 +150,18 @@ static void extractMimeType(const QNetworkReply* reply, QString& mimeType) { mimeType.clear(); const KIO::MetaData& metaData = reply->attribute(static_cast<QNetworkRequest::Attribute>(KIO::AccessManager::MetaData)).toMap(); - if(metaData.contains(QL1S("content-type"))) + if (metaData.contains(QL1S("content-type"))) mimeType = metaData.value(QL1S("content-type")); - if(!mimeType.isEmpty()) + if (!mimeType.isEmpty()) return; - if(!reply->hasRawHeader("Content-Type")) + if (!reply->hasRawHeader("Content-Type")) return; const QString value(QL1S(reply->rawHeader("Content-Type").simplified().constData())); const int index = value.indexOf(QL1C(';')); - if(index == -1) + if (index == -1) mimeType = value; else mimeType = value.left(index); @@ -181,13 +181,13 @@ static bool downloadResource(const KUrl& srcUrl, const KIO::MetaData& metaData = // follow bug:184202 fixes destUrl = KFileDialog::getSaveFileName(KUrl(KGlobalSettings::downloadPath().append(fileName)), QString(), parent); - if(destUrl.isEmpty()) + if (destUrl.isEmpty()) return false; - if(destUrl.isLocalFile()) + if (destUrl.isLocalFile()) { QFileInfo finfo(destUrl.toLocalFile()); - if(finfo.exists()) + if (finfo.exists()) { QDateTime now = QDateTime::currentDateTime(); QPointer<KIO::RenameDialog> dlg = new KIO::RenameDialog(parent, @@ -207,24 +207,24 @@ static bool downloadResource(const KUrl& srcUrl, const KIO::MetaData& metaData = } } } - while(result == KIO::R_CANCEL && destUrl.isValid()); + while (result == KIO::R_CANCEL && destUrl.isValid()); // Save download history DownloadItem *item = rApp->downloadManager()->addDownload(srcUrl.pathOrUrl(), destUrl.pathOrUrl()); - if(!KStandardDirs::findExe("kget").isNull() && ReKonfig::kgetDownload()) + if (!KStandardDirs::findExe("kget").isNull() && ReKonfig::kgetDownload()) { //KGet integration: - if(!QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.kget")) + if (!QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.kget")) { KToolInvocation::kdeinitExecWait("kget"); } QDBusInterface kget("org.kde.kget", "/KGet", "org.kde.kget.main"); - if(!kget.isValid()) + if (!kget.isValid()) return false; QDBusMessage transfer = kget.call(QL1S("addTransfer"), srcUrl.prettyUrl(), destUrl.prettyUrl(), true); - if(transfer.arguments().isEmpty()) + if (transfer.arguments().isEmpty()) return true; const QString transferPath = transfer.arguments().first().toString(); @@ -233,13 +233,13 @@ static bool downloadResource(const KUrl& srcUrl, const KIO::MetaData& metaData = } KIO::Job *job = KIO::file_copy(srcUrl, destUrl, -1, KIO::Overwrite); - if(item) + if (item) { QObject::connect(job, SIGNAL(percent(KJob *, unsigned long)), item, SLOT(updateProgress(KJob *, unsigned long))); QObject::connect(job, SIGNAL(finished(KJob *)), item, SLOT(onFinished(KJob*))); } - if(!metaData.isEmpty()) + if (!metaData.isEmpty()) job->setMetaData(metaData); job->addMetaData(QL1S("MaxCacheSize"), QL1S("0")); // Don't store in http cache. @@ -268,7 +268,7 @@ WebPage::WebPage(QWidget *parent) manager->setCache(0); // set cookieJar window.. - if(parent && parent->window()) + if (parent && parent->window()) manager->setWindow(parent->window()); // set network reply object to emit readyRead when it receives meta data @@ -304,7 +304,7 @@ WebPage::~WebPage() bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type) { - if(_isOnRekonqPage) + if (_isOnRekonqPage) { WebView *view = qobject_cast<WebView *>(parent()); WebTab *tab = qobject_cast<WebTab *>(view->parent()); @@ -320,7 +320,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r KIO::MetaData metaData = manager->requestMetaData(); // Get the SSL information sent, if any... - if(metaData.contains(QL1S("ssl_in_use"))) + if (metaData.contains(QL1S("ssl_in_use"))) { WebSslInfo info; info.restoreFrom(metaData.toVariant(), request.url()); @@ -328,17 +328,17 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r _sslInfo = info; } - if(frame) + if (frame) { - if(_protHandler.preHandling(request, frame)) + if (_protHandler.preHandling(request, frame)) { return false; } - switch(type) + switch (type) { case QWebPage::NavigationTypeLinkClicked: - if(_sslInfo.isValid()) + if (_sslInfo.isValid()) { setRequestMetaData("ssl_was_in_use", "TRUE"); } @@ -348,10 +348,10 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r break; case QWebPage::NavigationTypeFormResubmitted: - if(KMessageBox::warningContinueCancel(view(), - i18n("Are you sure you want to send your data again?"), - i18n("Resend form data") - ) + if (KMessageBox::warningContinueCancel(view(), + i18n("Are you sure you want to send your data again?"), + i18n("Resend form data") + ) == KMessageBox::Cancel) { return false; @@ -374,11 +374,11 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r WebPage *WebPage::createWindow(QWebPage::WebWindowType type) { // added to manage web modal dialogs - if(type == QWebPage::WebModalDialog) + if (type == QWebPage::WebModalDialog) kDebug() << "Modal Dialog"; WebTab *w = 0; - if(ReKonfig::openTabNoWindow()) + if (ReKonfig::openTabNoWindow()) { w = rApp->mainWindow()->mainView()->newWebTab(!ReKonfig::openTabsBack()); } @@ -394,16 +394,16 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) { Q_ASSERT(reply); - if(!reply) + if (!reply) return; // handle protocols WebKit cannot handle... - if(_protHandler.postHandling(reply->request(), mainFrame())) + if (_protHandler.postHandling(reply->request(), mainFrame())) { return; } - if(reply->error() != QNetworkReply::NoError) + if (reply->error() != QNetworkReply::NoError) return; KIO::Integration::AccessManager::putReplyOnHold(reply); @@ -415,7 +415,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) extractMimeType(reply, _mimeType); // Convert executable text files to plain text... - if(KParts::BrowserRun::isTextExecutable(_mimeType)) + if (KParts::BrowserRun::isTextExecutable(_mimeType)) _mimeType = QL1S("text/plain"); kDebug() << "Detected MimeType = " << _mimeType; @@ -427,7 +427,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) KUrl replyUrl = reply->url(); bool isLocal = replyUrl.isLocalFile(); - if(appService.isNull()) // no service can handle this. We can just download it.. + if (appService.isNull()) // no service can handle this. We can just download it.. { isLocal ? KMessageBox::sorry(view(), i18n("No service can handle this file.")) @@ -436,13 +436,13 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) return; } - if(!isLocal) + if (!isLocal) { KParts::BrowserOpenOrSaveQuestion dlg(rApp->mainWindow(), replyUrl, _mimeType); - if(!_suggestedFileName.isEmpty()) + if (!_suggestedFileName.isEmpty()) dlg.setSuggestedFileName(_suggestedFileName); - switch(dlg.askEmbedOrSave()) + switch (dlg.askEmbedOrSave()) { case KParts::BrowserOpenOrSaveQuestion::Save: downloadReply(reply, _suggestedFileName); @@ -457,7 +457,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) } // Handle Post operations that return content... - if(reply->operation() == QNetworkAccessManager::PostOperation) + if (reply->operation() == QNetworkAccessManager::PostOperation) { kDebug() << "POST OPERATION: downloading file..."; QFileInfo finfo(_suggestedFileName.isEmpty() ? _loadingUrl.fileName() : _suggestedFileName); @@ -475,7 +475,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) // case KParts::BrowserRun::Embed KParts::ReadOnlyPart *pa = KMimeTypeTrader::createPartInstanceFromQuery<KParts::ReadOnlyPart>(_mimeType, view(), this, QString()); - if(pa) + if (pa) { _isOnRekonqPage = true; @@ -526,9 +526,9 @@ void WebPage::loadFinished(bool ok) // KWallet Integration QStringList list = ReKonfig::walletBlackList(); - if(wallet() + if (wallet() && !list.contains(mainFrame()->url().toString()) - ) + ) { wallet()->fillFormData(mainFrame()); } @@ -540,18 +540,18 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply) Q_ASSERT(reply); // check suggested file name - if(_suggestedFileName.isEmpty()) + if (_suggestedFileName.isEmpty()) extractSuggestedFileName(reply, _suggestedFileName); QWebFrame* frame = qobject_cast<QWebFrame *>(reply->request().originatingObject()); const bool isMainFrameRequest = (frame == mainFrame()); const bool isLoadingUrlReply = (mainFrame()->url() == reply->url()); - if(isMainFrameRequest + if (isMainFrameRequest && _sslInfo.isValid() && isLoadingUrlReply && !domainSchemeMatch(reply->url(), _sslInfo.url()) - ) + ) { // Reseting cached SSL info... _sslInfo = WebSslInfo(); @@ -559,11 +559,11 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply) // NOTE: These are not all networkreply errors, // but just that supported directly by KIO - switch(reply->error()) + switch (reply->error()) { case QNetworkReply::NoError: // no error. Simple :) - if(isMainFrameRequest && isLoadingUrlReply && !_sslInfo.isValid()) + if (isMainFrameRequest && isLoadingUrlReply && !_sslInfo.isValid()) { // Obtain and set the SSL information if any... _sslInfo.restoreFrom(reply->attribute(static_cast<QNetworkRequest::Attribute>(KIO::AccessManager::MetaData)), reply->url()); @@ -594,10 +594,10 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply) case QNetworkReply::ProtocolInvalidOperationError: // requested operation is invalid for this protocol kDebug() << "ERROR " << reply->error() << ": " << reply->errorString(); - if(reply->url() == _loadingUrl) + if (reply->url() == _loadingUrl) { frame->setHtml(errorPage(reply)); - if(isMainFrameRequest) + if (isMainFrameRequest) { _isOnRekonqPage = true; @@ -626,7 +626,7 @@ QString WebPage::errorPage(QNetworkReply *reply) QFile file(notfoundFilePath); bool isOpened = file.open(QIODevice::ReadOnly); - if(!isOpened) + if (!isOpened) { return QString("Couldn't open the rekonqinfo.html file"); } @@ -641,21 +641,21 @@ QString WebPage::errorPage(QNetworkReply *reply) iconPath.replace(QL1S("16"), QL1S("128")); QString msg; - msg += "<table>"; - msg += "<tr><td>"; - msg += "<img src=\"" + iconPath + "\" />"; - msg += "</td><td>"; - msg += "<h1>" + reply->errorString() + "</h1>"; - msg += "<h2>" + i18nc("%1=an URL, e.g.'kde.org'", "When connecting to: <b>%1</b>", urlString) + "</h2>"; - msg += "</td></tr></table>"; - - msg += "<ul><li>" + i18n("Check the address for errors such as <b>ww</b>.kde.org instead of <b>www</b>.kde.org"); - msg += "</li><li>" + i18n("If the address is correct, try to check the network connection.") + "</li><li>" ; + msg += QL1S("<table>"); + msg += QL1S("<tr><td>"); + msg += QL1S("<img src=\"") + iconPath + QL1S("\" />"); + msg += QL1S("</td><td>"); + msg += QL1S("<h1>") + reply->errorString() + QL1S("</h1>"); + msg += QL1S("<h2>") + i18nc("%1=an URL, e.g.'kde.org'", "When connecting to: <b>%1</b>", urlString) + QL1S("</h2>"); + msg += QL1S("</td></tr></table>"); + + msg += QL1S("<ul><li>") + i18n("Check the address for errors such as <b>ww</b>.kde.org instead of <b>www</b>.kde.org"); + msg += QL1S("</li><li>") + i18n("If the address is correct, try to check the network connection.") + QL1S("</li><li>") ; msg += i18n("If your computer or network is protected by a firewall or proxy, make sure that rekonq is permitted to access the network."); - msg += "</li><li>" + i18n("Of course, if rekonq does not work properly, you can always say it is a programmer error ;)"); - msg += "</li></ul><br/><br/>"; - msg += "<input type=\"button\" id=\"reloadButton\" onClick=\"document.location.href='" + urlString + "';\" value=\""; - msg += i18n("Try Again") + "\" />"; + msg += QL1S("</li><li>") + i18n("Of course, if rekonq does not work properly, you can always say it is a programmer error ;)"); + msg += QL1S("</li></ul><br/><br/>"); + msg += QL1S("<input type=\"button\" id=\"reloadButton\" onClick=\"document.location.href='") + urlString + QL1S("';\" value=\""); + msg += i18n("Try Again") + QL1S("\" />"); QString html = QString(QL1S(file.readAll())) .arg(title) @@ -705,12 +705,12 @@ void WebPage::downloadAllContentsWithKGet(QPoint) contents << baseUrl.resolved(relativeUrl).toString(); } - if(!QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.kget")) + if (!QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.kget")) { KToolInvocation::kdeinitExecWait("kget"); } QDBusInterface kget("org.kde.kget", "/KGet", "org.kde.kget.main"); - if(kget.isValid()) + if (kget.isValid()) { kget.call("importLinks", QVariant(contents.toList())); } @@ -719,7 +719,7 @@ void WebPage::downloadAllContentsWithKGet(QPoint) void WebPage::showSSLInfo(QPoint pos) { - if(mainFrame()->url().scheme() == QL1S("https")) + if (mainFrame()->url().scheme() == QL1S("https")) { SSLWidget *widget = new SSLWidget(mainFrame()->url(), _sslInfo, view()); widget->showAt(pos); @@ -736,7 +736,7 @@ void WebPage::showSSLInfo(QPoint pos) void WebPage::updateImage(bool ok) { - if(ok) + if (ok) { NewTabPage p(mainFrame()); p.snapFinished(); @@ -746,7 +746,7 @@ void WebPage::updateImage(bool ok) void WebPage::copyToTempFileResult(KJob* job) { - if(job->error()) + if (job->error()) job->uiDelegate()->showErrorMessage(); else (void)KRun::runUrl(static_cast<KIO::FileCopyJob *>(job)->destUrl(), _mimeType, rApp->mainWindow()); @@ -760,7 +760,7 @@ bool WebPage::hasSslValid() const if (certList.isEmpty()) return false; - Q_FOREACH(const QSslCertificate &cert, certList) + Q_FOREACH(const QSslCertificate & cert, certList) { if (!cert.isValid()) return false; diff --git a/src/webpluginfactory.cpp b/src/webpluginfactory.cpp index 9fe80075..0a47aef8 100644 --- a/src/webpluginfactory.cpp +++ b/src/webpluginfactory.cpp @@ -56,17 +56,17 @@ QObject *WebPluginFactory::create(const QString &mimeType, { kDebug() << "loading mimeType: " << mimeType; - switch(ReKonfig::pluginsEnabled()) + switch (ReKonfig::pluginsEnabled()) { case 0: kDebug() << "No plugins found for" << mimeType << ". Falling back to KDEWebKit ones..."; return KWebPluginFactory::create(mimeType, url, argumentNames, argumentValues); case 1: - if(mimeType != QString("application/x-shockwave-flash")) + if (mimeType != QString("application/x-shockwave-flash")) break; - if(_loadClickToFlash) + if (_loadClickToFlash) { emit signalLoadClickToFlash(false); return 0; //KWebPluginFactory::create(mimeType, url, argumentNames, argumentValues); diff --git a/src/websnap.cpp b/src/websnap.cpp index e7050f87..d041156e 100644 --- a/src/websnap.cpp +++ b/src/websnap.cpp @@ -144,7 +144,7 @@ QString WebSnap::imagePathFromUrl(const KUrl &url) void WebSnap::saveResult(bool ok) { - if(ok) + if (ok) { QPixmap image = renderPagePreview(m_page, defaultWidth, defaultHeight); QString path = imagePathFromUrl(m_url); diff --git a/src/websslinfo.cpp b/src/websslinfo.cpp index 720c2209..d266a8fc 100644 --- a/src/websslinfo.cpp +++ b/src/websslinfo.cpp @@ -113,7 +113,7 @@ QList<QSslCertificate> WebSslInfo::certificateChain() const WebSslInfo& WebSslInfo::operator=(const WebSslInfo & other) { - if(d) + if (d) { d->ciphers = other.d->ciphers; d->protocol = other.d->protocol; @@ -133,7 +133,7 @@ WebSslInfo& WebSslInfo::operator=(const WebSslInfo & other) bool WebSslInfo::saveTo(QMap<QString, QVariant>& data) const { const bool ok = isValid(); - if(ok) + if (ok) { data.insert("ssl_in_use", true); data.insert("ssl_peer_ip", d->peerAddress.toString()); @@ -154,10 +154,10 @@ bool WebSslInfo::saveTo(QMap<QString, QVariant>& data) const void WebSslInfo::restoreFrom(const QVariant& value, const QUrl& url) { - if(value.isValid() && value.type() == QVariant::Map) + if (value.isValid() && value.type() == QVariant::Map) { QMap<QString, QVariant> metaData = value.toMap(); - if(metaData.value("ssl_in_use", false).toBool()) + if (metaData.value("ssl_in_use", false).toBool()) { setCertificateChain(metaData.value("ssl_peer_chain").toByteArray()); setPeerAddress(metaData.value("ssl_peer_ip").toString()); @@ -174,54 +174,54 @@ void WebSslInfo::restoreFrom(const QVariant& value, const QUrl& url) void WebSslInfo::setUrl(const QUrl &url) { - if(d) + if (d) d->url = url; } void WebSslInfo::setPeerAddress(const QString& address) { - if(d) + if (d) d->peerAddress = address; } void WebSslInfo::setParentAddress(const QString& address) { - if(d) + if (d) d->parentAddress = address; } void WebSslInfo::setProtocol(const QString& protocol) { - if(d) + if (d) d->protocol = protocol; } void WebSslInfo::setCertificateChain(const QByteArray& chain) { - if(d) + if (d) d->certificateChain = QSslCertificate::fromData(chain); } void WebSslInfo::setCiphers(const QString& ciphers) { - if(d) + if (d) d->ciphers = ciphers; } void WebSslInfo::setUsedCipherBits(const QString& bits) { - if(d) + if (d) d->usedCipherBits = bits.toInt(); } void WebSslInfo::setSupportedCipherBits(const QString& bits) { - if(d) + if (d) d->supportedCipherBits = bits.toInt(); } void WebSslInfo::setCertificateErrors(const QString& certErrors) { - if(d) + if (d) d->certErrors = certErrors; } diff --git a/src/webtab.cpp b/src/webtab.cpp index 52f02467..39287d28 100644 --- a/src/webtab.cpp +++ b/src/webtab.cpp @@ -78,7 +78,7 @@ WebTab::WebTab(QWidget *parent) KWebWallet *wallet = m_webView->page()->wallet(); - if(wallet) + if (wallet) { connect(wallet, SIGNAL(saveFormDataRequested(const QString &, const QUrl &)), this, SLOT(createWalletBar(const QString &, const QUrl &))); @@ -101,7 +101,7 @@ WebTab::~WebTab() KUrl WebTab::url() { - if(page() && page()->isOnRekonqPage()) + if (page() && page()->isOnRekonqPage()) { return page()->loadingUrl(); } @@ -134,11 +134,11 @@ void WebTab::createWalletBar(const QString &key, const QUrl &url) // check if the url is in the wallet blacklist QString urlString = url.toString(); QStringList blackList = ReKonfig::walletBlackList(); - if(blackList.contains(urlString)) + if (blackList.contains(urlString)) return; KWebWallet *wallet = page()->wallet(); - if(m_walletBar.isNull()) + if (m_walletBar.isNull()) { m_walletBar = new WalletBar(this); m_walletBar.data()->onSaveFormData(key, url); @@ -161,7 +161,7 @@ void WebTab::createWalletBar(const QString &key, const QUrl &url) void WebTab::createPreviewSelectorBar(int index) { - if(m_previewSelectorBar.isNull()) + if (m_previewSelectorBar.isNull()) { m_previewSelectorBar = new PreviewSelectorBar(index, this); qobject_cast<QVBoxLayout *>(layout())->insertWidget(0, m_previewSelectorBar.data()); @@ -185,7 +185,7 @@ bool WebTab::hasRSSInfo() { QWebElementCollection col = page()->mainFrame()->findAllElements("link[type=\"application/rss+xml\"]"); col.append(page()->mainFrame()->findAllElements("link[type=\"application/atom+xml\"]")); - if(col.count() != 0) + if (col.count() != 0) return true; return false; @@ -202,7 +202,7 @@ void WebTab::showRSSInfo(const QPoint &pos) foreach(const QWebElement & el, col) { QString urlString; - if(el.attribute("href").startsWith(QL1S("http"))) + if (el.attribute("href").startsWith(QL1S("http"))) urlString = el.attribute("href"); else { @@ -210,12 +210,12 @@ void WebTab::showRSSInfo(const QPoint &pos) // NOTE // cd() is probably better than setPath() here, // for all those url sites just having a path - if(u.cd(el.attribute("href"))) + if (u.cd(el.attribute("href"))) urlString = u.toMimeDataString(); } QString title = el.attribute("title"); - if(title.isEmpty()) + if (title.isEmpty()) title = el.attribute("href"); map.insert(KUrl(urlString), title); @@ -228,7 +228,7 @@ void WebTab::showRSSInfo(const QPoint &pos) void WebTab::setPart(KParts::ReadOnlyPart *p, const KUrl &u) { - if(p) + if (p) { // Ok, part exists. Insert & show it.. m_part = p; @@ -240,7 +240,7 @@ void WebTab::setPart(KParts::ReadOnlyPart *p, const KUrl &u) return; } - if(!m_part) + if (!m_part) return; // Part NO more exists. Let's clean up from webtab @@ -255,11 +255,11 @@ KUrl WebTab::extractOpensearchUrl(QWebElement e) { QString href = e.attribute(QL1S("href")); KUrl url = KUrl(href); - if(!href.contains(":")) + if (!href.contains(":")) { KUrl docUrl = m_webView->url(); QString host = docUrl.scheme() + "://" + docUrl.host(); - if(docUrl.port() != -1) + if (docUrl.port() != -1) { host += QL1C(':') + QString::number(docUrl.port()); } @@ -280,7 +280,7 @@ void WebTab::showSearchEngine(const QPoint &pos) { QWebElement e = page()->mainFrame()->findFirstElement(QL1S("head >link[rel=\"search\"][ type=\"application/opensearchdescription+xml\"]")); QString title = e.attribute(QL1S("title")); - if(!title.isEmpty()) + if (!title.isEmpty()) { WebShortcutWidget *widget = new WebShortcutWidget(window()); widget->setWindowFlags(Qt::Popup); diff --git a/src/webview.cpp b/src/webview.cpp index 218dc151..a938ad70 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -105,7 +105,7 @@ WebView::WebView(QWidget* parent) WebView::~WebView() { - if(m_smoothScrolling) + if (m_smoothScrolling) stopScrolling(); WebPage* p = page(); @@ -118,10 +118,10 @@ WebView::~WebView() void WebView::changeWindowIcon() { - if(ReKonfig::useFavicon()) + if (ReKonfig::useFavicon()) { MainWindow *const mainWindow = rApp->mainWindow(); - if(url() == mainWindow->currentTab()->url()) + if (url() == mainWindow->currentTab()->url()) { const int index = mainWindow->mainView()->currentIndex(); mainWindow->changeWindowIcon(index); @@ -150,7 +150,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) connect(inspectAction, SIGNAL(triggered(bool)), this, SLOT(inspect())); // is a link? - if(!result.linkUrl().isEmpty()) + if (!result.linkUrl().isEmpty()) { // link actions a = new KAction(KIcon("tab-new"), i18n("Open in New &Tab"), this); @@ -170,31 +170,31 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) } // is content editable && selected? Add CUT - if(result.isContentEditable() && result.isContentSelected()) + if (result.isContentEditable() && result.isContentSelected()) { // actions for text selected in field menu.addAction(pageAction(KWebPage::Cut)); } // is content selected) Add COPY - if(result.isContentSelected()) + if (result.isContentSelected()) { a = pageAction(KWebPage::Copy); - if(!result.linkUrl().isEmpty()) + if (!result.linkUrl().isEmpty()) a->setText(i18n("Copy Text")); //for link else a->setText(i18n("Copy")); menu.addAction(a); - if(selectedText().contains('.') && selectedText().indexOf('.') < selectedText().length() && !selectedText().trimmed().contains(" ")) + if (selectedText().contains('.') && selectedText().indexOf('.') < selectedText().length() && !selectedText().trimmed().contains(" ")) { QString text = selectedText(); text = text.trimmed(); KUrl urlLikeText(text); - if(urlLikeText.isValid()) + if (urlLikeText.isValid()) { QString truncatedUrl = text; const int maxTextSize = 18; - if(truncatedUrl.length() > maxTextSize) + if (truncatedUrl.length() > maxTextSize) { const int truncateSize = 15; truncatedUrl.truncate(truncateSize); @@ -216,13 +216,13 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) } // is content editable? Add PASTE - if(result.isContentEditable()) + if (result.isContentEditable()) { menu.addAction(pageAction(KWebPage::Paste)); } // is content selected? Add SEARCH actions - if(result.isContentSelected()) + if (result.isContentSelected()) { KActionMenu *searchMenu = new KActionMenu(KIcon("edit-find"), i18n("Search with"), this); @@ -239,20 +239,20 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) connect(a, SIGNAL(triggered()), rApp->mainWindow(), SLOT(findSelectedText())); searchMenu->addAction(a); - if(!searchMenu->menu()->isEmpty()) + if (!searchMenu->menu()->isEmpty()) { menu.addAction(searchMenu); } menu.addSeparator(); - if(ReKonfig::showDeveloperTools()) + if (ReKonfig::showDeveloperTools()) menu.addAction(inspectAction); // TODO Add translate, show translation } // is an image? - if(!result.pixmap().isNull()) + if (!result.pixmap().isNull()) { menu.addSeparator(); @@ -272,33 +272,33 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) menu.addSeparator(); - if(ReKonfig::showDeveloperTools()) + if (ReKonfig::showDeveloperTools()) menu.addAction(inspectAction); } // page actions - if(!result.isContentSelected() && result.linkUrl().isEmpty()) + if (!result.isContentSelected() && result.linkUrl().isEmpty()) { // navigation QWebHistory *history = page()->history(); - if(history->canGoBack()) + if (history->canGoBack()) { menu.addAction(pageAction(KWebPage::Back)); } - if(history->canGoForward()) + if (history->canGoForward()) { menu.addAction(pageAction(KWebPage::Forward)); } menu.addAction(mainwindow->actionByName("view_redisplay")); - if(result.pixmap().isNull()) + if (result.pixmap().isNull()) { menu.addSeparator(); - if(!ReKonfig::alwaysShowTabBar() && mainwindow->mainView()->count() == 1) + if (!ReKonfig::alwaysShowTabBar() && mainwindow->mainView()->count() == 1) menu.addAction(mainwindow->actionByName("new_tab")); menu.addAction(mainwindow->actionByName("new_window")); @@ -323,14 +323,14 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) menu.addAction(mainwindow->actionByName(KStandardAction::name(KStandardAction::SaveAs))); - if(!KStandardDirs::findExe("kget").isNull() && ReKonfig::kgetList()) + if (!KStandardDirs::findExe("kget").isNull() && ReKonfig::kgetList()) { a = new KAction(KIcon("kget"), i18n("List All Links"), this); connect(a, SIGNAL(triggered(bool)), page(), SLOT(downloadAllContentsWithKGet())); menu.addAction(a); } - if(ReKonfig::showDeveloperTools()) + if (ReKonfig::showDeveloperTools()) { menu.addAction(mainwindow->actionByName("page_source")); menu.addAction(inspectAction); @@ -340,7 +340,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) menu.addAction(a); } - if(mainwindow->isFullScreen()) + if (mainwindow->isFullScreen()) { menu.addSeparator(); menu.addAction(mainwindow->actionByName("fullscreen")); @@ -353,7 +353,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) void WebView::mousePressEvent(QMouseEvent *event) { - if(m_isAutoScrollEnabled) + if (m_isAutoScrollEnabled) { m_vScrollSpeed = 0; m_hScrollSpeed = 0; @@ -366,7 +366,7 @@ void WebView::mousePressEvent(QMouseEvent *event) QWebHitTestResult result = page()->mainFrame()->hitTestContent(event->pos()); m_canEnableAutoScroll = ReKonfig::autoScroll() && !result.isContentEditable() && result.linkUrl().isEmpty(); - switch(event->button()) + switch (event->button()) { case Qt::XButton1: triggerPageAction(KWebPage::Back); @@ -377,12 +377,12 @@ void WebView::mousePressEvent(QMouseEvent *event) break; case Qt::MidButton: - if(m_canEnableAutoScroll + if (m_canEnableAutoScroll && !m_isAutoScrollEnabled && !page()->currentFrame()->scrollBarGeometry(Qt::Horizontal).contains(event->pos()) && !page()->currentFrame()->scrollBarGeometry(Qt::Vertical).contains(event->pos())) { - if(!page()->currentFrame()->scrollBarGeometry(Qt::Horizontal).isNull() + if (!page()->currentFrame()->scrollBarGeometry(Qt::Horizontal).isNull() || !page()->currentFrame()->scrollBarGeometry(Qt::Vertical).isNull()) { m_clickPos = event->pos(); @@ -403,27 +403,27 @@ void WebView::mouseMoveEvent(QMouseEvent *event) { m_mousePos = event->pos(); - if(m_isAutoScrollEnabled) + if (m_isAutoScrollEnabled) { QPoint r = m_mousePos - m_clickPos; m_hScrollSpeed = r.x() / 2; // you are too fast.. m_vScrollSpeed = r.y() / 2; - if(!m_autoScrollTimer->isActive()) + if (!m_autoScrollTimer->isActive()) m_autoScrollTimer->start(); return; } MainWindow *w = rApp->mainWindow(); - if(w->isFullScreen()) + if (w->isFullScreen()) { - if(event->pos().y() >= 0 && event->pos().y() <= 4) + if (event->pos().y() >= 0 && event->pos().y() <= 4) { w->setWidgetsVisible(true); } else { - if(!w->mainView()->currentUrlBar()->hasFocus()) + if (!w->mainView()->currentUrlBar()->hasFocus()) w->setWidgetsVisible(false); } } @@ -434,11 +434,11 @@ void WebView::mouseMoveEvent(QMouseEvent *event) void WebView::dropEvent(QDropEvent *event) { bool isEditable = page()->frameAt(event->pos())->hitTestContent(event->pos()).isContentEditable(); - if(event->mimeData()->hasFormat("application/rekonq-bookmark")) + if (event->mimeData()->hasFormat("application/rekonq-bookmark")) { QByteArray addresses = event->mimeData()->data("application/rekonq-bookmark"); KBookmark bookmark = rApp->bookmarkProvider()->bookmarkManager()->findByAddress(QString::fromLatin1(addresses.data())); - if(bookmark.isGroup()) + if (bookmark.isGroup()) { rApp->bookmarkProvider()->bookmarkOwner()->openFolderinTabs(bookmark.toGroup()); } @@ -447,18 +447,18 @@ void WebView::dropEvent(QDropEvent *event) emit loadUrl(bookmark.url(), Rekonq::CurrentTab); } } - else if(event->mimeData()->hasUrls() && event->source() != this && !isEditable) //dropped links + else if (event->mimeData()->hasUrls() && event->source() != this && !isEditable) //dropped links { Q_FOREACH(const QUrl & url, event->mimeData()->urls()) { emit loadUrl(url, Rekonq::NewFocusedTab); } } - else if(event->mimeData()->hasFormat("text/plain") && event->source() != this && !isEditable) //dropped plain text with url format + else if (event->mimeData()->hasFormat("text/plain") && event->source() != this && !isEditable) //dropped plain text with url format { QUrl url = QUrl::fromUserInput(event->mimeData()->data("text/plain")); - if(url.isValid()) + if (url.isValid()) emit loadUrl(url, Rekonq::NewFocusedTab); } else @@ -472,7 +472,7 @@ void WebView::paintEvent(QPaintEvent* event) { KWebView::paintEvent(event); - if(m_isAutoScrollEnabled) + if (m_isAutoScrollEnabled) { QPoint centeredPoint = m_clickPos; centeredPoint.setX(centeredPoint.x() - m_autoScrollIndicator.width() / 2); @@ -506,7 +506,7 @@ void WebView::viewImage(Qt::MouseButtons buttons, Qt::KeyboardModifiers modifier KAction *a = qobject_cast<KAction*>(sender()); KUrl url(a->data().toUrl()); - if(modifiers & Qt::ControlModifier || buttons == Qt::MidButton) + if (modifiers & Qt::ControlModifier || buttons == Qt::MidButton) { emit loadUrl(url, Rekonq::NewTab); } @@ -554,90 +554,90 @@ void WebView::openLinkInNewTab() void WebView::keyPressEvent(QKeyEvent *event) { - if(event->modifiers() == Qt::ControlModifier) + if (event->modifiers() == Qt::ControlModifier) { - if(event->key() == Qt::Key_C) + if (event->key() == Qt::Key_C) { triggerPageAction(KWebPage::Copy); return; } - if(event->key() == Qt::Key_A) + if (event->key() == Qt::Key_A) { triggerPageAction(KWebPage::SelectAll); return; } } - if(!m_canEnableAutoScroll) + if (!m_canEnableAutoScroll) { KWebView::keyPressEvent(event); return; } // Auto Scrolling - if(event->modifiers() == Qt::ShiftModifier) + if (event->modifiers() == Qt::ShiftModifier) { - if(event->key() == Qt::Key_Up) + if (event->key() == Qt::Key_Up) { m_vScrollSpeed--; - if(!m_autoScrollTimer->isActive()) + if (!m_autoScrollTimer->isActive()) m_autoScrollTimer->start(); return; } - if(event->key() == Qt::Key_Down) + if (event->key() == Qt::Key_Down) { m_vScrollSpeed++; - if(!m_autoScrollTimer->isActive()) + if (!m_autoScrollTimer->isActive()) m_autoScrollTimer->start(); return; } - if(event->key() == Qt::Key_Right) + if (event->key() == Qt::Key_Right) { m_hScrollSpeed++; - if(!m_autoScrollTimer->isActive()) + if (!m_autoScrollTimer->isActive()) m_autoScrollTimer->start(); return; } - if(event->key() == Qt::Key_Left) + if (event->key() == Qt::Key_Left) { m_hScrollSpeed--; - if(!m_autoScrollTimer->isActive()) + if (!m_autoScrollTimer->isActive()) m_autoScrollTimer->start(); return; } - if(m_autoScrollTimer->isActive()) + if (m_autoScrollTimer->isActive()) { m_autoScrollTimer->stop(); } else { - if(m_vScrollSpeed || m_hScrollSpeed) + if (m_vScrollSpeed || m_hScrollSpeed) m_autoScrollTimer->start(); } } // vi-like navigation - if(event->key() == Qt::Key_J && event->modifiers() == Qt::NoModifier) + if (event->key() == Qt::Key_J && event->modifiers() == Qt::NoModifier) { event->accept(); event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier); } - else if(event->key() == Qt::Key_K && event->modifiers() == Qt::NoModifier) + else if (event->key() == Qt::Key_K && event->modifiers() == Qt::NoModifier) { event->accept(); event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier); } - else if(event->key() == Qt::Key_L && event->modifiers() == Qt::NoModifier) + else if (event->key() == Qt::Key_L && event->modifiers() == Qt::NoModifier) { event->accept(); event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier); } - else if(event->key() == Qt::Key_H && event->modifiers() == Qt::NoModifier) + else if (event->key() == Qt::Key_H && event->modifiers() == Qt::NoModifier) { event->accept(); event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier); @@ -649,7 +649,7 @@ void WebView::keyPressEvent(QKeyEvent *event) void WebView::wheelEvent(QWheelEvent *event) { - if(event->orientation() == Qt::Vertical || !ReKonfig::hScrollWheelHistory()) + if (event->orientation() == Qt::Vertical || !ReKonfig::hScrollWheelHistory()) { // To let some websites (eg: google maps) to handle wheel events int prevPos = page()->currentFrame()->scrollPosition().y(); @@ -657,30 +657,30 @@ void WebView::wheelEvent(QWheelEvent *event) int newPos = page()->currentFrame()->scrollPosition().y(); // Sync with the zoom slider - if(event->modifiers() == Qt::ControlModifier) + if (event->modifiers() == Qt::ControlModifier) { // Limits of the slider - if(zoomFactor() > 1.9) + if (zoomFactor() > 1.9) setZoomFactor(1.9); - else if(zoomFactor() < 0.1) + else if (zoomFactor() < 0.1) setZoomFactor(0.1); // Round the factor (Fix slider's end value) int newFactor = zoomFactor() * 10; - if((zoomFactor() * 10 - newFactor) > 0.5) + if ((zoomFactor() * 10 - newFactor) > 0.5) newFactor++; emit zoomChanged(newFactor); } - else if(ReKonfig::smoothScrolling() && prevPos != newPos) + else if (ReKonfig::smoothScrolling() && prevPos != newPos) { page()->currentFrame()->setScrollPosition(QPoint(page()->currentFrame()->scrollPosition().x(), prevPos)); - if((event->delta() > 0) != !m_scrollBottom) + if ((event->delta() > 0) != !m_scrollBottom) stopScrolling(); - if(event->delta() > 0) + if (event->delta() > 0) m_scrollBottom = false; else m_scrollBottom = true; @@ -693,12 +693,12 @@ void WebView::wheelEvent(QWheelEvent *event) else { // left -> go to previous page - if(event->delta() > 0) + if (event->delta() > 0) { emit openPreviousInHistory(); } // right -> go to next page - if(event->delta() < 0) + if (event->delta() < 0) { emit openNextInHistory(); } @@ -709,7 +709,7 @@ void WebView::wheelEvent(QWheelEvent *event) void WebView::inspect() { QAction *a = rApp->mainWindow()->actionByName("web_inspector"); - if(a && !a->isChecked()) + if (a && !a->isChecked()) a->trigger(); pageAction(QWebPage::InspectElement)->trigger(); } @@ -728,11 +728,11 @@ void WebView::scrollFrameChanged() // check if we reached the end int y = page()->currentFrame()->scrollPosition().y(); - if(y == 0 || y == page()->currentFrame()->scrollBarMaximum(Qt::Vertical)) + if (y == 0 || y == page()->currentFrame()->scrollBarMaximum(Qt::Vertical)) m_vScrollSpeed = 0; int x = page()->currentFrame()->scrollPosition().x(); - if(x == 0 || x == page()->currentFrame()->scrollBarMaximum(Qt::Horizontal)) + if (x == 0 || x == page()->currentFrame()->scrollBarMaximum(Qt::Horizontal)) m_hScrollSpeed = 0; } @@ -743,7 +743,7 @@ void WebView::setupSmoothScrolling(int posY) m_dy += posY; - if(m_dy <= 0) + if (m_dy <= 0) { stopScrolling(); return; @@ -751,16 +751,16 @@ void WebView::setupSmoothScrolling(int posY) m_smoothScrollSteps = 8; - if(m_dy / m_smoothScrollSteps < ddy) + if (m_dy / m_smoothScrollSteps < ddy) { m_smoothScrollSteps = (abs(m_dy) + ddy - 1) / ddy; - if(m_smoothScrollSteps < 1) + if (m_smoothScrollSteps < 1) m_smoothScrollSteps = 1; } m_smoothScrollTime.start(); - if(!m_smoothScrolling) + if (!m_smoothScrolling) { m_smoothScrolling = true; m_smoothScrollTimer->start(); @@ -771,30 +771,30 @@ void WebView::setupSmoothScrolling(int posY) void WebView::scrollTick() { - if(m_dy == 0) + if (m_dy == 0) { stopScrolling(); return; } - if(m_smoothScrollSteps < 1) + if (m_smoothScrollSteps < 1) m_smoothScrollSteps = 1; int takesteps = m_smoothScrollTime.restart() / 16; int scroll_y = 0; - if(takesteps < 1) + if (takesteps < 1) takesteps = 1; - if(takesteps > m_smoothScrollSteps) + if (takesteps > m_smoothScrollSteps) takesteps = m_smoothScrollSteps; - for(int i = 0; i < takesteps; i++) + for (int i = 0; i < takesteps; i++) { int ddy = (m_dy / (m_smoothScrollSteps + 1)) * 2; // limit step to requested scrolling distance - if(abs(ddy) > abs(m_dy)) + if (abs(ddy) > abs(m_dy)) ddy = m_dy; // update remaining scroll @@ -803,7 +803,7 @@ void WebView::scrollTick() m_smoothScrollSteps--; } - if(m_scrollBottom) + if (m_scrollBottom) page()->currentFrame()->scroll(0, scroll_y); else page()->currentFrame()->scroll(0, -scroll_y); @@ -820,7 +820,7 @@ void WebView::stopScrolling() void WebView::dragEnterEvent(QDragEnterEvent *event) { - if(event->mimeData()->hasUrls() || event->mimeData()->hasText()) + if (event->mimeData()->hasUrls() || event->mimeData()->hasText()) event->acceptProposedAction(); else KWebView::dragEnterEvent(event); @@ -829,7 +829,7 @@ void WebView::dragEnterEvent(QDragEnterEvent *event) void WebView::dragMoveEvent(QDragMoveEvent *event) { - if(event->mimeData()->hasUrls() || event->mimeData()->hasText()) + if (event->mimeData()->hasUrls() || event->mimeData()->hasText()) event->acceptProposedAction(); else KWebView::dragMoveEvent(event); diff --git a/src/zoombar.cpp b/src/zoombar.cpp index 9dcf5e72..95a2c250 100644 --- a/src/zoombar.cpp +++ b/src/zoombar.cpp @@ -122,7 +122,7 @@ void ZoomBar::setupActions(MainWindow *window) void ZoomBar::show() { // show findbar if not visible - if(isHidden()) + if (isHidden()) { emit visibilityChanged(true); QWidget::show(); @@ -159,10 +159,10 @@ void ZoomBar::zoomNormal() void ZoomBar::updateSlider(int webview) { WebTab *tab = 0; - if(!rApp->mainWindowList().isEmpty()) + if (!rApp->mainWindowList().isEmpty()) tab = rApp->mainWindow()->mainView()->webTab(webview); - if(!tab) + if (!tab) return; m_zoomSlider->setValue(tab->view()->zoomFactor() * 10); |