VcsPlugin: Simplify return statements

Change-Id: Icdf580fb1ca6860a82f3594e4676fb450b55d174
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2023-08-02 11:45:36 +02:00
parent 224e4eeb59
commit 88926ed1a8
8 changed files with 14 additions and 16 deletions

View File

@@ -215,7 +215,7 @@ QString NickNameDialog::nickName() const
if (const QStandardItem *item = m_model->itemFromIndex(sourceIndex))
return NickNameEntry::nickNameOf(item);
}
return QString();
return {};
}
QStandardItemModel *NickNameDialog::createModel(QObject *parent)

View File

@@ -121,14 +121,14 @@ QList<QStandardItem *> SubmitFileModel::addFile(const QString &fileName, const Q
QString SubmitFileModel::state(int row) const
{
if (row < 0 || row >= rowCount())
return QString();
return {};
return item(row)->text();
}
QString SubmitFileModel::file(int row) const
{
if (row < 0 || row >= rowCount())
return QString();
return {};
return item(row, FileColumn)->text();
}

View File

@@ -515,7 +515,7 @@ QString VcsBaseClient::vcsCommandString(VcsCommandTag cmd) const
case LogCommand: return QLatin1String("log");
case StatusCommand: return QLatin1String("status");
}
return QString();
return {};
}
ExitCodeInterpreter VcsBaseClient::exitCodeInterpreter(VcsCommandTag cmd) const

View File

@@ -1554,7 +1554,7 @@ bool VcsBaseEditorWidget::isValidRevision(const QString &revision) const
QString VcsBaseEditorWidget::revisionSubject(const QTextBlock &inBlock) const
{
Q_UNUSED(inBlock)
return QString();
return {};
}
bool VcsBaseEditorWidget::hasDiff() const

View File

@@ -220,7 +220,7 @@ QString StateListener::windowTitleVcsTopic(const FilePath &filePath)
searchPath = projects.first()->projectDirectory();
}
if (searchPath.isEmpty())
return QString();
return {};
FilePath topLevelPath;
IVersionControl *vc = VcsManager::findVersionControlForDirectory(
searchPath, &topLevelPath);
@@ -232,7 +232,7 @@ static inline QString displayNameOfEditor(const FilePath &fileName)
IDocument *document = DocumentModel::documentForFilePath(fileName);
if (document)
return document->displayName();
return QString();
return {};
}
void StateListener::slotStateChanged()

View File

@@ -487,7 +487,7 @@ QString VcsBaseSubmitEditor::promptForNickName()
d->m_nickNameDialog = new NickNameDialog(VcsPlugin::instance()->nickNameModel(), d->m_widget);
if (d->m_nickNameDialog->exec() == QDialog::Accepted)
return d->m_nickNameDialog->nickName();
return QString();
return {};
}
void VcsBaseSubmitEditor::slotInsertNickName()

View File

@@ -123,13 +123,13 @@ QString OutputWindowPlainTextEdit::identifierUnderCursor(const QPoint &widgetPos
const int cursorDocumentPos = cursor.position();
cursor.select(QTextCursor::BlockUnderCursor);
if (!cursor.hasSelection())
return QString();
return {};
const QString block = cursor.selectedText();
// Determine cursor position within line and find blank-delimited word
const int cursorPos = cursorDocumentPos - cursor.block().position();
const int blockSize = block.size();
if (cursorPos < 0 || cursorPos >= blockSize || block.at(cursorPos).isSpace())
return QString();
return {};
// Retrieve repository if desired
if (repository)
if (QTextBlockUserData *data = cursor.block().userData())

View File

@@ -107,8 +107,7 @@ void VcsPlugin::initialize()
MacroExpander *expander = globalMacroExpander();
expander->registerVariable(Constants::VAR_VCS_NAME,
Tr::tr("Name of the version control system in use by the current project."),
[]() -> QString {
Tr::tr("Name of the version control system in use by the current project."), [] {
IVersionControl *vc = nullptr;
if (Project *project = ProjectTree::currentProject())
vc = VcsManager::findVersionControlForDirectory(project->projectDirectory());
@@ -116,8 +115,8 @@ void VcsPlugin::initialize()
});
expander->registerVariable(Constants::VAR_VCS_TOPIC,
Tr::tr("The current version control topic (branch or tag) identification of the current project."),
[]() -> QString {
Tr::tr("The current version control topic (branch or tag) identification "
"of the current project."), [] {
IVersionControl *vc = nullptr;
FilePath topLevel;
if (Project *project = ProjectTree::currentProject())
@@ -126,8 +125,7 @@ void VcsPlugin::initialize()
});
expander->registerVariable(Constants::VAR_VCS_TOPLEVELPATH,
Tr::tr("The top level path to the repository the current project is in."),
[]() -> QString {
Tr::tr("The top level path to the repository the current project is in."), [] {
if (Project *project = ProjectTree::currentProject())
return VcsManager::findTopLevelForDirectory(project->projectDirectory()).toString();
return QString();