summaryrefslogtreecommitdiff
path: root/src/plugins/git/gitorious
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2013-01-08 03:32:53 +0200
committerhjk <qthjk@ovi.com>2013-01-08 10:48:18 +0100
commit29a93998df8405e8799ad23934a56cd99fb36403 (patch)
treec0e4a341efeef78fbe530a618caaa50254daad59 /src/plugins/git/gitorious
parent73a2717bed511cffd0163195c314f7d919e5128b (diff)
downloadqt-creator-29a93998df8405e8799ad23934a56cd99fb36403.tar.gz
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>
Diffstat (limited to 'src/plugins/git/gitorious')
-rw-r--r--src/plugins/git/gitorious/gitorious.cpp52
-rw-r--r--src/plugins/git/gitorious/gitorioushostwidget.cpp3
-rw-r--r--src/plugins/git/gitorious/gitoriousprojectwidget.cpp10
3 files changed, 28 insertions, 37 deletions
diff --git a/src/plugins/git/gitorious/gitorious.cpp b/src/plugins/git/gitorious/gitorious.cpp
index a89ca8b657..56c0ebe6e4 100644
--- a/src/plugins/git/gitorious/gitorious.cpp
+++ b/src/plugins/git/gitorious/gitorious.cpp
@@ -207,11 +207,10 @@ GitoriousProjectReader::ProjectList GitoriousProjectReader::read(const QByteArra
while (!reader.atEnd()) {
reader.readNext();
if (reader.isStartElement()) {
- if (reader.name() == QLatin1String("projects")) {
+ if (reader.name() == QLatin1String("projects"))
readProjects(reader);
- } else {
+ else
readUnknownElement(reader);
- }
}
}
@@ -259,17 +258,16 @@ QSharedPointer<GitoriousProject> GitoriousProjectReader::readProject(QXmlStreamR
if (reader.isStartElement()) {
const QStringRef name = reader.name();
- if (name == QLatin1String("description")) {
+ if (name == QLatin1String("description"))
project->description = reader.readElementText();
- } else if (name == QLatin1String("title")) {
+ else if (name == QLatin1String("title"))
project->name = reader.readElementText();
- } else if (name == QLatin1String("slug") && project->name.isEmpty()) {
+ else if (name == QLatin1String("slug") && project->name.isEmpty())
project->name = reader.readElementText();
- } else if (name == QLatin1String("repositories")) {
+ else if (name == QLatin1String("repositories"))
project->repositories = readRepositories(reader);
- } else {
+ else
readUnknownElement(reader);
- }
}
}
return project;
@@ -287,24 +285,22 @@ QList<GitoriousRepository> GitoriousProjectReader::readRepositories(QXmlStreamRe
if (reader.isEndElement()) {
const QStringRef name = reader.name();
- if (name == m_mainLinesElement || name == m_clonesElement) {
+ if (name == m_mainLinesElement || name == m_clonesElement)
defaultType = -1;
- } else {
+ else
break;
- }
}
if (reader.isStartElement()) {
const QStringRef name = reader.name();
- if (reader.name() == QLatin1String("repository")) {
+ if (reader.name() == QLatin1String("repository"))
repositories.push_back(readRepository(reader, defaultType));
- } else if (name == m_mainLinesElement) {
+ else if (name == m_mainLinesElement)
defaultType = GitoriousRepository::MainLineRepository;
- } else if (name == m_clonesElement) {
+ else if (name == m_clonesElement)
defaultType = GitoriousRepository::CloneRepository;
- } else {
+ else
readUnknownElement(reader);
- }
}
}
return repositories;
@@ -324,23 +320,22 @@ GitoriousRepository GitoriousProjectReader::readRepository(QXmlStreamReader &rea
if (reader.isStartElement()) {
const QStringRef name = reader.name();
- if (name == QLatin1String("name")) {
+ if (name == QLatin1String("name"))
repository.name = reader.readElementText();
- } else if (name == QLatin1String("owner")) {
+ else if (name == QLatin1String("owner"))
repository.owner = reader.readElementText();
- } else if (name == QLatin1String("id")) {
+ else if (name == QLatin1String("id"))
repository.id = reader.readElementText().toInt();
- } else if (name == QLatin1String("description")) {
+ else if (name == QLatin1String("description"))
repository.description = reader.readElementText();
- } else if (name == QLatin1String("push_url")) {
+ else if (name == QLatin1String("push_url"))
repository.pushUrl = reader.readElementText();
- } else if (name == QLatin1String("clone_url")) {
+ else if (name == QLatin1String("clone_url"))
repository.cloneUrl = reader.readElementText();
- } else if (name == QLatin1String("namespace")) {
+ else if (name == QLatin1String("namespace"))
repository.type = repositoryType(reader.readElementText());
- } else {
+ else
readUnknownElement(reader);
- }
}
}
return repository;
@@ -588,11 +583,10 @@ void Gitorious::restoreSettings(const QString &group, const QSettings *s)
const QStringList hosts = s->value(group + QLatin1Char('/') + QLatin1String(settingsKeyC), QStringList()).toStringList();
foreach (const QString &h, hosts) {
const int sepPos = h.indexOf(separator);
- if (sepPos == -1) {
+ if (sepPos == -1)
addHost(GitoriousHost(h));
- } else {
+ else
addHost(GitoriousHost(h.mid(0, sepPos), h.mid(sepPos + 1)));
- }
}
}
diff --git a/src/plugins/git/gitorious/gitorioushostwidget.cpp b/src/plugins/git/gitorious/gitorioushostwidget.cpp
index 2042afc449..92000ac139 100644
--- a/src/plugins/git/gitorious/gitorioushostwidget.cpp
+++ b/src/plugins/git/gitorious/gitorioushostwidget.cpp
@@ -64,9 +64,8 @@ static QList<QStandardItem *> hostEntry(const QString &host,
// Empty for dummy, else "..." or count
QStandardItem *projectCountItem = 0;
QString countItemText;
- if (!isDummyEntry) {
+ if (!isDummyEntry)
countItemText = projectCount ? QString::number(projectCount) : QString(QLatin1String("..."));
- }
projectCountItem = new QStandardItem(countItemText);
projectCountItem->setFlags(nonEditableFlags);
QStandardItem *descriptionItem = new QStandardItem(description);
diff --git a/src/plugins/git/gitorious/gitoriousprojectwidget.cpp b/src/plugins/git/gitorious/gitoriousprojectwidget.cpp
index 844beaa22a..08af912f70 100644
--- a/src/plugins/git/gitorious/gitoriousprojectwidget.cpp
+++ b/src/plugins/git/gitorious/gitoriousprojectwidget.cpp
@@ -212,11 +212,10 @@ void GitoriousProjectWidget::setDescription(const QString &description,
descLine.truncate(newLinePos);
if (descLine.size() > MaxDescriptionLineLength) {
const int dotPos = descLine.lastIndexOf(QLatin1Char('.'), MaxDescriptionLineLength);
- if (dotPos != -1) {
+ if (dotPos != -1)
descLine.truncate(dotPos);
- } else {
+ else
descLine.truncate(MaxDescriptionLineLength);
- }
descLine += QLatin1String("...");
}
items->at(descriptionColumn)->setText(descLine);
@@ -230,11 +229,10 @@ void GitoriousProjectWidget::setDescription(const QString &description,
// Do not fall for "(http://XX)", strip special characters
static QRegExp urlRegExp(QLatin1String("(http://[\\w\\.-]+/[a-zA-Z0-9/\\-&]*)"));
QTC_CHECK(urlRegExp.isValid());
- if (urlRegExp.indexIn(description) != -1) {
+ if (urlRegExp.indexIn(description) != -1)
*url= urlRegExp.cap(1);
- } else {
+ else
url->clear();
- }
}
}