diff options
Diffstat (limited to 'src')
90 files changed, 1836 insertions, 1813 deletions
| diff --git a/src/adblock/adblockhostmatcher.cpp b/src/adblock/adblockhostmatcher.cpp index 021fe12d..4a29fb9e 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 9b096bb9..d3af2722 100644 --- a/src/adblock/adblockmanager.cpp +++ b/src/adblock/adblockmanager.cpp @@ -46,10 +46,10 @@  AdBlockManager::AdBlockManager(QObject *parent) -        : QObject(parent) -        , _isAdblockEnabled(false) -        , _isHideAdsEnabled(false) -        , _index(0) +    : QObject(parent) +    , _isAdblockEnabled(false) +    , _isHideAdsEnabled(false) +    , _index(0)  {  } @@ -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); @@ -106,7 +106,7 @@ void AdBlockManager::loadSettings(bool checkUpdateDate)      // else      QStringList titles = ReKonfig::subscriptionTitles(); -    foreach(const QString &title, titles) +    foreach(const QString & title, titles)      {          rules = rulesGroup.readEntry(title + "-rules" , QStringList());          loadRules(rules); @@ -116,26 +116,26 @@ void AdBlockManager::loadSettings(bool checkUpdateDate)  void AdBlockManager::loadRules(const QStringList &rules)  { -    foreach(const QString &stringRule, 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,16 +180,16 @@ 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;          return 0;      } -    foreach(const AdBlockRule &filter, _whiteList) +    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; @@ -206,9 +206,9 @@ QNetworkReply *AdBlockManager::block(const QNetworkRequest &request, WebPage *pa          return reply;      } -    foreach(const AdBlockRule &filter, _blackList) +    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,25 +239,25 @@ 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();      // HIDE RULES -    foreach(const QString &filter, _hideList) +    foreach(const QString & filter, _hideList)      {          QWebElementCollection elements = document.findAll(filter);          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);          kDebug() << "DOWNLOADING FROM " << urlString; @@ -297,13 +297,13 @@ void AdBlockManager::updateNextSubscription()  void AdBlockManager::slotResult(KJob *job)  { -    if (job->error()) +    if(job->error())          return;      kDebug() << "SAVING RULES..";      QList<QByteArray> list = _buffer.split('\n');      QStringList ruleList; -    foreach(const QByteArray &ba, list) +    foreach(const QByteArray & ba, list)      {          ruleList << QString(ba);      } @@ -321,7 +321,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,9 +333,9 @@ void AdBlockManager::subscriptionData(KIO::Job* job, const QByteArray& data)  void AdBlockManager::saveRules(const QStringList &rules)  {      QStringList cleanedRules; -    foreach(const QString &r, rules) +    foreach(const QString & r, rules)      { -        if (!r.startsWith('!') && !r.startsWith('[') && !r.isEmpty()) +        if(!r.startsWith('!') && !r.startsWith('[') && !r.isEmpty())              cleanedRules << r;      } @@ -351,11 +351,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/adblocknetworkreply.cpp b/src/adblock/adblocknetworkreply.cpp index 41eb04de..5a5e9d8b 100644 --- a/src/adblock/adblocknetworkreply.cpp +++ b/src/adblock/adblocknetworkreply.cpp @@ -40,7 +40,7 @@  AdBlockNetworkReply::AdBlockNetworkReply(const QNetworkRequest &request, const QString &urlString, QObject *parent) -        : QNetworkReply(parent) +    : QNetworkReply(parent)  {      setOperation(QNetworkAccessManager::GetOperation);      setRequest(request); diff --git a/src/adblock/adblockrule.cpp b/src/adblock/adblockrule.cpp index 87fcb680..fcc5fd8c 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 f5f913dc..336987b0 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 bb68b0c2..7977849b 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")))              m_thirdPartyOption = true; -        foreach(const QString &option, options) +        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) +                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); @@ -94,8 +94,8 @@ bool AdBlockRuleFallbackImpl::match(const QNetworkRequest &request, const QStrin  {      if(!request.hasRawHeader("referer"))          return false; -     -    if (m_thirdPartyOption) + +    if(m_thirdPartyOption)      {          const QString referer = request.rawHeader("referer");          const QString host = request.url().host(); @@ -106,22 +106,22 @@ bool AdBlockRuleFallbackImpl::match(const QNetworkRequest &request, const QStrin      }      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 7f4e40b3..ecd46b1b 100644 --- a/src/adblock/adblockrulenullimpl.cpp +++ b/src/adblock/adblockrulenullimpl.cpp @@ -35,7 +35,7 @@  AdBlockRuleNullImpl::AdBlockRuleNullImpl(const QString &filter) -        : AdBlockRuleImpl(filter) +    : AdBlockRuleImpl(filter)  {  } @@ -51,71 +51,71 @@ 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(','))); -    Q_FOREACH(const QString &option, options) +    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 f3f93204..70b5d03d 100644 --- a/src/adblock/adblockruletextmatchimpl.cpp +++ b/src/adblock/adblockruletextmatchimpl.cpp @@ -35,7 +35,7 @@  AdBlockRuleTextMatchImpl::AdBlockRuleTextMatchImpl(const QString &filter) -        : AdBlockRuleImpl(filter) +    : AdBlockRuleImpl(filter)  {      Q_ASSERT(AdBlockRuleTextMatchImpl::isTextMatchFilter(filter)); @@ -46,10 +46,10 @@ 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...  +    // this basically lets the "first request" to pass...      if(!request.hasRawHeader("referer"))          return false; -     +      Q_UNUSED(encodedUrl);      // Case sensitive compare is faster, but would be incorrect with encodedUrl since      // we do want case insensitive. @@ -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 0d573109..566fea15 100644 --- a/src/analyzer/analyzerpanel.cpp +++ b/src/analyzer/analyzerpanel.cpp @@ -40,8 +40,8 @@  NetworkAnalyzerPanel::NetworkAnalyzerPanel(const QString &title, QWidget *parent) -        : QDockWidget(title, parent) -        , _viewer(new NetworkAnalyzer(this)) +    : QDockWidget(title, parent) +    , _viewer(new NetworkAnalyzer(this))  {      setObjectName("networkAnalyzerDock");      setWidget(_viewer); @@ -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 97ea1240..7decd566 100644 --- a/src/analyzer/networkanalyzer.cpp +++ b/src/analyzer/networkanalyzer.cpp @@ -47,9 +47,9 @@  NetworkAnalyzer::NetworkAnalyzer(QWidget *parent) -        : QWidget(parent) -        , _mapper(new QSignalMapper(this)) -        , _requestList(new QTreeWidget(this)) +    : QWidget(parent) +    , _mapper(new QSignalMapper(this)) +    , _requestList(new QTreeWidget(this))  {      QStringList headers;      headers << i18n("Method") << i18n("URL") << i18n("Response") << i18n("Length") << i18n("Content Type") << i18n("Info"); @@ -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,7 +151,7 @@ void NetworkAnalyzer::clear()  void NetworkAnalyzer::requestFinished(QObject *replyObject)  {      QNetworkReply *reply = qobject_cast<QNetworkReply *>(replyObject); -    if (!reply) +    if(!reply)      {          kDebug() << "Failed to downcast reply";          return; @@ -166,7 +166,7 @@ void NetworkAnalyzer::requestFinished(QObject *replyObject)      // Record the reply headers      QList<QByteArray> headerValues; -    foreach(const QByteArray &header, reply->rawHeaderList()) +    foreach(const QByteArray & header, reply->rawHeaderList())      {          headerValues += reply->rawHeader(header);      } @@ -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())); @@ -203,7 +203,7 @@ void NetworkAnalyzer::showItemDetails(QTreeWidgetItem *item)      QNetworkRequest req = _itemRequestMap[item];      details += i18n("<h3>Request Details</h3>");      details += QL1S("<ul>"); -    foreach(const QByteArray &header, req.rawHeaderList()) +    foreach(const QByteArray & header, req.rawHeaderList())      {          details += QL1S("<li>");          details += QL1S(header); @@ -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 40cfcffe..69a3b0c9 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -70,8 +70,8 @@ using namespace ThreadWeaver;  Application::Application() -        : KUniqueApplication() -        , _privateBrowsingAction(0) +    : KUniqueApplication() +    , _privateBrowsingAction(0)  {      connect(Weaver::instance(), SIGNAL(jobDone(ThreadWeaver::Job*)),              this, SLOT(loadResolvedUrl(ThreadWeaver::Job*))); @@ -95,32 +95,38 @@ 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();      } @@ -129,7 +135,8 @@ 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();      } @@ -159,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... @@ -185,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(); @@ -204,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(); @@ -223,9 +230,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); @@ -244,7 +251,7 @@ int Application::newInstance()          }      } -    if (isFirstLoad) +    if(isFirstLoad)      {          // give me some time to do the other things..          QTimer::singleShot(100, this, SLOT(postLaunch())); @@ -290,14 +297,14 @@ MainWindow *Application::mainWindow()  {      MainWindow *active = qobject_cast<MainWindow*>(QApplication::activeWindow()); -    if (!active) +    if(!active)      {          if(m_mainWindows.isEmpty())              return 0; -        Q_FOREACH (const QWeakPointer<MainWindow> &pointer, m_mainWindows) +        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(); @@ -308,7 +315,7 @@ MainWindow *Application::mainWindow()  HistoryManager *Application::historyManager()  { -    if (m_historyManager.isNull()) +    if(m_historyManager.isNull())      {          m_historyManager = new HistoryManager;      } @@ -318,7 +325,7 @@ HistoryManager *Application::historyManager()  BookmarkProvider *Application::bookmarkProvider()  { -    if (m_bookmarkProvider.isNull()) +    if(m_bookmarkProvider.isNull())      {          m_bookmarkProvider = new BookmarkProvider;      } @@ -328,7 +335,7 @@ BookmarkProvider *Application::bookmarkProvider()  SessionManager *Application::sessionManager()  { -    if (m_sessionManager.isNull()) +    if(m_sessionManager.isNull())      {          m_sessionManager = new SessionManager;      } @@ -338,7 +345,7 @@ SessionManager *Application::sessionManager()  OpenSearchManager *Application::opensearchManager()  { -    if (m_opensearchManager.isNull()) +    if(m_opensearchManager.isNull())      {          m_opensearchManager = new OpenSearchManager;      } @@ -348,7 +355,7 @@ OpenSearchManager *Application::opensearchManager()  IconManager *Application::iconManager()  { -    if (m_iconManager.isNull()) +    if(m_iconManager.isNull())      {          m_iconManager = new IconManager;      } @@ -358,7 +365,7 @@ IconManager *Application::iconManager()  DownloadManager *Application::downloadManager()  { -    if (m_downloadManager.isNull()) +    if(m_downloadManager.isNull())      {          m_downloadManager = new DownloadManager(instance());      } @@ -368,10 +375,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; @@ -384,10 +391,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          { @@ -417,7 +424,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); @@ -431,7 +438,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); @@ -455,7 +462,7 @@ MainWindowList Application::mainWindowList()  AdBlockManager *Application::adblockManager()  { -    if (m_adblockManager.isNull()) +    if(m_adblockManager.isNull())      {          m_adblockManager = new AdBlockManager;      } @@ -469,7 +476,7 @@ void Application::loadResolvedUrl(ThreadWeaver::Job *job)      KUrl url = threadedJob->url();      WebView *view = threadedJob->view(); -    if (view) +    if(view)      {          view->load(url);      } @@ -486,16 +493,16 @@ void Application::newWindow()  } -bool Application::eventFilter( QObject* watched, QEvent* event ) +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); @@ -504,7 +511,7 @@ bool Application::eventFilter( QObject* watched, QEvent* event )          }      } -    return QObject::eventFilter( watched, event ); +    return QObject::eventFilter(watched, event);  } @@ -517,9 +524,9 @@ void Application::updateConfiguration()          MainView *mv = w.data()->mainView();          mv->updateTabBar(); -        mv->tabBar()->setAnimatedTabHighlighting( ReKonfig::animatedTabHighlighting() ); +        mv->tabBar()->setAnimatedTabHighlighting(ReKonfig::animatedTabHighlighting()); -        if (b) +        if(b)              mv->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab);          else              mv->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectRightTab); @@ -566,7 +573,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); @@ -578,7 +585,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"); @@ -588,38 +595,38 @@ void Application::updateConfiguration()      // Applies user/system defined CSS to all open webpages.      ReKonfig::userCSS().isEmpty() -        ? defaultSettings->setUserStyleSheetUrl(KUrl(KStandardDirs::locate("appdata" , "default_rekonq.css"))) -        : defaultSettings->setUserStyleSheetUrl(ReKonfig::userCSS()) +    ? defaultSettings->setUserStyleSheetUrl(KUrl(KStandardDirs::locate("appdata" , "default_rekonq.css"))) +    : defaultSettings->setUserStyleSheetUrl(ReKonfig::userCSS())      ;      // ====== 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());          } @@ -646,17 +653,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); @@ -679,7 +686,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/application.h b/src/application.h index ec377a71..cc9bc433 100644 --- a/src/application.h +++ b/src/application.h @@ -57,7 +57,7 @@ class KAction;  namespace ThreadWeaver  { -    class Job; +class Job;  } @@ -94,7 +94,7 @@ public:      OpenSearchManager *opensearchManager();      IconManager *iconManager();      DownloadManager *downloadManager(); -     +      KAction *privateBrowsingAction()      {          return _privateBrowsingAction; diff --git a/src/bookmarks/bookmarkowner.cpp b/src/bookmarks/bookmarkowner.cpp index da006801..75b5f12d 100644 --- a/src/bookmarks/bookmarkowner.cpp +++ b/src/bookmarks/bookmarkowner.cpp @@ -48,16 +48,16 @@  BookmarkOwner::BookmarkOwner(KBookmarkManager *manager, QObject *parent) -        : QObject(parent) -        , KBookmarkOwner() -        , m_manager(manager) +    : QObject(parent) +    , KBookmarkOwner() +    , m_manager(manager)  {  }  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,19 +146,19 @@ 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;      } -    Q_FOREACH(const KUrl &url, urlList) +    Q_FOREACH(const KUrl & url, urlList)      {          emit openUrl(url, Rekonq::NewFocusedTab);      } @@ -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(""); @@ -378,8 +378,8 @@ KAction* BookmarkOwner::createAction(const QString &text, const QString &icon,  CustomBookmarkAction::CustomBookmarkAction(const KBookmark &bookmark, const KIcon &icon, const QString &text, QObject *parent) -        : KAction(icon, text, parent) -        , m_bookmark(bookmark) +    : KAction(icon, text, parent) +    , m_bookmark(bookmark)  {      connect(this, SIGNAL(triggered()), this, SLOT(onActionTriggered()));  } diff --git a/src/bookmarks/bookmarkprovider.cpp b/src/bookmarks/bookmarkprovider.cpp index fc351320..0d1b1ada 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 ..."; @@ -91,21 +91,21 @@ BookmarkProvider::~BookmarkProvider()  KActionMenu* BookmarkProvider::bookmarkActionMenu(QWidget *parent)  {      kDebug() << "creating a bookmarks action menu..."; -     +      KMenu *menu = new KMenu(parent);      KActionMenu *bookmarkActionMenu = new KActionMenu(menu);      bookmarkActionMenu->setMenu(menu);      bookmarkActionMenu->setText(i18n("&Bookmarks"));      BookmarkMenu *bMenu = new BookmarkMenu(m_manager, m_owner, menu, m_actionCollection);      bMenu->setParent(menu); -     +      return bookmarkActionMenu;  }  void BookmarkProvider::registerBookmarkBar(BookmarkToolBar *toolbar)  { -    if (m_bookmarkToolBars.contains(toolbar)) +    if(m_bookmarkToolBars.contains(toolbar))          return;      m_bookmarkToolBars.append(toolbar); @@ -120,7 +120,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())); @@ -130,13 +130,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();  } @@ -144,7 +144,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);  } @@ -161,8 +161,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; @@ -172,7 +172,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,15 +181,15 @@ KBookmark BookmarkProvider::bookmarkForUrl(const KUrl &url)  void BookmarkProvider::slotBookmarksChanged()  { -    foreach(BookmarkToolBar *bookmarkToolBar, m_bookmarkToolBars) +    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);  } @@ -197,25 +197,25 @@ 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);              BookmarkMenu *bMenu = new BookmarkMenu(bookmarkManager(), bookmarkOwner(), menuAction->menu(), bookmark.address());              bMenu->setParent(menuAction->menu()); -             +              connect(menuAction->menu(), SIGNAL(aboutToShow()), toolBar, SLOT(menuDisplayed()));              connect(menuAction->menu(), SIGNAL(aboutToHide()), toolBar, SLOT(menuHidden()));              toolBar->toolBar()->addAction(menuAction);              toolBar->toolBar()->widgetForAction(menuAction)->installEventFilter(toolBar);          } -        else if (bookmark.isSeparator()) +        else if(bookmark.isSeparator())          {              toolBar->toolBar()->addSeparator();          } @@ -233,38 +233,38 @@ void BookmarkProvider::fillBookmarkBar(BookmarkToolBar *toolBar)  void BookmarkProvider::slotPanelChanged()  { -    foreach(BookmarksPanel *panel, m_bookmarkPanels) +    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      {          QStringList words = text.split(' ');          bool matches = true; -        foreach(const QString &word, words) +        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;      }  } @@ -274,18 +274,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;      } @@ -297,19 +297,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 1def2592..16936682 100644 --- a/src/bookmarks/bookmarkscontextmenu.cpp +++ b/src/bookmarks/bookmarkscontextmenu.cpp @@ -37,9 +37,9 @@  BookmarksContextMenu::BookmarksContextMenu(const KBookmark &bookmark, KBookmarkManager *manager, BookmarkOwner *owner, bool nullForced, QWidget *parent) -        : KBookmarkContextMenu(bookmark, manager, owner, parent) -        , m_bmOwner(owner) -        , m_nullForced(nullForced) +    : KBookmarkContextMenu(bookmark, manager, owner, parent) +    , m_bmOwner(owner) +    , m_nullForced(nullForced)  {  } @@ -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 94a3de94..8ad15309 100644 --- a/src/bookmarks/bookmarkspanel.cpp +++ b/src/bookmarks/bookmarkspanel.cpp @@ -43,9 +43,9 @@  BookmarksPanel::BookmarksPanel(const QString &title, QWidget *parent, Qt::WindowFlags flags) -        : UrlPanel(title, parent, flags) -        , _bkTreeModel(new BookmarksTreeModel(this)) -        , _loadingState(false) +    : UrlPanel(title, parent, flags) +    , _bkTreeModel(new BookmarksTreeModel(this)) +    , _loadingState(false)  {      setObjectName("bookmarksPanel");      setVisible(ReKonfig::showBookmarksPanel()); @@ -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"); @@ -129,19 +129,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); @@ -153,7 +153,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 b3ee8b18..ec91ad3a 100644 --- a/src/bookmarks/bookmarkstoolbar.cpp +++ b/src/bookmarks/bookmarkstoolbar.cpp @@ -47,7 +47,7 @@ BookmarkMenu::BookmarkMenu(KBookmarkManager *manager,                             KBookmarkOwner *owner,                             KMenu *menu,                             KActionCollection* actionCollection) -        : KBookmarkMenu(manager, owner, menu, actionCollection) +    : KBookmarkMenu(manager, owner, menu, actionCollection)  {  } @@ -56,7 +56,7 @@ BookmarkMenu::BookmarkMenu(KBookmarkManager  *manager,                             KBookmarkOwner  *owner,                             KMenu  *parentMenu,                             const QString &parentAddress) -        : KBookmarkMenu(manager, owner, parentMenu, parentAddress) +    : KBookmarkMenu(manager, owner, parentMenu, parentAddress)  {  } @@ -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());  } @@ -158,13 +158,13 @@ void BookmarkMenu::actionHovered()  BookmarkToolBar::BookmarkToolBar(KToolBar *toolBar, QObject *parent) -        : QObject(parent) -        , m_toolBar(toolBar) -        , m_currentMenu(0) -        , m_dragAction(0) -        , m_dropAction(0) -        , m_checkedAction(0) -        , m_filled(false) +    : QObject(parent) +    , m_toolBar(toolBar) +    , m_currentMenu(0) +    , m_dragAction(0) +    , m_dropAction(0) +    , m_checkedAction(0) +    , m_filled(false)  {      toolBar->setContextMenuPolicy(Qt::CustomContextMenu);      connect(toolBar, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenu(const QPoint &))); @@ -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,333 +222,333 @@ 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() -        && !m_currentMenu->rect().contains(m_currentMenu->mapFromGlobal(QCursor::pos()))) +    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())); +            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();          } -         +          return QObject::eventFilter(watched, event);      } -     -    switch (event->type()) + +    switch(event->type())      { -        case QEvent::Show: +    case QEvent::Show: +    { +        if(!m_filled)          { -            if (!m_filled) -            { -                rApp->bookmarkProvider()->fillBookmarkBar(this); -                m_filled = true; -            } +            rApp->bookmarkProvider()->fillBookmarkBar(this); +            m_filled = true;          } -            break; +    } +    break; -        case QEvent::ActionRemoved: +    case QEvent::ActionRemoved: +    { +        QActionEvent *actionEvent = static_cast<QActionEvent*>(event); +        if(actionEvent && actionEvent->action() != m_dropAction)          { -            QActionEvent *actionEvent = static_cast<QActionEvent*>(event); -            if (actionEvent && actionEvent->action() != m_dropAction) +            QWidget *widget = toolBar()->widgetForAction(actionEvent->action()); +            if(widget)              { -                QWidget *widget = toolBar()->widgetForAction(actionEvent->action()); -                if (widget) -                { -                    widget->removeEventFilter(this); -                } +                widget->removeEventFilter(this);              }          } -            break; +    } +    break; -        case QEvent::ParentChange: +    case QEvent::ParentChange: +    { +        QActionEvent *actionEvent = static_cast<QActionEvent*>(event); +        if(actionEvent && actionEvent->action() != m_dropAction)          { -            QActionEvent *actionEvent = static_cast<QActionEvent*>(event); -            if (actionEvent && actionEvent->action() != m_dropAction) +            QWidget *widget = toolBar()->widgetForAction(actionEvent->action()); +            if(widget)              { -                QWidget *widget = toolBar()->widgetForAction(actionEvent->action()); -                if (widget) -                { -                    widget->removeEventFilter(this); -                } +                widget->removeEventFilter(this);              }          } -            break; +    } +    break; -        case QEvent::DragEnter: +    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"))          { -            QDragEnterEvent *dragEvent = static_cast<QDragEnterEvent*>(event); -            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); -                m_dropAction = toolBar()->insertWidget(toolBar()->actionAt(dragEvent->pos()), dropIndicatorWidget); +            QFrame* dropIndicatorWidget = new QFrame(toolBar()); +            dropIndicatorWidget->setFrameShape(QFrame::VLine); +            m_dropAction = toolBar()->insertWidget(toolBar()->actionAt(dragEvent->pos()), dropIndicatorWidget); -                dragEvent->accept(); -            } +            dragEvent->accept();          } -            break; - -        case QEvent::DragLeave: -        { -            QDragLeaveEvent *dragEvent = static_cast<QDragLeaveEvent*>(event); +    } +    break; -            if (m_checkedAction) -            { -                m_checkedAction->setCheckable(false); -                m_checkedAction->setChecked(false); -            } +    case QEvent::DragLeave: +    { +        QDragLeaveEvent *dragEvent = static_cast<QDragLeaveEvent*>(event); -            delete m_dropAction; -            m_dropAction = 0; -            dragEvent->accept(); +        if(m_checkedAction) +        { +            m_checkedAction->setCheckable(false); +            m_checkedAction->setChecked(false);          } -            break; -        case QEvent::DragMove: +        delete m_dropAction; +        m_dropAction = 0; +        dragEvent->accept(); +    } +    break; + +    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"))          { -            QDragMoveEvent *dragEvent = static_cast<QDragMoveEvent*>(event); -            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); +            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)                  { -                    toolBar()->removeAction(m_dropAction); -                    if (m_checkedAction) -                    { -                        m_checkedAction->setCheckable(false); -                        m_checkedAction->setChecked(false); -                    } +                    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); -                            } -                            else -                            { -                                toolBar()->addAction(m_dropAction); -                            } +                            toolBar()->insertAction(toolBar()->actions().at(toolBar()->actions().indexOf(overAction) + 1), m_dropAction);                          }                          else                          { -                            toolBar()->insertAction(overAction, m_dropAction); +                            toolBar()->addAction(m_dropAction);                          }                      }                      else                      { -                        if ((dragEvent->pos().x() - widgetAction->pos().x()) >= (widgetAction->width() * 0.75)) -                        { -                            if (toolBar()->actions().count() >  toolBar()->actions().indexOf(overAction) + 1) -                            { -                                toolBar()->insertAction(toolBar()->actions().at(toolBar()->actions().indexOf(overAction) + 1), m_dropAction); -                            } -                            else -                            { -                                toolBar()->addAction(m_dropAction); -                            } -                        } -                        else if ((dragEvent->pos().x() - widgetAction->pos().x()) <= (widgetAction->width() * 0.25)) +                        toolBar()->insertAction(overAction, m_dropAction); +                    } +                } +                else +                { +                    if((dragEvent->pos().x() - widgetAction->pos().x()) >= (widgetAction->width() * 0.75)) +                    { +                        if(toolBar()->actions().count() >  toolBar()->actions().indexOf(overAction) + 1)                          { -                            toolBar()->insertAction(overAction, m_dropAction); +                            toolBar()->insertAction(toolBar()->actions().at(toolBar()->actions().indexOf(overAction) + 1), m_dropAction);                          }                          else                          { -                            overAction->setCheckable(true); -                            overAction->setChecked(true); -                            m_checkedAction = overAction; +                            toolBar()->addAction(m_dropAction);                          }                      } - -                    dragEvent->accept(); +                    else if((dragEvent->pos().x() - widgetAction->pos().x()) <= (widgetAction->width() * 0.25)) +                    { +                        toolBar()->insertAction(overAction, m_dropAction); +                    } +                    else +                    { +                        overAction->setCheckable(true); +                        overAction->setChecked(true); +                        m_checkedAction = overAction; +                    }                  } + +                dragEvent->accept();              }          } -            break; +    } +    break; -        case QEvent::Drop: -        { -            QDropEvent *dropEvent = static_cast<QDropEvent*>(event); -            KBookmark bookmark; -            KBookmarkGroup root = rApp->bookmarkProvider()->bookmarkManager()->toolbar(); +    case QEvent::Drop: +    { +        QDropEvent *dropEvent = static_cast<QDropEvent*>(event); +        KBookmark bookmark; +        KBookmarkGroup root = rApp->bookmarkProvider()->bookmarkManager()->toolbar(); -            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()) -                    return false; -            } -            else if (dropEvent->mimeData()->hasFormat("text/uri-list")) +        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()) +                return false; +        } +        else if(dropEvent->mimeData()->hasFormat("text/uri-list")) +        { +            kDebug() << "DROP is URL"; +            QString url = dropEvent->mimeData()->urls().at(0).toString(); +            QString title = url.contains(rApp->mainWindow()->currentTab()->url().url()) +                            ? rApp->mainWindow()->currentTab()->view()->title() +                            : url; +            bookmark = root.addBookmark(title, url); +        } +        else if(dropEvent->mimeData()->hasFormat("text/plain")) +        { +            kDebug() << "DROP is TEXT"; +            QString url = dropEvent->mimeData()->text(); +            KUrl u(url); +            if(u.isValid())              { -                kDebug() << "DROP is URL"; -                QString url = dropEvent->mimeData()->urls().at(0).toString(); -                QString title = url.contains( rApp->mainWindow()->currentTab()->url().url() ) -                    ? rApp->mainWindow()->currentTab()->view()->title() -                    : url; +                QString title = url.contains(rApp->mainWindow()->currentTab()->url().url()) +                                ? rApp->mainWindow()->currentTab()->view()->title() +                                : url;                  bookmark = root.addBookmark(title, url);              } -            else if (dropEvent->mimeData()->hasFormat("text/plain")) +        } +        else +        { +            return false; +        } + +        QAction *destAction = toolBar()->actionAt(dropEvent->pos()); +        if(destAction && destAction == m_dropAction) +        { +            if(toolBar()->actions().indexOf(m_dropAction) > 0)              { -                kDebug() << "DROP is TEXT"; -                QString url = dropEvent->mimeData()->text(); -                KUrl u(url); -                if (u.isValid()) -                { -                    QString title = url.contains( rApp->mainWindow()->currentTab()->url().url() ) -                        ? rApp->mainWindow()->currentTab()->view()->title() -                        : url; -                    bookmark = root.addBookmark(title, url); -                } +                destAction = toolBar()->actions().at(toolBar()->actions().indexOf(m_dropAction) - 1);              }              else              { -                return false; +                destAction = toolBar()->actions().at(1);              } +        } -            QAction *destAction = toolBar()->actionAt(dropEvent->pos()); -            if (destAction && destAction == m_dropAction) -            { -                if (toolBar()->actions().indexOf(m_dropAction) > 0) -                { -                    destAction = toolBar()->actions().at(toolBar()->actions().indexOf(m_dropAction) - 1); -                } -                else -                { -                    destAction = toolBar()->actions().at(1); -                } -            } +        if(destAction) +        { +            KBookmarkActionInterface *destBookmarkAction = dynamic_cast<KBookmarkActionInterface *>(destAction); +            QWidget *widgetAction = toolBar()->widgetForAction(destAction); -            if (destAction) +            if(destBookmarkAction && !destBookmarkAction->bookmark().isNull() && widgetAction +                    && bookmark.address() != destBookmarkAction->bookmark().address())              { -                KBookmarkActionInterface *destBookmarkAction = dynamic_cast<KBookmarkActionInterface *>(destAction); -                QWidget *widgetAction = toolBar()->widgetForAction(destAction); +                KBookmark destBookmark = destBookmarkAction->bookmark(); -                if (destBookmarkAction && !destBookmarkAction->bookmark().isNull() && widgetAction -                        && bookmark.address() != destBookmarkAction->bookmark().address()) +                if(!destBookmark.isGroup())                  { -                    KBookmark destBookmark = destBookmarkAction->bookmark(); - -                    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); -                        } -                        else -                        { -                            root.moveBookmark(bookmark, destBookmark.parentGroup().previous(destBookmark)); -                        } +                        root.moveBookmark(bookmark, destBookmark);                      }                      else                      { -                        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)) -                        { -                            root.moveBookmark(bookmark, destBookmark.parentGroup().previous(destBookmark)); -                        } -                        else -                        { -                            destBookmark.toGroup().addBookmark(bookmark); -                        } +                        root.moveBookmark(bookmark, destBookmark.parentGroup().previous(destBookmark));                      } - - -                    rApp->bookmarkProvider()->bookmarkManager()->emitChanged();                  } -            } -            else -            { -                root.deleteBookmark(bookmark); -                bookmark = root.addBookmark(bookmark); -                if (dropEvent->pos().x() < toolBar()->widgetForAction(toolBar()->actions().first())->pos().x()) +                else                  { -                    root.moveBookmark(bookmark, KBookmark()); +                    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)) +                    { +                        root.moveBookmark(bookmark, destBookmark.parentGroup().previous(destBookmark)); +                    } +                    else +                    { +                        destBookmark.toGroup().addBookmark(bookmark); +                    }                  } +                  rApp->bookmarkProvider()->bookmarkManager()->emitChanged();              } -            dropEvent->accept();          } -            break; +        else +        { +            root.deleteBookmark(bookmark); +            bookmark = root.addBookmark(bookmark); +            if(dropEvent->pos().x() < toolBar()->widgetForAction(toolBar()->actions().first())->pos().x()) +            { +                root.moveBookmark(bookmark, KBookmark()); +            } -        default: -            break; +            rApp->bookmarkProvider()->bookmarkManager()->emitChanged(); +        } +        dropEvent->accept(); +    } +    break; + +    default: +        break;      }      // 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)); +        case QEvent::MouseButtonPress: // drag handling +        { +            QPoint pos = toolBar()->mapFromGlobal(QCursor::pos()); +            KBookmarkActionInterface *action = dynamic_cast<KBookmarkActionInterface *>(toolBar()->actionAt(pos)); -                if (action) -                { -                    m_dragAction = toolBar()->actionAt(pos); -                    m_startDragPos = pos; +            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()) -                        return true; -                } +                // The menu is displayed only when the mouse button is released +                if(action->bookmark().isGroup()) +                    return true;              } -                break; +        } +        break; -            case QEvent::MouseMove: +        case QEvent::MouseMove: +        { +            int distance = (toolBar()->mapFromGlobal(QCursor::pos()) - m_startDragPos).manhattanLength(); +            if(!m_currentMenu && distance >= QApplication::startDragDistance())              { -                int distance = (toolBar()->mapFromGlobal(QCursor::pos()) - m_startDragPos).manhattanLength(); -                if (!m_currentMenu && distance >= QApplication::startDragDistance()) -                { -                    startDrag(); -                } +                startDrag();              } -                break; +        } +        break; -            case QEvent::MouseButtonRelease: -            { -                int distance = (toolBar()->mapFromGlobal(QCursor::pos()) - m_startDragPos).manhattanLength(); -                KBookmarkActionInterface *action = dynamic_cast<KBookmarkActionInterface *>(toolBar()->actionAt(m_startDragPos)); +        case QEvent::MouseButtonRelease: +        { +            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()) -                { -                    KBookmarkActionMenu *menu = dynamic_cast<KBookmarkActionMenu *>(toolBar()->actionAt(m_startDragPos)); -                    QPoint actionPos = toolBar()->mapToGlobal(toolBar()->widgetForAction(menu)->pos()); -                    menu->menu()->popup(QPoint(actionPos.x(), actionPos.y() + toolBar()->widgetForAction(menu)->height())); -                } +            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()); +                menu->menu()->popup(QPoint(actionPos.x(), actionPos.y() + toolBar()->widgetForAction(menu)->height()));              } -                break; +        } +        break; -            default: -                break; +        default: +            break;          }      } @@ -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 1e2e462f..f29e866f 100644 --- a/src/bookmarks/bookmarkstreemodel.cpp +++ b/src/bookmarks/bookmarkstreemodel.cpp @@ -44,8 +44,8 @@  BtmItem::BtmItem(const KBookmark &bm) -        : m_parent(0) -        , m_kbm(bm) +    : m_parent(0) +    , m_kbm(bm)  {  } @@ -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; @@ -163,8 +163,8 @@ KBookmark BtmItem::getBkm() const  BookmarksTreeModel::BookmarksTreeModel(QObject *parent) -        : QAbstractItemModel(parent) -        , m_root(0) +    : QAbstractItemModel(parent) +    , m_root(0)  {      resetModel();      connect(rApp->bookmarkProvider()->bookmarkManager(), SIGNAL(changed(const QString &, const QString &)), this, SLOT(bookmarksChanged(const QString &))); @@ -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();      } @@ -344,13 +344,13 @@ void BookmarksTreeModel::bookmarksChanged(const QString &groupAddress)          QStringList indexChain(groupAddress.split('/', QString::SkipEmptyParts));          bool ok;          int i; -        foreach(const QString &sIndex, indexChain) +        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 b908ac8d..982c8143 100644 --- a/src/clicktoflash.cpp +++ b/src/clicktoflash.cpp @@ -41,8 +41,8 @@  ClickToFlash::ClickToFlash(const QUrl &pluginUrl, QWidget *parent) -        : QWidget(parent) -        , m_url(pluginUrl) +    : QWidget(parent) +    , m_url(pluginUrl)  {      QHBoxLayout *l = new QHBoxLayout(this);      setLayout(l); @@ -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); @@ -116,19 +116,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 d1f8ec9e..9570e4f9 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,34 +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();      }  } @@ -152,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/downloaditem.h b/src/downloaditem.h index 80f905bb..05e4d438 100644 --- a/src/downloaditem.h +++ b/src/downloaditem.h @@ -58,16 +58,28 @@ class DownloadItem : public QObject  public:      explicit DownloadItem(const QString &srcUrl, const QString &destUrl, const QDateTime &d, QObject *parent = 0); -    inline QDateTime dateTime() const { return m_dateTime; } -    inline QString originUrl() const { return m_srcUrlString; } +    inline QDateTime dateTime() const +    { +        return m_dateTime; +    } +    inline QString originUrl() const +    { +        return m_srcUrlString; +    }      QString destinationUrl() const;      QString fileName() const;      QString fileDirectory() const;      QString icon() const;      // Necessary to provide i18nized strings to javascript. -    Q_INVOKABLE QString i18nOpenDir() const { return i18n("Open directory"); } -    Q_INVOKABLE QString i18nOpenFile() const { return i18n("Open file"); } +    Q_INVOKABLE QString i18nOpenDir() const +    { +        return i18n("Open directory"); +    } +    Q_INVOKABLE QString i18nOpenFile() const +    { +        return i18n("Open file"); +    }      // For transfer control and notification      void setKGetTransferDbusPath(const QString &path); diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 490637bf..25018a7d 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/downloadmanager.h b/src/downloadmanager.h index d96c46de..2955904c 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -49,7 +49,10 @@ class REKONQ_TESTS_EXPORT DownloadManager : public QObject  public:      DownloadManager(QObject *parent = 0); -    DownloadList downloads() const { return m_downloadList; } +    DownloadList downloads() const +    { +        return m_downloadList; +    }      DownloadItem* addDownload(const QString &srcUrl, const QString &destUrl);      bool clearDownloadsHistory(); diff --git a/src/filterurljob.cpp b/src/filterurljob.cpp index 65eab8cc..e6fde179 100644 --- a/src/filterurljob.cpp +++ b/src/filterurljob.cpp @@ -35,11 +35,11 @@ KUriFilter *FilterUrlJob::s_uriFilter;  FilterUrlJob::FilterUrlJob(WebView *view, const QString &urlString, QObject *parent) -        : Job(parent) -        , _view(view) -        , _urlString(urlString) +    : Job(parent) +    , _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 8272a2d3..ae10de3a 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -53,12 +53,12 @@  FindBar::FindBar(MainWindow *window) -        : QWidget(window) -        , m_mainWindow(window) -        , m_lineEdit(new KLineEdit(this)) -        , m_hideTimer(new QTimer(this)) -        , m_matchCase(new QCheckBox(i18n("&Match case"), this)) -        , m_highlightAll(new QCheckBox(i18n("&Highlight all"), this)) +    : QWidget(window) +    , m_mainWindow(window) +    , m_lineEdit(new KLineEdit(this)) +    , m_hideTimer(new QTimer(this)) +    , m_matchCase(new QCheckBox(i18n("&Match case"), this)) +    , m_highlightAll(new QCheckBox(i18n("&Highlight all"), this))  {      QHBoxLayout *layout = new QHBoxLayout; @@ -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 935453d9..c490ac46 100644 --- a/src/history/autosaver.cpp +++ b/src/history/autosaver.cpp @@ -41,16 +41,16 @@ const int MAX_TIME_LIMIT = 1000 * 15; // seconds  AutoSaver::AutoSaver(QObject *parent) -        : QObject(parent) -        , m_timer(new QBasicTimer) -        , m_firstChange(new QTime) +    : QObject(parent) +    , m_timer(new QBasicTimer) +    , m_firstChange(new QTime)  {  }  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 8113add4..742e957c 100644 --- a/src/history/historymanager.cpp +++ b/src/history/historymanager.cpp @@ -63,10 +63,10 @@ static const unsigned int HISTORY_VERSION = 24;  HistoryManager::HistoryManager(QObject *parent) -        : QWebHistoryInterface(parent) -        , m_saveTimer(new AutoSaver(this)) -        , m_historyLimit(0) -        , m_historyTreeModel(0) +    : QWebHistoryInterface(parent) +    , m_saveTimer(new AutoSaver(this)) +    , m_historyLimit(0) +    , m_historyTreeModel(0)  {      connect(this, SIGNAL(entryAdded(const HistoryItem &)), m_saveTimer, SLOT(changeOccurred()));      connect(this, SIGNAL(entryRemoved(const HistoryItem &)), m_saveTimer, SLOT(changeOccurred())); @@ -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().dateTime;          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); @@ -248,23 +248,23 @@ QList<HistoryItem> HistoryManager::find(const QString &text)      QList<HistoryItem> list;      QStringList urlKeys = m_historyFilterModel->keys(); -    Q_FOREACH(const QString &url, urlKeys) +    Q_FOREACH(const QString & url, urlKeys)      {          int index = m_historyFilterModel->historyLocation(url);          HistoryItem item = m_history.at(index);          QStringList words = text.split(' ');          bool matches = true; -        foreach(const QString &word, words) +        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; @@ -368,29 +368,29 @@ void HistoryManager::load()              continue;          }; -        if (!item.dateTime.isValid()) +        if(!item.dateTime.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(); @@ -402,19 +402,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"); @@ -424,7 +424,7 @@ void HistoryManager::save()      QTemporaryFile tempFile;      tempFile.setAutoRemove(false);      bool open = false; -    if (saveAll) +    if(saveAll)      {          open = tempFile.open();      } @@ -433,15 +433,15 @@ 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()); +                 << (saveAll ? tempFile.fileName() : historyFile.fileName());          return;      }      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); @@ -451,13 +451,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/historymanager.h b/src/history/historymanager.h index 8650bd14..e22b7042 100644 --- a/src/history/historymanager.h +++ b/src/history/historymanager.h @@ -63,10 +63,10 @@ public:                           const QDateTime &d = QDateTime(),                           const QString &t = QString()                          ) -            : title(t) -            , url(u) -            , dateTime(d) -            , visitCount(1) +        : title(t) +        , url(u) +        , dateTime(d) +        , visitCount(1)      {}      inline bool operator==(const HistoryItem &other) const diff --git a/src/history/historymodels.cpp b/src/history/historymodels.cpp index 2cab8efb..e78c3ac1 100644 --- a/src/history/historymodels.cpp +++ b/src/history/historymodels.cpp @@ -59,8 +59,8 @@  HistoryModel::HistoryModel(HistoryManager *history, QObject *parent) -        : QAbstractTableModel(parent) -        , m_historyManager(history) +    : QAbstractTableModel(parent) +    , m_historyManager(history)  {      Q_ASSERT(m_historyManager);      connect(m_historyManager, SIGNAL(historyReset()), this, SLOT(historyReset())); @@ -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.dateTime; @@ -127,14 +127,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;              } @@ -144,13 +144,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.dateTime.toString(Qt::SystemLocaleShortDate) + '\n' + item.url;          return tooltip; @@ -173,12 +173,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); @@ -192,8 +192,8 @@ bool HistoryModel::removeRows(int row, int count, const QModelIndex &parent)  HistoryFilterModel::HistoryFilterModel(QAbstractItemModel *sourceModel, QObject *parent) -        : QAbstractProxyModel(parent) -        , m_loaded(false) +    : QAbstractProxyModel(parent) +    , m_loaded(false)  {      setSourceModel(sourceModel);  } @@ -202,7 +202,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);  } @@ -216,7 +216,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 &)), @@ -229,7 +229,7 @@ void HistoryFilterModel::setSourceModel(QAbstractItemModel *newSourceModel)      QAbstractProxyModel::setSourceModel(newSourceModel); -    if (sourceModel()) +    if(sourceModel())      {          m_loaded = false;          connect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); @@ -265,7 +265,7 @@ void HistoryFilterModel::sourceReset()  int HistoryFilterModel::rowCount(const QModelIndex &parent) const  {      load(); -    if (parent.isValid()) +    if(parent.isValid())          return 0;      return m_historyHash.count();  } @@ -289,7 +289,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 @@ -299,15 +299,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()); @@ -317,7 +317,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(); @@ -333,16 +333,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; @@ -356,19 +356,19 @@ void HistoryFilterModel::sourceRowsInserted(const QModelIndex &parent, int start  {      //Q_ASSERT(start == end && start == 0);      Q_UNUSED(end); -     +      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(); @@ -398,7 +398,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)), @@ -412,7 +412,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;  } @@ -422,7 +422,7 @@ bool HistoryFilterModel::removeRows(int row, int count, const QModelIndex &paren  HistoryTreeModel::HistoryTreeModel(QAbstractItemModel *sourceModel, QObject *parent) -        : QAbstractProxyModel(parent) +    : QAbstractProxyModel(parent)  {      setSourceModel(sourceModel);  } @@ -436,29 +436,29 @@ 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); @@ -477,24 +477,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; @@ -515,15 +515,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();      } @@ -534,7 +534,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()); @@ -543,12 +543,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);  } @@ -557,7 +557,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);  } @@ -566,7 +566,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;  } @@ -574,7 +574,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;  } @@ -582,10 +582,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()); @@ -594,11 +594,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;          }      } @@ -608,7 +608,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())); @@ -620,7 +620,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())); @@ -645,7 +645,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(); @@ -655,7 +655,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(); @@ -670,15 +670,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()); @@ -691,28 +691,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); @@ -724,7 +724,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 44cd9f96..d9a1afa9 100644 --- a/src/history/historypanel.cpp +++ b/src/history/historypanel.cpp @@ -49,7 +49,7 @@  HistoryPanel::HistoryPanel(const QString &title, QWidget *parent, Qt::WindowFlags flags) -        : UrlPanel(title, parent, flags) +    : UrlPanel(title, parent, flags)  {      setObjectName("historyPanel");      setVisible(ReKonfig::showHistoryPanel()); @@ -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 c4082d27..18e31f6e 100644 --- a/src/iconmanager.cpp +++ b/src/iconmanager.cpp @@ -49,7 +49,7 @@  IconManager::IconManager(QObject *parent) -        : QObject(parent) +    : QObject(parent)  {      _faviconsDir = KStandardDirs::locateLocal("cache" , "favicons/" , true);  } @@ -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,28 +97,28 @@ 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")))      {          kDebug() << "No http/https site..."; -        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))      {          kDebug() << "Private browsing, private icon..."; -        if (notify) +        if(notify)              emit iconChanged();          return;      }      // check if icon exists -    if (!KMimeType::favIconForUrl(url).isEmpty()) +    if(!KMimeType::favIconForUrl(url).isEmpty())      {          kDebug() << "icon JUST present. Aborting..."; -        if (notify) +        if(notify)              emit iconChanged();          return;      } @@ -132,13 +132,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) @@ -153,7 +153,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 *))); @@ -170,7 +170,7 @@ void IconManager::clearIconCache()  {      QDir d(_faviconsDir);      QStringList favicons = d.entryList(); -    Q_FOREACH(const QString &fav, favicons) +    Q_FOREACH(const QString & fav, favicons)      {          d.remove(fav);      } @@ -179,7 +179,7 @@ void IconManager::clearIconCache()  void IconManager::doLastStuffs(KJob *j)  { -    if (j->error()) +    if(j->error())      {          kDebug() << "FAVICON JOB ERROR";          return; @@ -190,14 +190,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(); @@ -205,13 +205,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(); @@ -219,7 +219,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 422025aa..bde1e2f5 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 fb5e3a97..587717f1 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -60,11 +60,11 @@  QString temporaryUglyHackString = "";  MainView::MainView(MainWindow *parent) -        : KTabWidget(parent) -        , m_widgetBar(new StackedUrlBar(this)) -        , m_addTabButton(0) -        , m_currentTabIndex(0) -        , m_parentWindow(parent) +    : KTabWidget(parent) +    , m_widgetBar(new StackedUrlBar(this)) +    , m_addTabButton(0) +    , m_currentTabIndex(0) +    , m_parentWindow(parent)  {      // setting tabbar      TabBar *tabBar = new TabBar(this); @@ -101,9 +101,9 @@ MainView::MainView(MainWindow *parent)  void MainView::postLaunch()  {      QStringList list = rApp->sessionManager()->closedSites(); -    Q_FOREACH(const QString &line, list) +    Q_FOREACH(const QString & line, list)      { -        if (line.startsWith(QL1S("about"))) +        if(line.startsWith(QL1S("about")))              break;          QString title = line;          QString url = title; @@ -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,16 +242,16 @@ 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)      WebTab *oldTab = this->webTab(m_currentTabIndex); -     +      // 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();          } @@ -401,17 +401,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);      } @@ -422,9 +422,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(); @@ -439,14 +439,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 @@ -462,36 +462,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);      } @@ -502,13 +502,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();  } @@ -517,22 +517,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();      } @@ -543,14 +543,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();      } @@ -558,12 +558,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); @@ -576,7 +576,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); @@ -596,21 +596,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('&'));  } @@ -619,11 +619,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(); @@ -633,7 +633,7 @@ void MainView::webViewUrlChanged(const QUrl &url)  void MainView::nextTab()  {      int next = currentIndex() + 1; -    if (next == count()) +    if(next == count())          next = 0;      setCurrentIndex(next);  } @@ -642,7 +642,7 @@ void MainView::nextTab()  void MainView::previousTab()  {      int next = currentIndex() - 1; -    if (next < 0) +    if(next < 0)          next = count() - 1;      setCurrentIndex(next);  } @@ -650,7 +650,7 @@ void MainView::previousTab()  void MainView::openLastClosedTab()  { -    if (m_recentlyClosedTabs.isEmpty()) +    if(m_recentlyClosedTabs.isEmpty())          return;      const HistoryItem item = m_recentlyClosedTabs.takeFirst(); @@ -661,7 +661,7 @@ void MainView::openLastClosedTab()  void MainView::openClosedTab()  {      KAction *action = qobject_cast<KAction *>(sender()); -    if (action) +    if(action)      {          rApp->loadUrl(action->data().toUrl(), Rekonq::NewTab); @@ -675,33 +675,33 @@ void MainView::openClosedTab()  void MainView::switchToTab(const int index)  { -    if (index <= 0 || index > count()) +    if(index <= 0 || index > count())          return; -    setCurrentIndex(index-1); +    setCurrentIndex(index - 1);  }  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)); +    KUrl url = KUrl(urls.at(index - 1));      rApp->loadUrl(url);  }  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); @@ -723,15 +723,15 @@ 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();      kDebug() << "detaching tab with url: " << u; -    if (u.scheme() == QL1S("about")) +    if(u.scheme() == QL1S("about"))      {          closeTab(index);          rApp->loadUrl(u, Rekonq::NewWindow); @@ -743,7 +743,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 a419151c..b21e7f0e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -99,22 +99,22 @@  MainWindow::MainWindow() -        : KXmlGuiWindow() -        , m_view(new MainView(this)) -        , m_findBar(new FindBar(this)) -        , m_zoomBar(new ZoomBar(this)) -        , m_historyPanel(0) -        , m_bookmarksPanel(0) -        , m_webInspectorPanel(0) -        , m_analyzerPanel(0) -        , m_historyBackMenu(0) -        , m_historyForwardMenu(0) -        , m_userAgentMenu(new KMenu(this)) -        , m_bookmarksBar(0) -        , m_popup(new KPassivePopup(this)) -        , m_hidePopupTimer(new QTimer(this)) -        , m_toolsMenu(0) -        , m_developerMenu(0) +    : KXmlGuiWindow() +    , m_view(new MainView(this)) +    , m_findBar(new FindBar(this)) +    , m_zoomBar(new ZoomBar(this)) +    , m_historyPanel(0) +    , m_bookmarksPanel(0) +    , m_webInspectorPanel(0) +    , m_analyzerPanel(0) +    , m_historyBackMenu(0) +    , m_historyForwardMenu(0) +    , m_userAgentMenu(new KMenu(this)) +    , m_bookmarksBar(0) +    , m_popup(new KPassivePopup(this)) +    , m_hidePopupTimer(new QTimer(this)) +    , m_toolsMenu(0) +    , m_developerMenu(0)  {      // creating a centralWidget containing panel, m_view and the hidden findbar      QWidget *centralWidget = new QWidget; @@ -148,7 +148,7 @@ MainWindow::MainWindow()      // disable help menu, as we'll load it on our own...      setHelpMenuEnabled(false); -         +      // a call to KXmlGuiWindow::setupGUI() populates the GUI      // with actions, using KXMLGUI.      // It also applies the saved mainwindow settings, if any, and ask the @@ -170,7 +170,7 @@ MainWindow::MainWindow()  MainWindow::~MainWindow()  {      m_hidePopupTimer->stop(); -     +      rApp->bookmarkProvider()->removeBookmarkBar(m_bookmarksBar);      rApp->bookmarkProvider()->removeBookmarkPanel(m_bookmarksPanel);      rApp->removeMainWindow(this); @@ -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); @@ -682,7 +682,7 @@ void MainWindow::fileSaveAs()          return;      } -     +      KIO::Job *job = KIO::file_copy(srcUrl, KUrl(destUrl), -1, KIO::Overwrite);      job->addMetaData("MaxCacheSize", "0");  // Don't store in http cache.      job->addMetaData("cache", "cache");     // Use entry from cache if available. @@ -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 @@ -714,7 +714,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()); @@ -727,9 +727,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)"));          } @@ -740,7 +740,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));          } @@ -760,7 +760,7 @@ void MainWindow::fileOpen()                         this,                         i18n("Open Web Resource")); -    if (filePath.isEmpty()) +    if(filePath.isEmpty())          return;      rApp->loadUrl(filePath); @@ -769,17 +769,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(); @@ -792,7 +792,7 @@ void MainWindow::printRequested(QWebFrame *frame)      }      QWebFrame *printFrame = 0; -    if (frame == 0) +    if(frame == 0)      {          printFrame = currentTab()->page()->mainFrame();      } @@ -812,7 +812,7 @@ void MainWindow::printRequested(QWebFrame *frame)  void MainWindow::find(const QString & search)  { -    if (!currentTab()) +    if(!currentTab())          return;      m_lastSearch = search; @@ -823,7 +823,7 @@ void MainWindow::find(const QString & search)  void MainWindow::matchCaseUpdate()  { -    if (!currentTab()) +    if(!currentTab())          return;      currentTab()->view()->findText(m_lastSearch, QWebPage::FindBackward); @@ -834,14 +834,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(); @@ -849,7 +849,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); @@ -858,13 +858,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); @@ -875,11 +875,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); @@ -889,16 +889,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); @@ -929,10 +929,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(); @@ -954,11 +954,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();      }  } @@ -966,7 +966,7 @@ void MainWindow::setWidgetsVisible(bool makeVisible)  QString MainWindow::selectedText() const  { -    if (!currentTab()) +    if(!currentTab())          return QString();      return currentTab()->view()->selectedText(); @@ -976,8 +976,8 @@ QString MainWindow::selectedText() const  void MainWindow::viewPageSource()  {      WebTab * w = currentTab(); -     -    if (!w) + +    if(!w)          return;      KUrl url = w->url(); @@ -991,7 +991,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; @@ -1008,7 +1008,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); @@ -1025,7 +1025,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")); @@ -1053,22 +1053,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);      } @@ -1086,22 +1086,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);      } @@ -1117,14 +1117,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; @@ -1137,13 +1137,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(); @@ -1152,7 +1152,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(); @@ -1167,13 +1167,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; @@ -1182,7 +1182,7 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status)      m_hidePopupTimer->stop(); -    switch (status) +    switch(status)      {      case Rekonq::Url:          break; @@ -1204,8 +1204,8 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status)      // setting popup size      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()) +    QSize labelSize(label->fontMetrics().width(msg) + 2 * margin, label->fontMetrics().height() + 2 * margin); +    if(labelSize.width() > width())      {          labelSize.setWidth(width());          label->setText(label->fontMetrics().elidedText(msg, Qt::ElideMiddle, width())); @@ -1218,7 +1218,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); @@ -1227,7 +1227,7 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status)      //TODO: detect QStyle sizeHint, instead of fixed 17      int hScrollbarSize = horizontalScrollbarIsVisible ? 17 : 0;      int vScrollbarSize = verticalScrollbarIsVisible ? 17 : 0; -     +      QPoint webViewOrigin = tab->view()->mapToGlobal(QPoint(0, 0));      QPoint mousePos = tab->mapToGlobal(tab->view()->mousePos()); @@ -1235,18 +1235,18 @@ 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();      } -     +      m_popup->show(QPoint(x, y));  } @@ -1273,7 +1273,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()); @@ -1283,40 +1283,40 @@ 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");              QDir cacheDir(path);              QStringList fileList = cacheDir.entryList(); -            foreach(const QString &str, fileList) +            foreach(const QString & str, fileList)              {                  QFile file(path + str);                  file.remove(); @@ -1330,7 +1330,7 @@ void MainWindow::clearPrivateData()  void MainWindow::aboutToShowBackMenu()  {      m_historyBackMenu->clear(); -    if (!currentTab()) +    if(!currentTab())          return;      QWebHistory *history = currentTab()->view()->history();      int pivot = history->currentItemIndex(); @@ -1338,10 +1338,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); @@ -1352,7 +1352,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); @@ -1369,7 +1369,7 @@ void MainWindow::aboutToShowForwardMenu()  {      m_historyForwardMenu->clear(); -    if (!currentTab()) +    if(!currentTab())          return;      QWebHistory *history = currentTab()->view()->history(); @@ -1379,10 +1379,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); @@ -1393,7 +1393,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); @@ -1409,12 +1409,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); @@ -1431,7 +1431,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; @@ -1443,7 +1443,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; @@ -1490,7 +1490,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); @@ -1499,7 +1499,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; @@ -1523,26 +1523,26 @@ 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, -                        i18n("Wanna close the window or the whole app?"), -                        i18n("Application/Window closing..."), -                        KGuiItem(i18n("C&lose Current Window"), KIcon("window-close")), -                        KStandardGuiItem::quit(), -                        KStandardGuiItem::cancel(), -                        "confirmClosingMultipleWindows" +                         this, +                         i18n("Wanna close the window or the whole app?"), +                         i18n("Application/Window closing..."), +                         KGuiItem(i18n("C&lose Current Window"), KIcon("window-close")), +                         KStandardGuiItem::quit(), +                         KStandardGuiItem::cancel(), +                         "confirmClosingMultipleWindows"                       ); -        switch (answer) +        switch(answer)          {          case KMessageBox::Yes:              return true; @@ -1571,13 +1571,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()));      } @@ -1600,9 +1600,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); @@ -1611,9 +1611,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/mainwindow.h b/src/mainwindow.h index 2f59211c..e7a52074 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -181,7 +181,7 @@ private Q_SLOTS:      void enableNetworkAnalysis(bool);      void setEditable(bool); -     +      void initBookmarkBar();      void updateToolsMenu(); diff --git a/src/messagebar.cpp b/src/messagebar.cpp index 4cf02734..0e89ac56 100644 --- a/src/messagebar.cpp +++ b/src/messagebar.cpp @@ -43,22 +43,22 @@ MessageBar::MessageBar(const QString &message, QWidget *parent)  {      connect(this, SIGNAL(accepted()), this, SLOT(hideAndDelete()));      connect(this, SIGNAL(rejected()), this, SLOT(hideAndDelete())); -     +      setMessageType(KMessageWidget::Warning); -     +      QSize sz = size(); -    sz.setWidth( qobject_cast<QWidget *>(parent)->size().width() ); +    sz.setWidth(qobject_cast<QWidget *>(parent)->size().width());      resize(sz); -     +      setCloseButtonVisible(false); -     -    setText( message ); -    QAction *acceptAction = new QAction( i18n("Yes"), this ); +    setText(message); + +    QAction *acceptAction = new QAction(i18n("Yes"), this);      connect(acceptAction, SIGNAL(triggered(bool)), this, SIGNAL(accepted()));      addAction(acceptAction); -    QAction *rejectAction = new QAction( i18n("No"), this ); +    QAction *rejectAction = new QAction(i18n("No"), this);      connect(rejectAction, SIGNAL(triggered(bool)), this, SIGNAL(rejected()));      addAction(rejectAction);  } diff --git a/src/messagebar.h b/src/messagebar.h index 6125bfa1..bbf5d5d4 100644 --- a/src/messagebar.h +++ b/src/messagebar.h @@ -44,7 +44,7 @@ public:  private Q_SLOTS:      void hideAndDelete(); -     +  Q_SIGNALS:      void accepted();      void rejected(); diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index 78a880e7..3c03657c 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -41,12 +41,12 @@  NetworkAccessManager::NetworkAccessManager(QObject *parent) -        : AccessManager(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); @@ -84,16 +84,16 @@ QNetworkReply *NetworkAccessManager::createRequest(QNetworkAccessManager::Operat          req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);          break;      } -     +      // 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 2b7de0bf..082070bb 100644 --- a/src/newtabpage.cpp +++ b/src/newtabpage.cpp @@ -57,15 +57,15 @@  NewTabPage::NewTabPage(QWebFrame *frame) -        : QObject(frame) -        , m_root(frame->documentElement()) +    : QObject(frame) +    , m_root(frame->documentElement())  {      QString htmlFilePath = KStandardDirs::locate("data", "rekonq/htmls/home.html");      QString imagesPath = QL1S("file://") + KGlobal::dirs()->findResourceDir("data", "rekonq/pics/bg.png") + QL1S("rekonq/pics");      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,24 +175,24 @@ 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)); +            prev = validPreview(i, url, QString::number(i + 1) + " - " + names.at(i));          setupPreview(prev, 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,14 +563,14 @@ 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"));          return;      } -    foreach(DownloadItem *item, list) +    foreach(DownloadItem * item, list)      {          m_root.prependInside(markup(QL1S("div"))); diff --git a/src/opensearch/opensearchengine.cpp b/src/opensearch/opensearchengine.cpp index 80eb308f..f48118ca 100644 --- a/src/opensearch/opensearchengine.cpp +++ b/src/opensearch/opensearchengine.cpp @@ -43,15 +43,15 @@  OpenSearchEngine::OpenSearchEngine(QObject *parent) -        : QObject(parent) -        , m_parser(0) +    : QObject(parent) +    , m_parser(0)  {  }  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,12 +267,12 @@ ResponseList OpenSearchEngine::parseSuggestion(const QString &searchTerm, const  ResponseList OpenSearchEngine::parseSuggestion(const QByteArray &resp)  { -    if (!m_parser) +    if(!m_parser)          return ResponseList();      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 591a4acb..35716d9a 100644 --- a/src/opensearch/opensearchmanager.cpp +++ b/src/opensearch/opensearchmanager.cpp @@ -54,9 +54,9 @@  #include <QDBusConnection>  OpenSearchManager::OpenSearchManager(QObject *parent) -        : QObject(parent) -        , m_activeEngine(0) -        , m_currentJob(0) +    : QObject(parent) +    , m_activeEngine(0) +    , m_currentJob(0)  {      m_state = IDLE;      loadEngines(); @@ -75,18 +75,18 @@ 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())          {              kDebug() << "OpenSearch file name empty";              return;          }          QFile file(fileName); -        if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) +        if(!file.open(QIODevice::ReadOnly | QIODevice::Text))          {              kDebug() << "Cannot open opensearch description file: " + fileName;              return; @@ -95,7 +95,7 @@ void OpenSearchManager::setSearchProvider(const QString &searchProvider)          OpenSearchReader reader;          OpenSearchEngine *engine = reader.read(&file); -        if (engine) +        if(engine)          {              m_engineCache.insert(searchProvider, engine);          } @@ -121,7 +121,7 @@ void OpenSearchManager::addOpenSearchEngine(const KUrl &url, const QString &titl      m_shortcut = shortcut; -    if (m_state != IDLE) +    if(m_state != IDLE)      {          idleJob();      } @@ -135,10 +135,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 @@ -147,7 +147,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));      } @@ -174,18 +174,18 @@ 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);          kDebug() << "Received suggestions in " << _typedText << " from " << m_activeEngine->name() << ": "; -        Q_FOREACH(const Response &r, suggestionsList) +        Q_FOREACH(const Response & r, suggestionsList)          {              kDebug() << r.title;          } @@ -194,18 +194,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/"); @@ -249,7 +249,7 @@ 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))      {          kDebug() << "opensearch db cannot be read";          return; @@ -257,7 +257,7 @@ void OpenSearchManager::loadEngines()      QString fileContent = QString::fromUtf8(file.readAll());      QScriptEngine reader; -    if (!reader.canEvaluate(fileContent)) +    if(!reader.canEvaluate(fileContent))      {          kDebug() << "opensearch db cannot be read";          return; @@ -267,7 +267,7 @@ void OpenSearchManager::loadEngines()      QVariantList list;      qScriptValueToSequence(responseParts, list);      QStringList l; -    Q_FOREACH(const QVariant &e, list) +    Q_FOREACH(const QVariant & e, list)      {          l = e.toStringList();          m_engines.insert(KUrl(l.first()), l.last()); @@ -279,7 +279,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))      {          kDebug() << "opensearch db cannot be writen";          return; @@ -288,11 +288,11 @@ void OpenSearchManager::saveEngines()      out << "[";      int i = 0;      QList<KUrl> urls = m_engines.keys(); -    Q_FOREACH(const KUrl &url, urls) +    Q_FOREACH(const KUrl & url, urls)      {          out << "[\"" << url.url() << "\",\"" << m_engines.value(url) << "\"]";          i++; -        if (i != urls.size()) +        if(i != urls.size())          {              out << ",\n";          } @@ -305,10 +305,10 @@ void OpenSearchManager::saveEngines()  void  OpenSearchManager::removeDeletedEngines()  {      KService::Ptr service; -    Q_FOREACH(const KUrl &url, m_engines.keys()) +    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"); @@ -329,15 +329,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());              } @@ -351,7 +351,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 2076338b..a789c413 100644 --- a/src/opensearch/opensearchreader.cpp +++ b/src/opensearch/opensearchreader.cpp @@ -42,7 +42,7 @@  OpenSearchReader::OpenSearchReader() -        : QXmlStreamReader() +    : QXmlStreamReader()  {  } @@ -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 d1464275..d6a34f54 100644 --- a/src/opensearch/opensearchwriter.cpp +++ b/src/opensearch/opensearchwriter.cpp @@ -37,7 +37,7 @@  OpenSearchWriter::OpenSearchWriter() -        : QXmlStreamWriter() +    : QXmlStreamWriter()  {      setAutoFormatting(true);  } @@ -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 974bcc77..09eb5891 100644 --- a/src/opensearch/searchengine.cpp +++ b/src/opensearch/searchengine.cpp @@ -61,10 +61,10 @@ void SearchEngine::reload()      favoriteEngines = cg.readEntry("FavoriteSearchEngines", favoriteEngines);      KService::List favorites;      KService::Ptr service; -    Q_FOREACH(const QString &engine, favoriteEngines) +    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();              kDebug() << "ENGINE URL: " << url; @@ -85,7 +85,7 @@ void SearchEngine::reload()  QString SearchEngine::delimiter()  { -    if (!d->isLoaded) +    if(!d->isLoaded)          reload();      return d->delimiter; @@ -94,7 +94,7 @@ QString SearchEngine::delimiter()  KService::List SearchEngine::favorites()  { -    if (!d->isLoaded) +    if(!d->isLoaded)          reload();      return d->favorites; @@ -103,7 +103,7 @@ KService::List SearchEngine::favorites()  KService::Ptr SearchEngine::defaultEngine()  { -    if (!d->isLoaded) +    if(!d->isLoaded)          reload();      return d->defaultEngine; @@ -116,13 +116,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) +        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; @@ -137,7 +137,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 a6619441..0e390d99 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())      {          kDebug() << "RESPONSE IS EMPTY";          return ResponseList();      } -    if (!response.startsWith(QL1C('[')) +    if(!response.startsWith(QL1C('['))              || !response.endsWith(QL1C(']')) -       ) +      )      {          kDebug() << "RESPONSE is NOT well FORMED";          return ResponseList();      }      // Evaluate the JSON response using QtScript. -    if (!m_reader.canEvaluate(response)) +    if(!m_reader.canEvaluate(response))      {          kDebug() << "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())      {          kDebug() << "RESPONSE is not an array";          return ResponseList(); @@ -138,7 +138,7 @@ ResponseList JSONParser::parse(const QByteArray &resp)      QStringList responsePartsList;      qScriptValueToSequence(responseParts.property(1), responsePartsList); -    Q_FOREACH(const QString &s, responsePartsList) +    Q_FOREACH(const QString & s, responsePartsList)      {          rlist << Response(s);      } diff --git a/src/opensearch/suggestionparser.h b/src/opensearch/suggestionparser.h index f96061c7..523a4e6f 100644 --- a/src/opensearch/suggestionparser.h +++ b/src/opensearch/suggestionparser.h @@ -50,20 +50,20 @@ public:      int image_height;      Response(const Response &item) : title(item.title), -            description(item.description), -            url(item.url), -            image(item.image), -            image_width(item.image_width), -            image_height(item.image_height) +        description(item.description), +        url(item.url), +        image(item.image), +        image_width(item.image_width), +        image_height(item.image_height)      {};      Response() : title(QString()), -            description(QString()), -            url(QString()), -            image(QString()), -            image_width(0), -            image_height(0) +        description(QString()), +        url(QString()), +        image(QString()), +        image_width(0), +        image_height(0)      {}; @@ -73,11 +73,11 @@ public:               const QString &_image = QString(),               const int &_image_width = 0,               const int &_image_height = 0) : title(_title), -            description(_description), -            url(_url), -            image(_image), -            image_width(_image_width), -            image_height(_image_height) +        description(_description), +        url(_url), +        image(_image), +        image_width(_image_width), +        image_height(_image_height)      {};  }; diff --git a/src/paneltreeview.cpp b/src/paneltreeview.cpp index 7b28142e..1c727d78 100644 --- a/src/paneltreeview.cpp +++ b/src/paneltreeview.cpp @@ -40,7 +40,7 @@  PanelTreeView::PanelTreeView(QWidget *parent) -        : QTreeView(parent) +    : QTreeView(parent)  {      connect(this, SIGNAL(itemHovered(const QString &)), parent, SIGNAL(itemHovered(const QString &)));      connect(this, SIGNAL(openUrl(const KUrl &, Rekonq::OpenType)), parent, SIGNAL(openUrl(const KUrl &, Rekonq::OpenType))); @@ -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 23d5f9e5..b242846d 100644 --- a/src/previewselectorbar.cpp +++ b/src/previewselectorbar.cpp @@ -55,15 +55,15 @@ PreviewSelectorBar::PreviewSelectorBar(int index, QWidget* parent)      , m_insertAction(0)  {      setMessageType(KMessageWidget::Information); -     +      QSize sz = size(); -    sz.setWidth( qobject_cast<QWidget *>(parent)->size().width() ); +    sz.setWidth(qobject_cast<QWidget *>(parent)->size().width());      resize(sz); -     +      setCloseButtonVisible(false); -     -    setText( i18n("Please open up the webpage you want to add as favorite") ); -     + +    setText(i18n("Please open up the webpage you want to add as favorite")); +      m_insertAction = new QAction(KIcon("insert-image"), i18n("Set to This Page"), this);      connect(m_insertAction, SIGNAL(triggered(bool)), this, SLOT(clicked()));      addAction(m_insertAction); @@ -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,12 +106,12 @@ void PreviewSelectorBar::clicked()  {      WebPage *page = rApp->mainWindow()->currentTab()->page(); -    if (page) +    if(page)      {          KUrl url = page->mainFrame()->url();          QStringList names = ReKonfig::previewNames();          QStringList urls = ReKonfig::previewUrls(); -         +          //cleanup the previous image from the cache (useful to refresh the snapshot)          QFile::remove(WebSnap::imagePathFromUrl(urls.at(m_previewIndex)));          page->mainFrame()->setScrollBarValue(Qt::Vertical, 0); diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index c5e0ef96..7274a250 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -68,9 +68,9 @@ static KFileItemList sortFileList(const KFileItemList &list)      KFileItemList orderedList, dirList, fileList;      // order dirs before files.. -    Q_FOREACH(const KFileItem &item, list) +    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;          } @@ -125,25 +125,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"); @@ -174,9 +174,9 @@ 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      KMessageBox::error(rApp->mainWindow(), i18nc("@info", "rekonq does not know how to handle this protocol: %1", _url.protocol())); @@ -190,14 +190,14 @@ bool ProtocolHandler::postHandling(const QNetworkRequest &request, QWebFrame *fr      _frame = frame;      kDebug() << "URL PROTOCOL: " << _url; -     +      // "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; @@ -208,7 +208,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*))); @@ -216,10 +216,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); @@ -230,7 +230,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))      {          kDebug() << "WARNING: launching a new app...";          (void)new KRun(_url, rApp->mainWindow(), 0, _url.isLocalFile()); @@ -246,7 +246,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());      } @@ -265,7 +265,7 @@ void ProtocolHandler::showResults(const KFileItemList &list)  QString ProtocolHandler::dirHandling(const KFileItemList &list)  { -    if (!_lister) +    if(!_lister)      {          return QString("rekonq error, sorry :(");      } @@ -278,7 +278,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 :(");      } @@ -287,7 +287,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); @@ -299,7 +299,7 @@ QString ProtocolHandler::dirHandling(const KFileItemList &list)      msg += "<tr><th align=\"left\">" + i18n("Name") + "</th><th>" + i18n("Size") + "</th><th>" + i18n("Last Modified") + "</th></tr>";      KFileItemList orderedList = sortFileList(list); -    Q_FOREACH(const KFileItem &item, orderedList) +    Q_FOREACH(const KFileItem & item, orderedList)      {          msg += "<tr>";          QString fullPath = item.url().prettyUrl(); @@ -313,7 +313,7 @@ QString ProtocolHandler::dirHandling(const KFileItemList &list)          msg += "</td>";          msg += "<td align=\"right\">"; -        if (item.isFile()) +        if(item.isFile())          {              msg += QString::number(item.size() / 1024) + " KB";          } @@ -339,7 +339,7 @@ QString ProtocolHandler::dirHandling(const KFileItemList &list)  void ProtocolHandler::slotMostLocalUrlResult(KJob *job)  { -    if (job->error()) +    if(job->error())      {          // TODO          kDebug() << "error"; @@ -348,7 +348,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); @@ -370,7 +370,7 @@ void ProtocolHandler::abpHandling()      kDebug() << "handling abp url: " << _url;      QString path = _url.path(); -    if (path != QL1S("subscribe")) +    if(path != QL1S("subscribe"))          return;      QMap<QString, QString> map = _url.queryItems(KUrl::CaseInsensitiveKeys); @@ -381,7 +381,7 @@ void ProtocolHandler::abpHandling()      QString requirestitle = map.value(QL1S("requirestitle"));      QString info; -    if (requirestitle.isEmpty() || requireslocation.isEmpty()) +    if(requirestitle.isEmpty() || requireslocation.isEmpty())      {          info = title;      } @@ -390,15 +390,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 68bc6350..0cd036ec 100644 --- a/src/sessionmanager.cpp +++ b/src/sessionmanager.cpp @@ -45,8 +45,8 @@  SessionManager::SessionManager(QObject *parent) -        : QObject(parent) -        , m_safe(false) +    : QObject(parent) +    , m_safe(false)  {      m_sessionFilePath = KStandardDirs::locateLocal("appdata" , "session");  } @@ -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 1461ba21..12a18fc0 100644 --- a/src/settings/adblockwidget.cpp +++ b/src/settings/adblockwidget.cpp @@ -43,8 +43,8 @@  AdBlockWidget::AdBlockWidget(QWidget *parent) -        : QWidget(parent) -        , _changed(false) +    : QWidget(parent) +    , _changed(false)  {      setupUi(this); @@ -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); @@ -123,7 +123,7 @@ void AdBlockWidget::load()      QStringList subscriptions = ReKonfig::subscriptionTitles();      // load automatic rules -    foreach(const QString &sub, subscriptions) +    foreach(const QString & sub, subscriptions)      {          QTreeWidgetItem *subItem = new QTreeWidgetItem(treeWidget);          subItem->setText(0, sub); @@ -134,7 +134,7 @@ void AdBlockWidget::load()      KSharedConfig::Ptr config = KSharedConfig::openConfig("adblock", KConfig::SimpleConfig, "appdata");      KConfigGroup localGroup(config, "rules");      QStringList rules = localGroup.readEntry("local-rules" , QStringList()); -    foreach(const QString &rule, rules) +    foreach(const QString & rule, rules)      {          listWidget->addItem(rule);      } @@ -149,7 +149,7 @@ void AdBlockWidget::loadRules(QTreeWidgetItem *item)      QString str = item->text(0) + "-rules";      QStringList rules = localGroup.readEntry(str , QStringList()); -    foreach(const QString &rule, rules) +    foreach(const QString & rule, rules)      {          QTreeWidgetItem *subItem = new QTreeWidgetItem(item);          subItem->setText(0, 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/appearancewidget.cpp b/src/settings/appearancewidget.cpp index eb486c90..df28989e 100644 --- a/src/settings/appearancewidget.cpp +++ b/src/settings/appearancewidget.cpp @@ -36,8 +36,8 @@  #include <KCharsets>  AppearanceWidget::AppearanceWidget(QWidget *parent) -        : QWidget(parent) -        , _changed(false) +    : QWidget(parent) +    , _changed(false)  {      setupUi(this); diff --git a/src/settings/generalwidget.cpp b/src/settings/generalwidget.cpp index b86e7aec..9f6de0d5 100644 --- a/src/settings/generalwidget.cpp +++ b/src/settings/generalwidget.cpp @@ -40,8 +40,8 @@  #include <kstandarddirs.h>  GeneralWidget::GeneralWidget(QWidget *parent) -        : QWidget(parent) -        , _changed(false) +    : QWidget(parent) +    , _changed(false)  {      setupUi(this); @@ -75,7 +75,7 @@ void GeneralWidget::setHomeToCurrentPage()  {      MainWindow *mw = rApp->mainWindow();      WebTab *webTab = mw->currentTab(); -    if (webTab) +    if(webTab)      {          kcfg_homePage->setText(webTab->url().prettyUrl());      } @@ -90,7 +90,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/networkwidget.cpp b/src/settings/networkwidget.cpp index 52f47ffb..c2988eb1 100644 --- a/src/settings/networkwidget.cpp +++ b/src/settings/networkwidget.cpp @@ -37,11 +37,11 @@  NetworkWidget::NetworkWidget(QWidget *parent) -        : QWidget(parent) -        , _cacheModule(0) -        , _cookiesModule(0) -        , _proxyModule(0) -        , _changed(false) +    : QWidget(parent) +    , _cacheModule(0) +    , _cookiesModule(0) +    , _proxyModule(0) +    , _changed(false)  {      QVBoxLayout *l = new QVBoxLayout(this);      l->setMargin(0); diff --git a/src/settings/settingsdialog.cpp b/src/settings/settingsdialog.cpp index 6f7f3347..8afb61d7 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");      } @@ -149,8 +149,8 @@ Private::Private(SettingsDialog *parent)  SettingsDialog::SettingsDialog(QWidget *parent) -        : KConfigDialog(parent, "rekonfig", ReKonfig::self()) -        , d(new Private(this)) +    : KConfigDialog(parent, "rekonfig", ReKonfig::self()) +    , d(new Private(this))  {      showButtonSeparator(false);      setWindowTitle(i18nc("Window title of the settings dialog", "Configure – rekonq")); @@ -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/settings/tabswidget.cpp b/src/settings/tabswidget.cpp index 30410f00..67829f82 100644 --- a/src/settings/tabswidget.cpp +++ b/src/settings/tabswidget.cpp @@ -30,8 +30,8 @@  TabsWidget::TabsWidget(QWidget *parent) -        : QWidget(parent) -        , _changed(false) +    : QWidget(parent) +    , _changed(false)  {      setupUi(this);  } diff --git a/src/settings/webkitwidget.cpp b/src/settings/webkitwidget.cpp index 6e837ead..04242af1 100644 --- a/src/settings/webkitwidget.cpp +++ b/src/settings/webkitwidget.cpp @@ -30,8 +30,8 @@  WebKitWidget::WebKitWidget(QWidget *parent) -        : QWidget(parent) -        , _changed(false) +    : QWidget(parent) +    , _changed(false)  {      setupUi(this);  } diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 1b2dcb2b..edcb3a9c 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -83,12 +83,12 @@ TabBar::TabBar(QWidget *parent)      connect(this, SIGNAL(contextMenu(int, const QPoint &)), this, SLOT(contextMenu(int, const QPoint &)));      connect(this, SIGNAL(emptyAreaContextMenu(const QPoint &)), this, SLOT(emptyAreaContextMenu(const QPoint &))); -    connect(this, SIGNAL(tabMoved(int,int)), this, SLOT(tabMoved(int,int))); +    connect(this, SIGNAL(tabMoved(int, int)), this, SLOT(tabMoved(int, int)));      connect(m_animationMapper, SIGNAL(mapped(int)), this, SLOT(removeAnimation(int)));      setGraphicsEffect(m_tabHighlightEffect); -    setAnimatedTabHighlighting( ReKonfig::animatedTabHighlighting() ); +    setAnimatedTabHighlighting(ReKonfig::animatedTabHighlighting());  } @@ -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,25 +175,25 @@ 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); -    m_previewPopup = new TabPreviewPopup(indexedTab ,this); +    m_previewPopup = new TabPreviewPopup(indexedTab , this);      int tabBarWidth = mv->size().width(); -    int leftIndex = tabRect(m_currentTabPreviewIndex).x() + (tabRect(m_currentTabPreviewIndex).width() - w)/2; +    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,19 +383,19 @@ 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()) +    Q_FOREACH(const HistoryItem & item, mv->recentlyClosedTabs())      {          KAction *a = new KAction(rApp->iconManager()->iconForUrl(item.url), item.title, this);          a->setData(item.url); @@ -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)); @@ -437,7 +437,7 @@ void TabBar::setTabHighlighted(int index)              m_animationMapper->setMapping(anim, index);              connect(anim, SIGNAL(finished()), m_animationMapper, SLOT(map()));          } -  +          setTabTextColor(index, highlightColor);      }  } @@ -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 b92017cf..a6441f04 100644 --- a/src/tabhighlighteffect.cpp +++ b/src/tabhighlighteffect.cpp @@ -37,9 +37,9 @@ const QByteArray prep("hAnim");  TabHighlightEffect::TabHighlightEffect(TabBar *tabBar) -        : QGraphicsEffect(tabBar) -        , m_tabBar(tabBar) -        , m_highlightColor(tabBar->palette().highlight().color().lighter()) +    : QGraphicsEffect(tabBar) +    , m_tabBar(tabBar) +    , m_highlightColor(tabBar->palette().highlight().color().lighter())  {      Q_ASSERT(m_tabBar);  } @@ -48,22 +48,22 @@ TabHighlightEffect::TabHighlightEffect(TabBar *tabBar)  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()) +    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/tabpreviewpopup.cpp b/src/tabpreviewpopup.cpp index 3d1bc5a6..f6ede995 100644 --- a/src/tabpreviewpopup.cpp +++ b/src/tabpreviewpopup.cpp @@ -41,10 +41,10 @@  #include <QPoint> -TabPreviewPopup::TabPreviewPopup(WebTab* tab,QWidget* parent) -  : KPassivePopup(parent), -    m_thumbnail(new QLabel(this)), -    m_url(new QLabel(this)) +TabPreviewPopup::TabPreviewPopup(WebTab* tab, QWidget* parent) +    : KPassivePopup(parent), +      m_thumbnail(new QLabel(this)), +      m_url(new QLabel(this))  {      m_thumbnail->setAlignment(Qt::AlignHCenter);      m_url->setAlignment(Qt::AlignHCenter); @@ -95,14 +95,14 @@ void TabPreviewPopup::setUrl(const QString& text)  void TabPreviewPopup::setFixedSize(int w, int h)  { -    KPassivePopup::setFixedSize(w,h); -    m_url->setText(m_url->fontMetrics().elidedText(m_url->text(),Qt::ElideMiddle,this->width() - this->borderRadius)); +    KPassivePopup::setFixedSize(w, h); +    m_url->setText(m_url->fontMetrics().elidedText(m_url->text(), Qt::ElideMiddle, this->width() - this->borderRadius));      QPixmap pixmap(size());      QPainter painter(&pixmap);      painter.setRenderHint(QPainter::Antialiasing);      painter.fillRect(pixmap.rect(), Qt::red);      painter.setBrush(QBrush(Qt::black)); -    painter.drawRoundRect(borderSpacing,borderSpacing,pixmap.width()-borderSpacing*2,pixmap.height()-borderSpacing*2, borderRadius, borderRadius); +    painter.drawRoundRect(borderSpacing, borderSpacing, pixmap.width() - borderSpacing * 2, pixmap.height() - borderSpacing * 2, borderRadius, borderRadius);      setMask(pixmap.createMaskFromColor(Qt::red));  }
\ No newline at end of file diff --git a/src/tabpreviewpopup.h b/src/tabpreviewpopup.h index fe2c50ac..7a6f81e4 100644 --- a/src/tabpreviewpopup.h +++ b/src/tabpreviewpopup.h @@ -48,7 +48,7 @@ public:      **/      explicit TabPreviewPopup(WebTab *tab, QWidget *parent = 0);      virtual ~TabPreviewPopup(); -     +  private:      QLabel *m_thumbnail; diff --git a/src/tests/listitem_test.cpp b/src/tests/listitem_test.cpp index 08b04e80..53918040 100644 --- a/src/tests/listitem_test.cpp +++ b/src/tests/listitem_test.cpp @@ -61,11 +61,11 @@ void ListItemTest::wordHighLighting_data()      QTest::addColumn<QString>("expected");      QTest::newRow("plan b") << "<i>http://www.google.com/search?q=plan b&ie=UTF-8&oe=UTF-8</i>" -    << "plan b" << "<i>http://www.google.com/search?q=<b>plan</b> <b>b</b>&ie=UTF-8&oe=UTF-8</i>"; +                            << "plan b" << "<i>http://www.google.com/search?q=<b>plan</b> <b>b</b>&ie=UTF-8&oe=UTF-8</i>";      QTest::newRow("plan b #2") << "<i>http://en.wikipedia.org/wiki/Plan_B_(British_musician)</i>" -    << "plan b" << "<i>http://en.wikipedia.org/wiki/<b>Plan</b>_<b>B</b>_(<b>B</b>ritish_musician)</i>"; +                               << "plan b" << "<i>http://en.wikipedia.org/wiki/<b>Plan</b>_<b>B</b>_(<b>B</b>ritish_musician)</i>";      QTest::newRow("i") << "<i>http://i.imgur.com/jacoj.jpg</i>" << "i" -    << "<i>http://<b>i</b>.<b>i</b>mgur.com/jacoj.jpg</i>"; +                       << "<i>http://<b>i</b>.<b>i</b>mgur.com/jacoj.jpg</i>";      QTest::newRow("i#2") << "KDE - Experience Freedom!" << "i" << "KDE - Exper<b>i</b>ence Freedom!";      QTest::newRow("i#3") << "The WebKit Open Source Project" << "i" << "The WebK<b>i</b>t Open Source Project";      QTest::newRow("i#4") << "<i>http://webkit.org/</i>" << "i" << "<i>http://webk<b>i</b>t.org/</i>"; @@ -73,7 +73,7 @@ void ListItemTest::wordHighLighting_data()      QTest::newRow("b#2") << "rekonq, WebKit KDE browser" << "b" << "rekonq, We<b>b</b>Kit KDE <b>b</b>rowser";      QTest::newRow("<") << "Subject < Section < Wiki" << "<" << "Subject <b><</b> Section <b><</b> Wiki";      QTest::newRow("&") << "<i>http://www.google.com/search?q=qt test&ie=UTF-8&oe=UTF-8</i>" << "&" -    << "<i>http://www.google.com/search?q=qt test<b>&</b>ie=UTF-8<b>&</b>oe=UTF-8</i>"; +                       << "<i>http://www.google.com/search?q=qt test<b>&</b>ie=UTF-8<b>&</b>oe=UTF-8</i>";      QTest::newRow("ciao") << "ciao" << "ciao" << "<b>ciao</b>";      QTest::newRow("http://ciao") << "http://ciao" << "ciao" << "http://<b>ciao</b>";  } diff --git a/src/urlbar/bookmarkwidget.cpp b/src/urlbar/bookmarkwidget.cpp index a7b3ded0..811e89be 100644 --- a/src/urlbar/bookmarkwidget.cpp +++ b/src/urlbar/bookmarkwidget.cpp @@ -46,8 +46,8 @@  BookmarkWidget::BookmarkWidget(const KBookmark &bookmark, QWidget *parent) -        : QMenu(parent) -        , m_bookmark(new KBookmark(bookmark)) +    : QMenu(parent) +    , m_bookmark(new KBookmark(bookmark))  {      setAttribute(Qt::WA_DeleteOnClose);      setFixedWidth(350); @@ -81,7 +81,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);      } @@ -120,7 +120,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 c8209fbc..1f697b19 100644 --- a/src/urlbar/completionwidget.cpp +++ b/src/urlbar/completionwidget.cpp @@ -52,10 +52,10 @@  CompletionWidget::CompletionWidget(QWidget *parent) -        : QFrame(parent, Qt::ToolTip) -        , _parent(parent) -        , _currentIndex(0) -        , _hasSuggestions(false) +    : QFrame(parent, Qt::ToolTip) +    , _parent(parent) +    , _currentIndex(0) +    , _hasSuggestions(false)  {      setFrameStyle(QFrame::Panel);      setLayoutDirection(Qt::LeftToRight); @@ -68,7 +68,7 @@ CompletionWidget::CompletionWidget(QWidget *parent)  void CompletionWidget::insertItems(const UrlSearchList &list, const QString& text, int offset)  { -    Q_FOREACH(const UrlSearchItem &item, list) +    Q_FOREACH(const UrlSearchItem & item, list)      {          ListItem *suggestion = ListItemFactory::create(item, text, this);          suggestion->setBackgroundRole(offset % 2 ? QPalette::AlternateBase : QPalette::Base); @@ -90,11 +90,11 @@ void CompletionWidget::updateSearchList(const UrlSearchList &list, const QString      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 +114,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 +131,7 @@ void CompletionWidget::popup()  {      findChild<ListItem *>(QString::number(0))->activate(); //activate first listitem      sizeAndPosition(); -    if (!isVisible()) +    if(!isVisible())          show();  } @@ -141,7 +141,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 +154,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 +183,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 +198,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 +238,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 +255,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 +294,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                  {                      kDebug() << "USING LISTITEM URL: " << child->url();                      kDebug() << "USING LISTITEM TITLE: " << child->text(); @@ -336,7 +336,7 @@ bool CompletionWidget::eventFilter(QObject *obj, QEvent *ev)  void CompletionWidget::setVisible(bool visible)  { -    if (visible) +    if(visible)      {          rApp->installEventFilter(this);      } @@ -352,7 +352,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); @@ -376,16 +376,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/listitem.cpp b/src/urlbar/listitem.cpp index 17a4585d..f268442f 100644 --- a/src/urlbar/listitem.cpp +++ b/src/urlbar/listitem.cpp @@ -60,9 +60,9 @@  ListItem::ListItem(const UrlSearchItem &item, QWidget *parent) -        : QWidget(parent) -        , m_option() -        , m_url(item.url) +    : QWidget(parent) +    , m_option() +    , m_url(item.url)  {      m_option.initFrom(this);      m_option.direction = Qt::LeftToRight; @@ -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);      } @@ -158,7 +158,7 @@ void ListItem::nextItemSubChoice()  TypeIconLabel::TypeIconLabel(int type, QWidget *parent) -        : QLabel(parent) +    : QLabel(parent)  {      setMinimumWidth(40);      QHBoxLayout *hLayout = new QHBoxLayout; @@ -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"));  } @@ -193,7 +193,7 @@ QLabel *TypeIconLabel::getIcon(QString icon)  IconLabel::IconLabel(const QString &icon, QWidget *parent) -        : QLabel(parent) +    : QLabel(parent)  {      QPixmap pixmapIcon = rApp->iconManager()->iconForUrl(KUrl(icon)).pixmap(16);      setFixedSize(16, 16); @@ -202,7 +202,7 @@ IconLabel::IconLabel(const QString &icon, QWidget *parent)  IconLabel::IconLabel(const KIcon &icon, QWidget *parent) -        : QLabel(parent) +    : QLabel(parent)  {      QPixmap pixmapIcon = icon.pixmap(16);      setFixedSize(16, 16); @@ -217,63 +217,63 @@ static QString highlightWordsInText(const QString &text, const QStringList &word  {      QString ret = text;      QBitArray boldSections(ret.size()); -    foreach(const QString &wordToPointOut, words) +    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);          }      } -     -    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;  }  TextLabel::TextLabel(const QString &text, const QString &textToPointOut, QWidget *parent) -        : QLabel(parent) +    : QLabel(parent)  {      setTextFormat(Qt::RichText);      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); @@ -281,7 +281,7 @@ TextLabel::TextLabel(const QString &text, const QString &textToPointOut, QWidget  TextLabel::TextLabel(QWidget *parent) -        : QLabel(parent) +    : QLabel(parent)  {      setTextFormat(Qt::RichText);      setMouseTracking(false); @@ -299,14 +299,14 @@ void TextLabel::setEngineText(const QString &engine, const QString &text)  DescriptionLabel::DescriptionLabel(const QString &text, QWidget *parent) -        : QLabel(parent) +    : QLabel(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 ? @@ -319,7 +319,7 @@ DescriptionLabel::DescriptionLabel(const QString &text, QWidget *parent)  PreviewListItem::PreviewListItem(const UrlSearchItem &item, const QString &text, QWidget *parent) -        : ListItem(item, parent) +    : ListItem(item, parent)  {      QHBoxLayout *hLayout = new QHBoxLayout;      hLayout->setSpacing(4); @@ -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://"); @@ -357,13 +357,13 @@ PreviewListItem::PreviewListItem(const UrlSearchItem &item, const QString &text,  PreviewLabel::PreviewLabel(const QString &url, int width, int height, QWidget *parent) -        : QLabel(parent) +    : QLabel(parent)  {      setFixedSize(width, height);      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)); @@ -376,11 +376,11 @@ PreviewLabel::PreviewLabel(const QString &url, int width, int height, QWidget *p  ImageLabel::ImageLabel(const QString &url, int width, int height, QWidget *parent) -        : QLabel(parent), -        m_url(url) +    : QLabel(parent), +      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"); @@ -418,8 +418,8 @@ void ImageLabel::slotResult(KJob *)  SearchListItem::SearchListItem(const UrlSearchItem &item, const QString &text, QWidget *parent) -        : ListItem(item, parent) -        , m_text(text) +    : ListItem(item, parent) +    , m_text(text)  {      m_iconLabel = new IconLabel(SearchEngine::buildQuery(UrlResolver::searchEngine(), ""), this);      m_titleLabel = new TextLabel(this); @@ -464,7 +464,7 @@ void SearchListItem::nextItemSubChoice()  EngineBar::EngineBar(KService::Ptr selectedEngine, QWidget *parent) -        : KToolBar(parent) +    : KToolBar(parent)  {      setIconSize(QSize(16, 16));      setToolButtonStyle(Qt::ToolButtonIconOnly); @@ -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()) +    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(); @@ -535,8 +535,8 @@ void EngineBar::selectNextEngine()  SuggestionListItem::SuggestionListItem(const UrlSearchItem &item, const QString &text, QWidget *parent) -        : ListItem(item, parent) -        , m_text(item.title) +    : ListItem(item, parent) +    , m_text(item.title)  {      QHBoxLayout *hLayout = new QHBoxLayout;      hLayout->setSpacing(4); @@ -559,15 +559,15 @@ QString SuggestionListItem::text()  VisualSuggestionListItem::VisualSuggestionListItem(const UrlSearchItem &item, const QString &text, QWidget *parent) -        : ListItem(item, parent) -        , m_text(item.title) +    : ListItem(item, parent) +    , m_text(item.title)  {      QHBoxLayout *hLayout = new QHBoxLayout;      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); @@ -605,7 +605,7 @@ QString VisualSuggestionListItem::text()  BrowseListItem::BrowseListItem(const UrlSearchItem &item, const QString &text, QWidget *parent) -        : ListItem(item, parent) +    : ListItem(item, parent)  {      QString url = text; @@ -627,34 +627,34 @@ 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)      {          kDebug() << "Search";          return new SearchListItem(item, text, parent);      } -    if (item.type & UrlSearchItem::Browse) +    if(item.type & UrlSearchItem::Browse)      {          kDebug() << "Browse";          return new BrowseListItem(item, text, parent);      } -    if (item.type & UrlSearchItem::History) +    if(item.type & UrlSearchItem::History)      {          kDebug() << "History";          return new PreviewListItem(item, text, parent);      } -    if (item.type & UrlSearchItem::Bookmark) +    if(item.type & UrlSearchItem::Bookmark)      {          kDebug() << "Bookmark";          return new PreviewListItem(item, text, parent);      } -    if (item.type & UrlSearchItem::Suggestion) +    if(item.type & UrlSearchItem::Suggestion)      {          kDebug() << "ITEM URL: " << item.url; -        if (item.description.isEmpty()) +        if(item.description.isEmpty())          {              kDebug() << "Suggestion";              return new SuggestionListItem(item, text, parent); diff --git a/src/urlbar/rsswidget.cpp b/src/urlbar/rsswidget.cpp index 006b2999..fc926e38 100644 --- a/src/urlbar/rsswidget.cpp +++ b/src/urlbar/rsswidget.cpp @@ -52,8 +52,8 @@  RSSWidget::RSSWidget(const QMap< KUrl, QString > &map, QWidget *parent) -        : QMenu(parent) -        , m_map(map) +    : QMenu(parent) +    , m_map(map)  {      setAttribute(Qt::WA_DeleteOnClose);      setMinimumWidth(250); @@ -85,7 +85,7 @@ RSSWidget::RSSWidget(const QMap< KUrl, QString > &map, QWidget *parent)      m_feeds = new KComboBox(this);      m_feeds->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); -    foreach(const QString &title, m_map) +    foreach(const QString & title, m_map)      {          m_feeds->addItem(title);      } @@ -121,7 +121,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); @@ -140,12 +140,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>")); @@ -157,7 +157,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/stackedurlbar.cpp b/src/urlbar/stackedurlbar.cpp index 1df9ce54..745818e3 100644 --- a/src/urlbar/stackedurlbar.cpp +++ b/src/urlbar/stackedurlbar.cpp @@ -33,7 +33,7 @@  StackedUrlBar::StackedUrlBar(QWidget *parent) -        : QStackedWidget(parent) +    : QStackedWidget(parent)  {      // cosmetic      setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); @@ -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 078dc6a6..292bf6c8 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -60,7 +60,7 @@  IconButton::IconButton(QWidget *parent) -        : QToolButton(parent) +    : QToolButton(parent)  {      setToolButtonStyle(Qt::ToolButtonIconOnly);      setStyleSheet("IconButton { background-color:transparent; border: none; padding: 0px}"); @@ -78,10 +78,10 @@ void IconButton::mouseReleaseEvent(QMouseEvent* event)  UrlBar::UrlBar(QWidget *parent) -        : KLineEdit(parent) -        , _tab(0) -        , _icon(new IconButton(this)) -        , _suggestionTimer(new QTimer(this)) +    : KLineEdit(parent) +    , _tab(0) +    , _icon(new IconButton(this)) +    , _suggestionTimer(new QTimer(this))  {      // initial style      setStyleSheet(QString("UrlBar { padding: 0 0 0 %1px;} ").arg(_icon->sizeHint().width())); @@ -133,7 +133,7 @@ UrlBar::~UrlBar()  void UrlBar::setQUrl(const QUrl& url)  { -    if (url.scheme() == QL1S("about")) +    if(url.scheme() == QL1S("about"))      {          clear();          setFocus(); @@ -163,7 +163,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; @@ -178,9 +178,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 = colorScheme.background(KColorScheme::NeutralBackground).color();  // light yellow              foregroundColor = colorScheme.foreground(KColorScheme::NormalText).color(); @@ -198,7 +198,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; @@ -217,7 +217,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); @@ -236,36 +236,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); @@ -276,17 +276,17 @@ 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() -            && !rApp->mainWindow()->currentTab()->view()->url().toString().startsWith("about")) +        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();      } @@ -306,11 +306,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()); @@ -326,7 +326,7 @@ void UrlBar::dropEvent(QDropEvent *event)  void UrlBar::loadFinished()  { -    if (_tab->url().scheme() == QL1S("about")) +    if(_tab->url().scheme() == QL1S("about"))      {          update();          return; @@ -337,28 +337,28 @@ void UrlBar::loadFinished()      connect(bt, SIGNAL(clicked(const QPoint &)), this, SLOT(showBookmarkInfo(const 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"))      {          IconButton *bt = addRightIcon(UrlBar::SSL);          connect(bt, SIGNAL(clicked(QPoint)), _tab->page(), SLOT(showSSLInfo(QPoint)));      }      // show add search engine -    if (_tab->hasNewSearchEngine()) +    if(_tab->hasNewSearchEngine())      {          IconButton *bt = addRightIcon(UrlBar::SearchEngine);          connect(bt, SIGNAL(clicked(QPoint)), _tab, SLOT(showSearchEngine(QPoint))); @@ -375,16 +375,16 @@ void UrlBar::loadFinished()  void UrlBar::showBookmarkInfo(const QPoint &pos)  { -    if (_tab->url().scheme() == QL1S("about")) +    if(_tab->url().scheme() == QL1S("about"))          return;      KBookmark bookmark = rApp->bookmarkProvider()->bookmarkForUrl(_tab->url());      IconButton *bt = qobject_cast<IconButton *>(this->sender()); -    if (!bt) +    if(!bt)          return; -    if (bookmark.isNull()) +    if(bookmark.isNull())      {          bookmark = rApp->bookmarkProvider()->bookmarkOwner()->bookmarkCurrentPage(); @@ -403,7 +403,7 @@ void UrlBar::showBookmarkInfo(const QPoint &pos)  void UrlBar::updateRightIcons()  { -    if (!_tab->isPageLoading()) +    if(!_tab->isPageLoading())      {          clearRightIcons();          loadFinished(); @@ -419,9 +419,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()); @@ -450,7 +450,7 @@ IconButton *UrlBar::addRightIcon(UrlBar::icon ic)  {      IconButton *rightIcon = new IconButton(this); -    switch (ic) +    switch(ic)      {      case UrlBar::KGet:          rightIcon->setIcon(KIcon("download")); @@ -465,7 +465,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")); @@ -479,7 +479,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");          } @@ -495,7 +495,7 @@ IconButton *UrlBar::addRightIcon(UrlBar::icon ic)      _rightIconsList << rightIcon;      int iconsCount = _rightIconsList.count();      int iconHeight = (height() - 18) / 2; -    rightIcon->move(width() - 23*iconsCount, iconHeight); +    rightIcon->move(width() - 23 * iconsCount, iconHeight);      rightIcon->show();      return rightIcon; @@ -517,10 +517,10 @@ 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); +        bt->move(w - 25 * (i + 1), newHeight);      }      KLineEdit::resizeEvent(event); @@ -529,13 +529,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);  } @@ -543,21 +543,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; diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp index d89f27d0..0d8ecc12 100644 --- a/src/urlbar/urlresolver.cpp +++ b/src/urlbar/urlresolver.cpp @@ -67,14 +67,14 @@ QRegExp UrlResolver::_searchEnginesRegexp;  UrlResolver::UrlResolver(const QString &typedUrl) -        : QObject() -        , _typedString(typedUrl.trimmed()) -        , _typedQuery() +    : QObject() +    , _typedString(typedUrl.trimmed()) +    , _typedQuery()  { -    if (!_searchEngine) +    if(!_searchEngine)          setSearchEngine(SearchEngine::defaultEngine()); -    if (_browseRegexp.isEmpty()) +    if(_browseRegexp.isEmpty())      {          kDebug() << "browse regexp empty. Setting value.."; @@ -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; @@ -256,26 +256,26 @@ UrlSearchList UrlResolver::orderLists()      kDebug() << "HISTORY COUNT: " << historyCount;      //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);              } @@ -285,7 +285,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);      } @@ -306,7 +306,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); @@ -320,13 +320,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; @@ -342,9 +342,9 @@ void UrlResolver::computeHistory()      QList<HistoryItem> found = rApp->historyManager()->find(_typedString);      qSort(found); -    Q_FOREACH(const HistoryItem &i, found) +    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; @@ -358,7 +358,7 @@ void UrlResolver::computeBookmarks()  {      QList<KBookmark> found = rApp->bookmarkProvider()->find(_typedString);      kDebug() << "FOUND: " << found.count(); -    Q_FOREACH(const KBookmark &b, found) +    Q_FOREACH(const KBookmark & b, found)      {          UrlSearchItem gItem(UrlSearchItem::Bookmark, b.url().url(), b.fullText());          _bookmarks << gItem; @@ -371,7 +371,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); @@ -380,7 +380,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); @@ -398,15 +398,15 @@ void UrlResolver::computeSuggestions()  void UrlResolver::suggestionsReceived(const QString &text, const ResponseList &suggestions)  { -    if (text != _typedQuery) +    if(text != _typedQuery)          return;      UrlSearchList sugList;      QString urlString; -    Q_FOREACH(const Response &i, suggestions) +    Q_FOREACH(const Response & i, suggestions)      {          urlString = i.url; -        if (urlString.isEmpty()) +        if(urlString.isEmpty())          {              urlString = SearchEngine::buildQuery(UrlResolver::searchEngine(), i.title);          } @@ -425,7 +425,7 @@ void UrlResolver::suggestionsReceived(const QString &text, const ResponseList &s  //     QString dot = QString(QL1C('.'));  //     QString test1 = QString(QL1C('/')) + _typedString + dot;  //     QString test2 = dot + _typedString + dot; -//  +//  //     for (int i = 0; i < list->count(); i++)  //     {  //         item = list->at(i); diff --git a/src/urlbar/urlresolver.h b/src/urlbar/urlresolver.h index 030d1deb..48ffece0 100644 --- a/src/urlbar/urlresolver.h +++ b/src/urlbar/urlresolver.h @@ -69,21 +69,21 @@ public:      QString bookmarkPath;      UrlSearchItem(const UrlSearchItem &item) : type(item.type), -            url(item.url), -            title(item.title), -            description(item.description), -            image(item.image), -            image_width(item.image_width), -            image_height(item.image_height) +        url(item.url), +        title(item.title), +        description(item.description), +        image(item.image), +        image_width(item.image_width), +        image_height(item.image_height)      {};      UrlSearchItem() : type(UrlSearchItem::Undefined), -            url(QString()), -            title(QString()), -            description(QString()), -            image(QString()), -            image_width(0), -            image_height(0) +        url(QString()), +        title(QString()), +        description(QString()), +        image(QString()), +        image_width(0), +        image_height(0)      {};      UrlSearchItem(const int &_type, @@ -94,13 +94,13 @@ public:                    const int &_image_width = 0,                    const int &_image_height = 0                   ) -            : type(_type), -            url(_url), -            title(_title), -            description(_description), -            image(_image), -            image_width(_image_width), -            image_height(_image_height) +        : type(_type), +          url(_url), +          title(_title), +          description(_description), +          image(_image), +          image_width(_image_width), +          image_height(_image_height)      {};      inline bool operator==(const UrlSearchItem &i) const @@ -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 bf281177..492f2d83 100644 --- a/src/urlbar/webshortcutwidget.cpp +++ b/src/urlbar/webshortcutwidget.cpp @@ -37,7 +37,7 @@  #include <KServiceTypeTrader>  WebShortcutWidget::WebShortcutWidget(QWidget *parent) -        : QDialog(parent) +    : QDialog(parent)  {      QVBoxLayout *mainLayout = new QVBoxLayout();      QHBoxLayout *titleLayout = new QHBoxLayout(); @@ -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");      } @@ -154,11 +154,11 @@ void WebShortcutWidget::shortcutsChanged(const QString& newShorthands)      QString contenderName = "";      QString contenderWS = ""; -    Q_FOREACH(const QString &shorthand, shorthands) +    Q_FOREACH(const QString & shorthand, shorthands)      {          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 4aaf09da..c3b4beea 100644 --- a/src/urlfilterproxymodel.cpp +++ b/src/urlfilterproxymodel.cpp @@ -31,7 +31,7 @@  UrlFilterProxyModel::UrlFilterProxyModel(QObject *parent) -        : QSortFilterProxyModel(parent) +    : QSortFilterProxyModel(parent)  {      setFilterCaseSensitivity(Qt::CaseInsensitive);  } @@ -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 388815c2..ea645716 100644 --- a/src/urlpanel.cpp +++ b/src/urlpanel.cpp @@ -44,9 +44,9 @@  UrlPanel::UrlPanel(const QString &title, QWidget *parent, Qt::WindowFlags flags) -        : QDockWidget(title, parent, flags) -        , _treeView(new PanelTreeView(this)) -        , _loaded(false) +    : QDockWidget(title, parent, flags) +    , _treeView(new PanelTreeView(this)) +    , _loaded(false)  {      setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); @@ -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 67390e94..1d473ad8 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; diff --git a/src/useragent/useragentinfo.h b/src/useragent/useragentinfo.h index f95c696c..417aeea1 100644 --- a/src/useragent/useragentinfo.h +++ b/src/useragent/useragentinfo.h @@ -72,7 +72,7 @@ private:      QString userAgentDescription(int);      bool providerExists(int); -     +  private:      KService::List m_providers;  }; diff --git a/src/useragent/useragentwidget.cpp b/src/useragent/useragentwidget.cpp index 0cdddadf..f5862544 100644 --- a/src/useragent/useragentwidget.cpp +++ b/src/useragent/useragentwidget.cpp @@ -33,7 +33,7 @@  UserAgentWidget::UserAgentWidget(QWidget *parent) -        : QWidget(parent) +    : QWidget(parent)  {      setupUi(this); @@ -44,7 +44,7 @@ UserAgentWidget::UserAgentWidget(QWidget *parent)      QStringList hosts = config.groupList();      kDebug() << "HOSTS" << hosts; -    Q_FOREACH(const QString &host, hosts) +    Q_FOREACH(const QString & host, hosts)      {          QStringList tmp;          tmp << host; @@ -62,7 +62,7 @@ UserAgentWidget::UserAgentWidget(QWidget *parent)  void UserAgentWidget::deleteUserAgent()  {      QTreeWidgetItem *item = sitePolicyTreeWidget->currentItem(); -    if (!item) +    if(!item)          return;      sitePolicyTreeWidget->takeTopLevelItem(sitePolicyTreeWidget->indexOfTopLevelItem(item)); @@ -72,7 +72,7 @@ void UserAgentWidget::deleteUserAgent()      KConfig config("kio_httprc", KConfig::NoGlobals);      KConfigGroup group(&config, host); -    if (group.exists()) +    if(group.exists())      {          group.deleteGroup();          KProtocolManager::reparseConfiguration(); @@ -87,7 +87,7 @@ void UserAgentWidget::deleteAll()      KConfig config("kio_httprc", KConfig::NoGlobals);      QStringList list = config.groupList(); -    Q_FOREACH(const QString &groupName, list) +    Q_FOREACH(const QString & groupName, list)      {          kDebug() << "HOST: " << groupName; diff --git a/src/walletbar.cpp b/src/walletbar.cpp index cf30e6d8..01a6d658 100644 --- a/src/walletbar.cpp +++ b/src/walletbar.cpp @@ -43,31 +43,31 @@ WalletBar::WalletBar(QWidget *parent)      : KMessageWidget(parent)  {      setMessageType(KMessageWidget::Warning); -     +      QSize sz = size(); -    sz.setWidth( qobject_cast<QWidget *>(parent)->size().width() ); +    sz.setWidth(qobject_cast<QWidget *>(parent)->size().width());      resize(sz); -     +      setCloseButtonVisible(false); -     +      QAction *rememberAction = new QAction(KIcon("document-save"), i18n("Remember"), this);      connect(rememberAction, SIGNAL(triggered(bool)), this, SLOT(rememberData()));      addAction(rememberAction); -     +      QAction *neverHereAction = new QAction(KIcon("process-stop"), i18n("Never for This Site"), this);      connect(neverHereAction, SIGNAL(triggered(bool)), this, SLOT(neverRememberData()));      addAction(neverHereAction); -     +      QAction *notNowAction = new QAction(KIcon("dialog-cancel"), i18n("Not Now"), this);      connect(notNowAction, SIGNAL(triggered(bool)), this, SLOT(notNowRememberData())); -    addAction(notNowAction);     +    addAction(notNowAction);  }  void WalletBar::rememberData()  {      emit saveFormDataAccepted(m_key); -     +      animatedHide();      deleteLater();  } @@ -87,7 +87,7 @@ void WalletBar::neverRememberData()  void WalletBar::notNowRememberData()  {      emit saveFormDataRejected(m_key); -     +      animatedHide();      deleteLater();  } diff --git a/src/walletbar.h b/src/walletbar.h index 13429eb9..e63cb941 100644 --- a/src/walletbar.h +++ b/src/walletbar.h @@ -44,7 +44,7 @@ class REKONQ_TESTS_EXPORT WalletBar : public KMessageWidget  public:      WalletBar(QWidget *parent); -     +  private Q_SLOTS:      void rememberData();      void neverRememberData(); diff --git a/src/webicon.cpp b/src/webicon.cpp index 755d0c2e..c313ef1b 100644 --- a/src/webicon.cpp +++ b/src/webicon.cpp @@ -38,8 +38,8 @@  WebIcon::WebIcon(const KUrl& url, QObject *parent) -        : QObject(parent) -        , m_url(url) +    : QObject(parent) +    , m_url(url)  {      m_page.settings()->setAttribute(QWebSettings::PluginsEnabled, false);      m_page.settings()->setAttribute(QWebSettings::JavascriptEnabled, false); @@ -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 b42756fc..20c9d8f1 100644 --- a/src/webinspectorpanel.cpp +++ b/src/webinspectorpanel.cpp @@ -39,8 +39,8 @@  WebInspectorPanel::WebInspectorPanel(QString title, QWidget *parent) -        : QDockWidget(title, parent) -        , _inspector(0) +    : QDockWidget(title, parent) +    , _inspector(0)  {      setObjectName("webInspectorDock");  } @@ -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 9499d6f7..328a4397 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,39 +207,39 @@ 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();          item->setKGetTransferDbusPath(transferPath);          return true;      }      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(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. @@ -253,9 +253,9 @@ static bool downloadResource(const KUrl& srcUrl, const KIO::MetaData& metaData =  WebPage::WebPage(QWidget *parent) -        : KWebPage(parent, KWalletIntegration) -        , _networkAnalyzer(false) -        , _isOnRekonqPage(false) +    : KWebPage(parent, KWalletIntegration) +    , _networkAnalyzer(false) +    , _isOnRekonqPage(false)  {      // ----- handling unsupported content...      setForwardUnsupportedContent(true); @@ -268,23 +268,23 @@ 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      manager->setEmitReadyReadOnMetaDataChange(true); -     +      setNetworkAccessManager(manager);      // activate ssl warnings -    setSessionMetaData( QL1S("ssl_activate_warnings"), QL1S("TRUE") ); +    setSessionMetaData(QL1S("ssl_activate_warnings"), QL1S("TRUE"));      // ----- Web Plugin Factory      setPluginFactory(new WebPluginFactory(this));      // ----- last stuffs      connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(manageNetworkErrors(QNetworkReply*))); -     +      connect(this, SIGNAL(downloadRequested(const QNetworkRequest &)), this, SLOT(downloadRequest(const QNetworkRequest &)));      connect(this, SIGNAL(loadStarted()), this, SLOT(loadStarted()));      connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool))); @@ -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,17 +394,17 @@ 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()))      {          kDebug() << "POST HANDLING the unsupported...";          return;      } -    if (reply->error() != QNetworkReply::NoError) +    if(reply->error() != QNetworkReply::NoError)          return;      KIO::Integration::AccessManager::putReplyOnHold(reply); @@ -416,7 +416,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,8 +427,8 @@ 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..      {          kDebug() << "no service can handle this. We can just download it.."; @@ -439,13 +439,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:              kDebug() << "user choice: no services, just download!"; @@ -461,7 +461,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); @@ -480,7 +480,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)      {          kDebug() << "EMBEDDING CONTENT..."; @@ -534,9 +534,9 @@ void WebPage::loadFinished(bool ok)      // KWallet Integration      QStringList list = ReKonfig::walletBlackList(); -    if (wallet() +    if(wallet()              && !list.contains(mainFrame()->url().toString()) -       ) +      )      {          wallet()->fillFormData(mainFrame());      } @@ -548,16 +548,16 @@ 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()); -    if (isMainFrameRequest +    if(isMainFrameRequest              && _sslInfo.isValid()              && !domainSchemeMatch(reply->url(), _sslInfo.url()) -       ) +      )      {          // Reseting cached SSL info...          _sslInfo = WebSslInfo(); @@ -565,11 +565,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 && !_sslInfo.isValid()) +        if(isMainFrameRequest && !_sslInfo.isValid())          {              // Obtain and set the SSL information if any...              _sslInfo.restoreFrom(reply->attribute(static_cast<QNetworkRequest::Attribute>(KIO::AccessManager::MetaData)), reply->url()); @@ -600,10 +600,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; @@ -632,7 +632,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");      } @@ -698,25 +698,25 @@ void WebPage::downloadAllContentsWithKGet(QPoint)      KUrl relativeUrl;      QWebElementCollection images = mainFrame()->documentElement().findAll("img"); -    foreach(const QWebElement &img, images) +    foreach(const QWebElement & img, images)      {          relativeUrl.setEncodedUrl(img.attribute("src").toUtf8(), KUrl::TolerantMode);          contents << baseUrl.resolved(relativeUrl).toString();      }      QWebElementCollection links = mainFrame()->documentElement().findAll("a"); -    foreach(const QWebElement &link, links) +    foreach(const QWebElement & link, links)      {          relativeUrl.setEncodedUrl(link.attribute("href").toUtf8(), KUrl::TolerantMode);          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()));      } @@ -725,7 +725,7 @@ void WebPage::downloadAllContentsWithKGet(QPoint)  void WebPage::showSSLInfo(QPoint)  { -    if (_sslInfo.isValid()) +    if(_sslInfo.isValid())      {          QPointer<KSslInfoDialog> dlg = new KSslInfoDialog(view());          dlg->setSslInfo(_sslInfo.certificateChain(), @@ -744,7 +744,7 @@ void WebPage::showSSLInfo(QPoint)          return;      } -    if (mainFrame()->url().scheme() == QL1S("https")) +    if(mainFrame()->url().scheme() == QL1S("https"))      {          KMessageBox::error(view(),                             i18n("The SSL information for this site appears to be corrupt."), @@ -763,7 +763,7 @@ void WebPage::showSSLInfo(QPoint)  void WebPage::updateImage(bool ok)  { -    if (ok) +    if(ok)      {          NewTabPage p(mainFrame());          p.snapFinished(); @@ -773,7 +773,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()); diff --git a/src/webpage.h b/src/webpage.h index 09977bff..3f9f27de 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -74,7 +74,7 @@ public:      {          return _loadingUrl;      }; -     +      inline QString suggestedFileName()      {          return _suggestedFileName; diff --git a/src/webpluginfactory.cpp b/src/webpluginfactory.cpp index c2fe95fa..9fe80075 100644 --- a/src/webpluginfactory.cpp +++ b/src/webpluginfactory.cpp @@ -36,8 +36,8 @@  WebPluginFactory::WebPluginFactory(QObject *parent) -        : KWebPluginFactory(parent) -        , _loadClickToFlash(false) +    : KWebPluginFactory(parent) +    , _loadClickToFlash(false)  {      connect(this, SIGNAL(signalLoadClickToFlash(bool)), SLOT(setLoadClickToFlash(bool)));  } @@ -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 d03e39a4..19b10506 100644 --- a/src/websnap.cpp +++ b/src/websnap.cpp @@ -48,8 +48,8 @@  WebSnap::WebSnap(const KUrl& url, QObject *parent) -        : QObject(parent) -        , m_url(url) +    : QObject(parent) +    , m_url(url)  {      // this to not register websnap history      m_page.settings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, true); @@ -191,7 +191,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/websnap.h b/src/websnap.h index f1b04aad..dd2cb93b 100644 --- a/src/websnap.h +++ b/src/websnap.h @@ -86,7 +86,7 @@ public:       */      static QPixmap renderPagePreview(const QWebPage &page, int w = defaultWidth, int h = defaultHeight); -    // static QPixmap renderVisiblePagePreview(const QWebPage &page, int w = WIDTH, int h = HEIGHT);  +    // static QPixmap renderVisiblePagePreview(const QWebPage &page, int w = WIDTH, int h = HEIGHT);      // TODO: try to make this method work => more previews for the urlbar      /** diff --git a/src/websslinfo.cpp b/src/websslinfo.cpp index e77e24e8..720c2209 100644 --- a/src/websslinfo.cpp +++ b/src/websslinfo.cpp @@ -30,7 +30,7 @@ class WebSslInfo::WebSslInfoPrivate  {  public:      WebSslInfoPrivate() -            : usedCipherBits(0), supportedCipherBits(0) {} +        : usedCipherBits(0), supportedCipherBits(0) {}      QUrl url;      QString ciphers; @@ -45,12 +45,12 @@ public:  };  WebSslInfo::WebSslInfo() -        : d(new WebSslInfo::WebSslInfoPrivate) +    : d(new WebSslInfo::WebSslInfoPrivate)  {  }  WebSslInfo::WebSslInfo(const WebSslInfo& other) -        : d(new WebSslInfo::WebSslInfoPrivate) +    : d(new WebSslInfo::WebSslInfoPrivate)  {      *this = other;  } @@ -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 578bf2a8..52f02467 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; @@ -199,10 +199,10 @@ void WebTab::showRSSInfo(const QPoint &pos)      QMap<KUrl, QString> map; -    foreach(const QWebElement &el, col) +    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); @@ -310,7 +310,7 @@ void WebTab::showMessageBar()      MessageBar *msgBar = new MessageBar(i18n("It seems rekonq was not closed properly. Do you want "                                          "to restore the last saved session?")                                          , this); -     +      qobject_cast<QVBoxLayout *>(layout())->insertWidget(0, msgBar);      msgBar->animatedShow(); diff --git a/src/webtab.h b/src/webtab.h index 55c0dff4..5157fb19 100644 --- a/src/webtab.h +++ b/src/webtab.h @@ -90,7 +90,7 @@ public:      void setPart(KParts::ReadOnlyPart *p, const KUrl &u);      void showMessageBar(); -     +  private Q_SLOTS:      void updateProgress(int progress);      void loadFinished(bool); diff --git a/src/webview.cpp b/src/webview.cpp index 37e9783d..218dc151 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -65,18 +65,18 @@  WebView::WebView(QWidget* parent) -        : KWebView(parent, false) -        , m_mousePos(QPoint(0, 0)) -        , m_autoScrollTimer(new QTimer(this)) -        , m_vScrollSpeed(0) -        , m_hScrollSpeed(0) -        , m_canEnableAutoScroll(true) -        , m_isAutoScrollEnabled(false) -        , m_autoScrollIndicator(QPixmap(KStandardDirs::locate("appdata" , "pics/autoscroll.png"))) -        , m_smoothScrollTimer(new QTimer(this)) -        , m_smoothScrolling(false) -        , m_dy(0) -        , m_smoothScrollSteps(0) +    : KWebView(parent, false) +    , m_mousePos(QPoint(0, 0)) +    , m_autoScrollTimer(new QTimer(this)) +    , m_vScrollSpeed(0) +    , m_hScrollSpeed(0) +    , m_canEnableAutoScroll(true) +    , m_isAutoScrollEnabled(false) +    , m_autoScrollIndicator(QPixmap(KStandardDirs::locate("appdata" , "pics/autoscroll.png"))) +    , m_smoothScrollTimer(new QTimer(this)) +    , m_smoothScrolling(false) +    , m_dy(0) +    , m_smoothScrollSteps(0)  {      WebPage *page = new WebPage(this);      setPage(page); @@ -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,17 +216,17 @@ 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); -        foreach(const KService::Ptr &engine, SearchEngine::favorites()) +        foreach(const KService::Ptr & engine, SearchEngine::favorites())          {              a = new KAction(engine->name(), this);              a->setIcon(rApp->iconManager()->iconForUrl(SearchEngine::buildQuery(engine, ""))); @@ -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()) +        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 7399b000..9dcf5e72 100644 --- a/src/zoombar.cpp +++ b/src/zoombar.cpp @@ -51,11 +51,11 @@  ZoomBar::ZoomBar(QWidget *parent) -        : QWidget(parent) -        , m_zoomIn(new QToolButton(this)) -        , m_zoomOut(new QToolButton(this)) -        , m_zoomNormal(new QToolButton(this)) -        , m_zoomSlider(new QSlider(Qt::Horizontal, this)) +    : QWidget(parent) +    , m_zoomIn(new QToolButton(this)) +    , m_zoomOut(new QToolButton(this)) +    , m_zoomNormal(new QToolButton(this)) +    , m_zoomSlider(new QSlider(Qt::Horizontal, this))  {      QHBoxLayout *layout = new QHBoxLayout; @@ -122,11 +122,11 @@ void ZoomBar::setupActions(MainWindow *window)  void ZoomBar::show()  {      // show findbar if not visible -    if (isHidden()) +    if(isHidden())      {          emit visibilityChanged(true);          QWidget::show(); -        m_zoomSlider->setValue(rApp->mainWindow()->currentTab()->view()->zoomFactor()*10); +        m_zoomSlider->setValue(rApp->mainWindow()->currentTab()->view()->zoomFactor() * 10);      }  } @@ -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); @@ -172,7 +172,7 @@ void ZoomBar::updateSlider(int webview)  void ZoomBar::setValue(int value)  {      m_zoomSlider->setValue(value); -    m_percentage->setText(i18nc("percentage of the website zoom", "%1%", QString::number(value*10))); +    m_percentage->setText(i18nc("percentage of the website zoom", "%1%", QString::number(value * 10)));      WebTab *tab = rApp->mainWindow()->currentTab();      saveZoomValue(tab->url().host(), value); | 
