Git: De-noise

* Remove QLatin1{String|Char} where possible
* Use initializer lists for QStringList

Change-Id: I8479f87f4fc909b5d74d854956885564209538e4
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Orgad Shaneh
2016-07-21 00:28:18 +03:00
committed by Orgad Shaneh
parent 539e33da02
commit 516161c875
31 changed files with 312 additions and 353 deletions

View File

@@ -45,7 +45,7 @@ class PushItemDelegate : public IconItemDelegate
{
public:
PushItemDelegate(LogChangeWidget *widget)
: IconItemDelegate(widget, QLatin1String(":/git/images/arrowup.png"))
: IconItemDelegate(widget, ":/git/images/arrowup.png")
{
}
@@ -62,17 +62,16 @@ QString GerritPushDialog::determineRemoteBranch(const QString &localBranch)
QString output;
QString error;
QStringList args;
args << QLatin1String("-r") << QLatin1String("--contains")
<< earliestCommit + QLatin1Char('^');
if (!GitPlugin::client()->synchronousBranchCmd(m_workingDir, args, &output, &error))
if (!GitPlugin::client()->synchronousBranchCmd(
m_workingDir, { "-r", "--contains", earliestCommit + '^' }, &output, &error)) {
return QString();
const QString head = QLatin1String("/HEAD");
QStringList refs = output.split(QLatin1Char('\n'));
}
const QString head = "/HEAD";
QStringList refs = output.split('\n');
QString remoteTrackingBranch;
if (localBranch != QLatin1String("HEAD"))
if (localBranch != "HEAD")
remoteTrackingBranch = GitPlugin::client()->synchronousTrackingBranch(m_workingDir, localBranch);
QString remoteBranch;
@@ -94,31 +93,30 @@ QString GerritPushDialog::determineRemoteBranch(const QString &localBranch)
void GerritPushDialog::initRemoteBranches()
{
QString output;
QStringList args;
const QString head = QLatin1String("/HEAD");
const QString head = "/HEAD";
QString remotesPrefix(QLatin1String("refs/remotes/"));
args << QLatin1String("--format=%(refname)\t%(committerdate:raw)")
<< remotesPrefix;
if (!GitPlugin::client()->synchronousForEachRefCmd(m_workingDir, args, &output))
QString remotesPrefix("refs/remotes/");
if (!GitPlugin::client()->synchronousForEachRefCmd(
m_workingDir, { "--format=%(refname)\t%(committerdate:raw)", remotesPrefix }, &output)) {
return;
}
const QStringList refs = output.split(QLatin1String("\n"));
const QStringList refs = output.split("\n");
foreach (const QString &reference, refs) {
QStringList entries = reference.split(QLatin1Char('\t'));
QStringList entries = reference.split('\t');
if (entries.count() < 2 || entries.first().endsWith(head))
continue;
const QString ref = entries.at(0).mid(remotesPrefix.size());
int refBranchIndex = ref.indexOf(QLatin1Char('/'));
int timeT = entries.at(1).leftRef(entries.at(1).indexOf(QLatin1Char(' '))).toInt();
int refBranchIndex = ref.indexOf('/');
int timeT = entries.at(1).leftRef(entries.at(1).indexOf(' ')).toInt();
BranchDate bd(ref.mid(refBranchIndex + 1), QDateTime::fromTime_t(timeT).date());
m_remoteBranches.insertMulti(ref.left(refBranchIndex), bd);
}
QStringList remotes = GitPlugin::client()->synchronousRemotesList(m_workingDir).keys();
remotes.removeDuplicates();
{
const QString origin = QLatin1String("origin");
const QString gerrit = QLatin1String("gerrit");
const QString origin = "origin";
const QString gerrit = "gerrit";
if (remotes.removeOne(origin))
remotes.prepend(origin);
if (remotes.removeOne(gerrit))
@@ -155,7 +153,7 @@ GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &rev
updateCommits(m_ui->localBranchComboBox->currentIndex());
setRemoteBranches();
QRegExpValidator *noSpaceValidator = new QRegExpValidator(QRegExp(QLatin1String("^\\S+$")), this);
QRegExpValidator *noSpaceValidator = new QRegExpValidator(QRegExp("^\\S+$"), this);
m_ui->reviewersLineEdit->setText(reviewerList);
m_ui->reviewersLineEdit->setValidator(noSpaceValidator);
m_ui->topicLineEdit->setValidator(noSpaceValidator);
@@ -179,16 +177,14 @@ QString GerritPushDialog::selectedCommit() const
QString GerritPushDialog::calculateChangeRange(const QString &branch)
{
QString remote = selectedRemoteName();
remote += QLatin1Char('/');
remote += '/';
remote += selectedRemoteBranchName();
QStringList args(remote + QLatin1String("..") + branch);
args << QLatin1String("--count");
QString number;
QString error;
GitPlugin::client()->synchronousRevListCmd(m_workingDir, args, &number, &error);
GitPlugin::client()->synchronousRevListCmd(m_workingDir, { remote + ".." + branch, "--count" },
&number, &error);
number.chop(1);
return number;
@@ -210,7 +206,7 @@ void GerritPushDialog::setChangeRange()
return;
}
m_ui->infoLabel->show();
const QString remote = selectedRemoteName() + QLatin1Char('/') + remoteBranchName;
const QString remote = selectedRemoteName() + '/' + remoteBranchName;
m_ui->infoLabel->setText(
tr("Number of commits between %1 and %2: %3").arg(branch, remote, range));
}
@@ -259,7 +255,7 @@ void GerritPushDialog::updateCommits(int index)
const QString remoteBranch = determineRemoteBranch(branch);
if (!remoteBranch.isEmpty()) {
const int slash = remoteBranch.indexOf(QLatin1Char('/'));
const int slash = remoteBranch.indexOf('/');
m_suggestedRemoteBranch = remoteBranch.mid(slash + 1);
const QString remote = remoteBranch.left(slash);
@@ -285,7 +281,7 @@ QString GerritPushDialog::selectedRemoteBranchName() const
QString GerritPushDialog::selectedPushType() const
{
return m_ui->draftCheckBox->isChecked() ? QLatin1String("drafts") : QLatin1String("for");
return QLatin1String(m_ui->draftCheckBox->isChecked() ? "drafts" : "for");
}
QString GerritPushDialog::selectedTopic() const