Remove braces for single lines of conditions

#!/usr/bin/env ruby

Dir.glob('**/*.cpp') { |file|
  # skip ast (excluding paste, astpath, and canv'ast'imer)
  next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
  s = File.read(file)
  next if s.include?('qlalr')
  orig = s.dup
  s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
    res = $&
    if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
      res
    else
      res.gsub!('} else', 'else')
      res.gsub!(/\n +} *\n/m, "\n")
      res.gsub(/ *{$/, '')
    end
  }
  s.gsub!(/ *$/, '')
  File.open(file, 'wb').write(s) if s != orig
}

Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Orgad Shaneh
2013-01-08 03:32:53 +02:00
committed by hjk
parent 73a2717bed
commit 29a93998df
396 changed files with 1856 additions and 3135 deletions

View File

@@ -247,11 +247,10 @@ void FutureProgress::setFinished()
d->m_progress->setFinished(true);
if (d->m_watcher.future().isCanceled()) {
if (d->m_watcher.future().isCanceled())
d->m_progress->setError(true);
} else {
else
d->m_progress->setError(false);
}
emit finished();
d->tryToFadeAway();
}
@@ -363,15 +362,13 @@ QString FutureProgress::type() const
void FutureProgress::setKeepOnFinish(KeepOnFinishType keepType)
{
if (d->m_keep == keepType) {
if (d->m_keep == keepType)
return;
}
d->m_keep = keepType;
//if it is not finished tryToFadeAway is called by setFinished at the end
if (d->m_watcher.isFinished()) {
if (d->m_watcher.isFinished())
d->tryToFadeAway();
}
}
bool FutureProgress::keepOnFinish() const

View File

@@ -272,9 +272,8 @@ void ProgressManagerPrivate::cancelTasks(const QString &type)
delete task.key();
task = m_runningTasks.erase(task);
}
if (found) {
if (found)
emit allTasksFinished(type);
}
}
void ProgressManagerPrivate::cancelAllRunningTasks()
@@ -330,9 +329,8 @@ void ProgressManagerPrivate::taskFinished()
m_runningTasks.remove(task);
delete task;
if (!m_runningTasks.key(type, 0)) {
if (!m_runningTasks.key(type, 0))
emit allTasksFinished(type);
}
}
void ProgressManagerPrivate::disconnectApplicationTask()

View File

@@ -69,11 +69,10 @@ FutureProgress *ProgressView::addTask(const QFuture<void> &future,
m_layout->insertWidget(0, progress);
m_taskList.append(progress);
progress->setType(type);
if (flags.testFlag(ProgressManager::KeepOnFinish)) {
if (flags.testFlag(ProgressManager::KeepOnFinish))
progress->setKeepOnFinish(FutureProgress::KeepOnFinishTillUserInteraction);
} else {
else
progress->setKeepOnFinish(FutureProgress::HideOnFinish);
}
connect(progress, SIGNAL(removeMe()), this, SLOT(slotRemoveTask()));
return progress;
}