forked from qt-creator/qt-creator
GitPlugin: Simplify return statements
Change-Id: If09c93acade749326b95bb1c6068b2d43a4d8551 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -264,22 +264,22 @@ BranchModel::~BranchModel()
|
|||||||
QModelIndex BranchModel::index(int row, int column, const QModelIndex &parentIdx) const
|
QModelIndex BranchModel::index(int row, int column, const QModelIndex &parentIdx) const
|
||||||
{
|
{
|
||||||
if (column > 1)
|
if (column > 1)
|
||||||
return QModelIndex();
|
return {};
|
||||||
BranchNode *parentNode = indexToNode(parentIdx);
|
BranchNode *parentNode = indexToNode(parentIdx);
|
||||||
|
|
||||||
if (row >= parentNode->count())
|
if (row >= parentNode->count())
|
||||||
return QModelIndex();
|
return {};
|
||||||
return nodeToIndex(parentNode->children.at(row), column);
|
return nodeToIndex(parentNode->children.at(row), column);
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex BranchModel::parent(const QModelIndex &index) const
|
QModelIndex BranchModel::parent(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QModelIndex();
|
return {};
|
||||||
|
|
||||||
BranchNode *node = indexToNode(index);
|
BranchNode *node = indexToNode(index);
|
||||||
if (node->parent == d->rootNode)
|
if (node->parent == d->rootNode)
|
||||||
return QModelIndex();
|
return {};
|
||||||
return nodeToIndex(node->parent, ColumnBranch);
|
return nodeToIndex(node->parent, ColumnBranch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,7 +304,7 @@ QVariant BranchModel::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
BranchNode *node = indexToNode(index);
|
BranchNode *node = indexToNode(index);
|
||||||
if (!node)
|
if (!node)
|
||||||
return QVariant();
|
return {};
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::DisplayRole: {
|
case Qt::DisplayRole: {
|
||||||
@@ -330,7 +330,7 @@ QVariant BranchModel::data(const QModelIndex &index, int role) const
|
|||||||
return index.column() == 0 ? node->fullRef() : QVariant();
|
return index.column() == 0 ? node->fullRef() : QVariant();
|
||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
if (!node->isLeaf())
|
if (!node->isLeaf())
|
||||||
return QVariant();
|
return {};
|
||||||
if (node->toolTip.isEmpty())
|
if (node->toolTip.isEmpty())
|
||||||
node->toolTip = toolTip(node->sha);
|
node->toolTip = toolTip(node->sha);
|
||||||
return node->toolTip;
|
return node->toolTip;
|
||||||
@@ -346,7 +346,7 @@ QVariant BranchModel::data(const QModelIndex &index, int role) const
|
|||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -524,17 +524,17 @@ FilePath BranchModel::workingDirectory() const
|
|||||||
QModelIndex BranchModel::currentBranch() const
|
QModelIndex BranchModel::currentBranch() const
|
||||||
{
|
{
|
||||||
if (!d->currentBranch)
|
if (!d->currentBranch)
|
||||||
return QModelIndex();
|
return {};
|
||||||
return nodeToIndex(d->currentBranch, ColumnBranch);
|
return nodeToIndex(d->currentBranch, ColumnBranch);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString BranchModel::fullName(const QModelIndex &idx, bool includePrefix) const
|
QString BranchModel::fullName(const QModelIndex &idx, bool includePrefix) const
|
||||||
{
|
{
|
||||||
if (!idx.isValid())
|
if (!idx.isValid())
|
||||||
return QString();
|
return {};
|
||||||
BranchNode *node = indexToNode(idx);
|
BranchNode *node = indexToNode(idx);
|
||||||
if (!node || !node->isLeaf())
|
if (!node || !node->isLeaf())
|
||||||
return QString();
|
return {};
|
||||||
if (node == d->headNode)
|
if (node == d->headNode)
|
||||||
return QString("HEAD");
|
return QString("HEAD");
|
||||||
return node->fullRef(includePrefix);
|
return node->fullRef(includePrefix);
|
||||||
@@ -550,7 +550,7 @@ QStringList BranchModel::localBranchNames() const
|
|||||||
QString BranchModel::sha(const QModelIndex &idx) const
|
QString BranchModel::sha(const QModelIndex &idx) const
|
||||||
{
|
{
|
||||||
if (!idx.isValid())
|
if (!idx.isValid())
|
||||||
return QString();
|
return {};
|
||||||
BranchNode *node = indexToNode(idx);
|
BranchNode *node = indexToNode(idx);
|
||||||
return node->sha;
|
return node->sha;
|
||||||
}
|
}
|
||||||
@@ -558,13 +558,11 @@ QString BranchModel::sha(const QModelIndex &idx) const
|
|||||||
QDateTime BranchModel::dateTime(const QModelIndex &idx) const
|
QDateTime BranchModel::dateTime(const QModelIndex &idx) const
|
||||||
{
|
{
|
||||||
if (!idx.isValid())
|
if (!idx.isValid())
|
||||||
return QDateTime();
|
return {};
|
||||||
BranchNode *node = indexToNode(idx);
|
BranchNode *node = indexToNode(idx);
|
||||||
return node->dateTime;
|
return node->dateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool BranchModel::isHead(const QModelIndex &idx) const
|
bool BranchModel::isHead(const QModelIndex &idx) const
|
||||||
{
|
{
|
||||||
if (!idx.isValid())
|
if (!idx.isValid())
|
||||||
@@ -679,7 +677,7 @@ static int positionForName(BranchNode *node, const QString &name)
|
|||||||
QModelIndex BranchModel::addBranch(const QString &name, bool track, const QModelIndex &startPoint)
|
QModelIndex BranchModel::addBranch(const QString &name, bool track, const QModelIndex &startPoint)
|
||||||
{
|
{
|
||||||
if (!d->rootNode || !d->rootNode->count())
|
if (!d->rootNode || !d->rootNode->count())
|
||||||
return QModelIndex();
|
return {};
|
||||||
|
|
||||||
const QString trackedBranch = fullName(startPoint);
|
const QString trackedBranch = fullName(startPoint);
|
||||||
const QString fullTrackedBranch = fullName(startPoint, true);
|
const QString fullTrackedBranch = fullName(startPoint, true);
|
||||||
@@ -705,7 +703,7 @@ QModelIndex BranchModel::addBranch(const QString &name, bool track, const QModel
|
|||||||
|
|
||||||
if (!gitClient().synchronousBranchCmd(d->workingDirectory, args, &output, &errorMessage)) {
|
if (!gitClient().synchronousBranchCmd(d->workingDirectory, args, &output, &errorMessage)) {
|
||||||
VcsOutputWindow::appendError(errorMessage);
|
VcsOutputWindow::appendError(errorMessage);
|
||||||
return QModelIndex();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
BranchNode *local = d->rootNode->children.at(LocalBranches);
|
BranchNode *local = d->rootNode->children.at(LocalBranches);
|
||||||
@@ -761,7 +759,7 @@ std::optional<QString> BranchModel::remoteName(const QModelIndex &idx) const
|
|||||||
if (!node)
|
if (!node)
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
if (node == remotesNode)
|
if (node == remotesNode)
|
||||||
return QString();
|
return {};
|
||||||
if (node->parent == remotesNode)
|
if (node->parent == remotesNode)
|
||||||
return node->name;
|
return node->name;
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
@@ -888,7 +886,7 @@ BranchNode *BranchModel::indexToNode(const QModelIndex &index) const
|
|||||||
QModelIndex BranchModel::nodeToIndex(BranchNode *node, int column) const
|
QModelIndex BranchModel::nodeToIndex(BranchNode *node, int column) const
|
||||||
{
|
{
|
||||||
if (node == d->rootNode)
|
if (node == d->rootNode)
|
||||||
return QModelIndex();
|
return {};
|
||||||
return createIndex(node->parent->rowOf(node), column, static_cast<void *>(node));
|
return createIndex(node->parent->rowOf(node), column, static_cast<void *>(node));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -333,7 +333,7 @@ QModelIndex BranchView::selectedIndex()
|
|||||||
{
|
{
|
||||||
QModelIndexList selected = m_branchView->selectionModel()->selectedIndexes();
|
QModelIndexList selected = m_branchView->selectionModel()->selectedIndexes();
|
||||||
if (selected.isEmpty())
|
if (selected.isEmpty())
|
||||||
return QModelIndex();
|
return {};
|
||||||
return m_filterModel->mapToSource(selected.at(0));
|
return m_filterModel->mapToSource(selected.at(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ static QString findEntry(const QString &line, const QString &type)
|
|||||||
const QRegularExpressionMatch match = entryMatch(line, type);
|
const QRegularExpressionMatch match = entryMatch(line, type);
|
||||||
if (match.hasMatch())
|
if (match.hasMatch())
|
||||||
return match.captured(1);
|
return match.captured(1);
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool replaceEntry(QString &line, const QString &type, const QString &value)
|
static bool replaceEntry(QString &line, const QString &type, const QString &value)
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ static inline QString defaultUrl(const QSharedPointer<GerritParameters> &p,
|
|||||||
QString GerritPatchSet::approvalsToHtml() const
|
QString GerritPatchSet::approvalsToHtml() const
|
||||||
{
|
{
|
||||||
if (approvals.isEmpty())
|
if (approvals.isEmpty())
|
||||||
return QString();
|
return {};
|
||||||
|
|
||||||
QString result;
|
QString result;
|
||||||
QTextStream str(&result);
|
QTextStream str(&result);
|
||||||
@@ -411,7 +411,7 @@ QString GerritModel::toHtml(const QModelIndex& index) const
|
|||||||
static const QString neededByHeader = Git::Tr::tr("Needed by");
|
static const QString neededByHeader = Git::Tr::tr("Needed by");
|
||||||
|
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QString();
|
return {};
|
||||||
const GerritChangePtr c = change(index);
|
const GerritChangePtr c = change(index);
|
||||||
const QString serverPrefix = c->url.left(c->url.lastIndexOf('/') + 1);
|
const QString serverPrefix = c->url.left(c->url.lastIndexOf('/') + 1);
|
||||||
QString result;
|
QString result;
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ QString GerritPushDialog::determineRemoteBranch(const QString &localBranch)
|
|||||||
|
|
||||||
if (!gitClient().synchronousBranchCmd(
|
if (!gitClient().synchronousBranchCmd(
|
||||||
m_workingDir, {"-r", "--contains", earliestCommit + '^'}, &output, &error)) {
|
m_workingDir, {"-r", "--contains", earliestCommit + '^'}, &output, &error)) {
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
const QString head = "/HEAD";
|
const QString head = "/HEAD";
|
||||||
const QStringList refs = output.split('\n');
|
const QStringList refs = output.split('\n');
|
||||||
|
|||||||
@@ -1677,7 +1677,7 @@ QString GitClient::synchronousTopic(const FilePath &workingDirectory) const
|
|||||||
// Detached HEAD, try a tag or remote branch
|
// Detached HEAD, try a tag or remote branch
|
||||||
QStringList references;
|
QStringList references;
|
||||||
if (!synchronousHeadRefs(workingDirectory, &references))
|
if (!synchronousHeadRefs(workingDirectory, &references))
|
||||||
return QString();
|
return {};
|
||||||
|
|
||||||
const QString tagStart("refs/tags/");
|
const QString tagStart("refs/tags/");
|
||||||
const QString remoteStart("refs/remotes/");
|
const QString remoteStart("refs/remotes/");
|
||||||
@@ -2262,7 +2262,7 @@ QString GitClient::commandInProgressDescription(const FilePath &workingDirectory
|
|||||||
case Merge:
|
case Merge:
|
||||||
return Tr::tr("MERGING");
|
return Tr::tr("MERGING");
|
||||||
}
|
}
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
GitClient::CommandInProgress GitClient::checkCommandInProgress(const FilePath &workingDirectory) const
|
GitClient::CommandInProgress GitClient::checkCommandInProgress(const FilePath &workingDirectory) const
|
||||||
|
|||||||
@@ -110,11 +110,11 @@ QString GitEditorWidget::changeUnderCursor(const QTextCursor &c) const
|
|||||||
// Any number is regarded as change number.
|
// Any number is regarded as change number.
|
||||||
cursor.select(QTextCursor::WordUnderCursor);
|
cursor.select(QTextCursor::WordUnderCursor);
|
||||||
if (!cursor.hasSelection())
|
if (!cursor.hasSelection())
|
||||||
return QString();
|
return {};
|
||||||
const QString change = cursor.selectedText();
|
const QString change = cursor.selectedText();
|
||||||
if (m_changeNumberPattern.match(change).hasMatch())
|
if (m_changeNumberPattern.match(change).hasMatch())
|
||||||
return change;
|
return change;
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseAnnotationHighlighter *GitEditorWidget::createAnnotationHighlighter(const QSet<QString> &changes) const
|
BaseAnnotationHighlighter *GitEditorWidget::createAnnotationHighlighter(const QSet<QString> &changes) const
|
||||||
@@ -317,7 +317,7 @@ QString GitEditorWidget::revisionSubject(const QTextBlock &inBlock) const
|
|||||||
return block.text().trimmed();
|
return block.text().trimmed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GitEditorWidget::supportChangeLinks() const
|
bool GitEditorWidget::supportChangeLinks() const
|
||||||
@@ -363,21 +363,21 @@ QWidget *GitEditorWidget::addFilterWidget()
|
|||||||
QString GitEditorWidget::grepValue() const
|
QString GitEditorWidget::grepValue() const
|
||||||
{
|
{
|
||||||
if (!m_logFilterWidget)
|
if (!m_logFilterWidget)
|
||||||
return QString();
|
return {};
|
||||||
return m_logFilterWidget->grepLineEdit->text();
|
return m_logFilterWidget->grepLineEdit->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GitEditorWidget::pickaxeValue() const
|
QString GitEditorWidget::pickaxeValue() const
|
||||||
{
|
{
|
||||||
if (!m_logFilterWidget)
|
if (!m_logFilterWidget)
|
||||||
return QString();
|
return {};
|
||||||
return m_logFilterWidget->pickaxeLineEdit->text();
|
return m_logFilterWidget->pickaxeLineEdit->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GitEditorWidget::authorValue() const
|
QString GitEditorWidget::authorValue() const
|
||||||
{
|
{
|
||||||
if (!m_logFilterWidget)
|
if (!m_logFilterWidget)
|
||||||
return QString();
|
return {};
|
||||||
return m_logFilterWidget->authorLineEdit->text();
|
return m_logFilterWidget->authorLineEdit->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ QString LogChangeWidget::commit() const
|
|||||||
{
|
{
|
||||||
if (const QStandardItem *sha1Item = currentItem(Sha1Column))
|
if (const QStandardItem *sha1Item = currentItem(Sha1Column))
|
||||||
return sha1Item->text();
|
return sha1Item->text();
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
int LogChangeWidget::commitIndex() const
|
int LogChangeWidget::commitIndex() const
|
||||||
@@ -113,7 +113,7 @@ QString LogChangeWidget::earliestCommit() const
|
|||||||
if (const QStandardItem *item = m_model->item(rows - 1, Sha1Column))
|
if (const QStandardItem *item = m_model->item(rows - 1, Sha1Column))
|
||||||
return item->text();
|
return item->text();
|
||||||
}
|
}
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogChangeWidget::setItemDelegate(QAbstractItemDelegate *delegate)
|
void LogChangeWidget::setItemDelegate(QAbstractItemDelegate *delegate)
|
||||||
@@ -269,7 +269,7 @@ int LogChangeDialog::commitIndex() const
|
|||||||
QString LogChangeDialog::resetFlag() const
|
QString LogChangeDialog::resetFlag() const
|
||||||
{
|
{
|
||||||
if (!m_resetTypeComboBox)
|
if (!m_resetTypeComboBox)
|
||||||
return QString();
|
return {};
|
||||||
return m_resetTypeComboBox->itemData(m_resetTypeComboBox->currentIndex()).toString();
|
return m_resetTypeComboBox->itemData(m_resetTypeComboBox->currentIndex()).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ QString MergeTool::mergeTypeName()
|
|||||||
case DeletedMerge: return Tr::tr("Deleted");
|
case DeletedMerge: return Tr::tr("Deleted");
|
||||||
case SymbolicLinkMerge: return Tr::tr("Symbolic link");
|
case SymbolicLinkMerge: return Tr::tr("Symbolic link");
|
||||||
}
|
}
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MergeTool::stateName(MergeTool::FileState state, const QString &extraInfo)
|
QString MergeTool::stateName(MergeTool::FileState state, const QString &extraInfo)
|
||||||
@@ -107,7 +107,7 @@ QString MergeTool::stateName(MergeTool::FileState state, const QString &extraInf
|
|||||||
case SymbolicLinkState: return Tr::tr("Symbolic link -> %1").arg(extraInfo);
|
case SymbolicLinkState: return Tr::tr("Symbolic link -> %1").arg(extraInfo);
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void MergeTool::chooseAction()
|
void MergeTool::chooseAction()
|
||||||
|
|||||||
@@ -112,14 +112,13 @@ QVariant RemoteModel::data(const QModelIndex &index, int role) const
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return QVariant();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant RemoteModel::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant RemoteModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
if (role != Qt::DisplayRole || orientation != Qt::Horizontal)
|
if (role != Qt::DisplayRole || orientation != Qt::Horizontal)
|
||||||
return QVariant();
|
return {};
|
||||||
|
|
||||||
return (section == 0) ? Tr::tr("Name") : Tr::tr("URL");
|
return (section == 0) ? Tr::tr("Name") : Tr::tr("URL");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -234,14 +234,14 @@ static inline QString nextStash(const QString &stash)
|
|||||||
{
|
{
|
||||||
const int openingBracePos = stash.indexOf('{');
|
const int openingBracePos = stash.indexOf('{');
|
||||||
if (openingBracePos == -1)
|
if (openingBracePos == -1)
|
||||||
return QString();
|
return {};
|
||||||
const int closingBracePos = stash.indexOf('}', openingBracePos + 2);
|
const int closingBracePos = stash.indexOf('}', openingBracePos + 2);
|
||||||
if (closingBracePos == -1)
|
if (closingBracePos == -1)
|
||||||
return QString();
|
return {};
|
||||||
bool ok;
|
bool ok;
|
||||||
const int n = stash.mid(openingBracePos + 1, closingBracePos - openingBracePos - 1).toInt(&ok);
|
const int n = stash.mid(openingBracePos + 1, closingBracePos - openingBracePos - 1).toInt(&ok);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
return QString();
|
return {};
|
||||||
QString rc = stash.left(openingBracePos + 1);
|
QString rc = stash.left(openingBracePos + 1);
|
||||||
rc += QString::number(n + 1);
|
rc += QString::number(n + 1);
|
||||||
rc += '}';
|
rc += '}';
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ QString Query::toString() const
|
|||||||
QString query = API_PREFIX;
|
QString query = API_PREFIX;
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
case Query::NoQuery:
|
case Query::NoQuery:
|
||||||
return QString();
|
return {};
|
||||||
case Query::Project:
|
case Query::Project:
|
||||||
QTC_ASSERT(!m_parameter.isEmpty(), return {});
|
QTC_ASSERT(!m_parameter.isEmpty(), return {});
|
||||||
query += QLatin1String(QUERY_PROJECT).arg(QLatin1String(
|
query += QLatin1String(QUERY_PROJECT).arg(QLatin1String(
|
||||||
|
|||||||
Reference in New Issue
Block a user