GitPlugin: Avoid using sender()

Change-Id: Ie711630dd4b92bdc69990f421f69b578bc0fe9dc
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Jarek Kobus
2022-07-21 22:37:49 +02:00
parent 82e25998a7
commit f794bb0acf
3 changed files with 37 additions and 76 deletions

View File

@@ -3124,7 +3124,7 @@ GitClient::RevertResult GitClient::revertI(QStringList files,
return RevertOk; return RevertOk;
} }
void GitClient::revert(const QStringList &files, bool revertStaging) void GitClient::revertFiles(const QStringList &files, bool revertStaging)
{ {
bool isDirectory; bool isDirectory;
QString errorMessage; QString errorMessage;

View File

@@ -298,7 +298,7 @@ public:
void subversionDeltaCommit(const Utils::FilePath &workingDirectory) const; void subversionDeltaCommit(const Utils::FilePath &workingDirectory) const;
void stashPop(const Utils::FilePath &workingDirectory, const QString &stash = {}); void stashPop(const Utils::FilePath &workingDirectory, const QString &stash = {});
void revert(const QStringList &files, bool revertStaging); void revertFiles(const QStringList &files, bool revertStaging);
bool synchronousStashList(const Utils::FilePath &workingDirectory, QList<Stash> *stashes, bool synchronousStashList(const Utils::FilePath &workingDirectory, QList<Stash> *stashes,
QString *errorMessage = nullptr) const; QString *errorMessage = nullptr) const;
// Resolve a stash name from message (for IVersionControl's names). // Resolve a stash name from message (for IVersionControl's names).

View File

@@ -332,7 +332,6 @@ public:
void pull(); void pull();
void push(); void push();
void startMergeTool(); void startMergeTool();
void continueOrAbortCommand();
void updateContinueAndAbortCommands(); void updateContinueAndAbortCommands();
void delayedPushToGerrit(); void delayedPushToGerrit();
@@ -615,8 +614,7 @@ QAction *GitPluginPrivate::createChangeRelatedRepositoryAction(const QString &te
const Context &context) const Context &context)
{ {
return createRepositoryAction(nullptr, text, id, context, true, return createRepositoryAction(nullptr, text, id, context, true,
std::bind(&GitPluginPrivate::startChangeRelatedAction, this, id), std::bind(&GitPluginPrivate::startChangeRelatedAction, this, id));
QKeySequence());
} }
// Action to act on the repository forwarded to a git client member function // Action to act on the repository forwarded to a git client member function
@@ -795,54 +793,45 @@ GitPluginPrivate::GitPluginPrivate()
= createRepositoryAction(localRepositoryMenu, = createRepositoryAction(localRepositoryMenu,
tr("Update Submodules"), "Git.SubmoduleUpdate", tr("Update Submodules"), "Git.SubmoduleUpdate",
context, true, std::bind(&GitPluginPrivate::updateSubmodules, this)); context, true, std::bind(&GitPluginPrivate::updateSubmodules, this));
m_abortMergeAction
= createRepositoryAction(localRepositoryMenu,
tr("Abort Merge", "Avoid translating \"Merge\""),
"Git.MergeAbort", context, true,
std::bind(&GitPluginPrivate::continueOrAbortCommand, this));
m_abortRebaseAction auto createAction = [=](const QString &text, Id id,
= createRepositoryAction(localRepositoryMenu, const std::function<void(const FilePath &)> &callback) {
tr("Abort Rebase", "Avoid translating \"Rebase\""), auto actionHandler = [this, callback] {
"Git.RebaseAbort", context, true, if (!DocumentManager::saveAllModifiedDocuments())
std::bind(&GitPluginPrivate::continueOrAbortCommand, this)); return;
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
m_abortCherryPickAction callback(state.topLevel());
= createRepositoryAction(localRepositoryMenu,
tr("Abort Cherry Pick", "Avoid translating \"Cherry Pick\""),
"Git.CherryPickAbort",
context, true,
std::bind(&GitPluginPrivate::continueOrAbortCommand, this));
m_abortRevertAction updateContinueAndAbortCommands();
= createRepositoryAction(localRepositoryMenu, };
tr("Abort Revert", "Avoid translating \"Revert\""), "Git.RevertAbort", return createRepositoryAction(localRepositoryMenu, text, id, context, true, actionHandler);
context, true, };
std::bind(&GitPluginPrivate::continueOrAbortCommand, this));
m_continueRebaseAction m_abortMergeAction = createAction(tr("Abort Merge", "Avoid translating \"Merge\""), "Git.MergeAbort",
= createRepositoryAction(localRepositoryMenu, std::bind(&GitClient::synchronousMerge, &m_gitClient, _1, QString("--abort"), true));
tr("Continue Rebase"), "Git.RebaseContinue",
context, true,
std::bind(&GitPluginPrivate::continueOrAbortCommand, this));
m_skipRebaseAction m_abortRebaseAction = createAction(tr("Abort Rebase", "Avoid translating \"Rebase\""), "Git.RebaseAbort",
= createRepositoryAction(localRepositoryMenu, std::bind(&GitClient::rebase, &m_gitClient, _1, QString("--abort")));
tr("Skip Rebase"), "Git.RebaseSkip",
context, true,
std::bind(&GitPluginPrivate::continueOrAbortCommand, this));
m_continueCherryPickAction m_continueRebaseAction = createAction(tr("Continue Rebase"), "Git.RebaseContinue",
= createRepositoryAction(localRepositoryMenu, std::bind(&GitClient::rebase, &m_gitClient, _1, QString("--continue")));
tr("Continue Cherry Pick"), "Git.CherryPickContinue",
context, true,
std::bind(&GitPluginPrivate::continueOrAbortCommand, this));
m_continueRevertAction m_skipRebaseAction = createAction(tr("Skip Rebase"), "Git.RebaseSkip",
= createRepositoryAction(localRepositoryMenu, std::bind(&GitClient::rebase, &m_gitClient, _1, QString("--skip")));
tr("Continue Revert"), "Git.RevertContinue",
context, true, m_abortCherryPickAction = createAction(tr("Abort Cherry Pick", "Avoid translating \"Cherry Pick\""), "Git.CherryPickAbort",
std::bind(&GitPluginPrivate::continueOrAbortCommand, this)); std::bind(&GitClient::synchronousCherryPick, &m_gitClient, _1, QString("--abort")));
m_continueCherryPickAction = createAction(tr("Continue Cherry Pick"), "Git.CherryPickContinue",
std::bind(&GitClient::cherryPick, &m_gitClient, _1, QString("--continue")));
m_abortRevertAction = createAction(tr("Abort Revert", "Avoid translating \"Revert\""), "Git.RevertAbort",
std::bind(&GitClient::synchronousRevert, &m_gitClient, _1, QString("--abort")));
m_continueRevertAction = createAction(tr("Continue Revert"), "Git.RevertContinue",
std::bind(&GitClient::revert, &m_gitClient, _1, QString("--continue")));
// -------------- // --------------
localRepositoryMenu->addSeparator(context); localRepositoryMenu->addSeparator(context);
@@ -1125,7 +1114,7 @@ void GitPluginPrivate::undoFileChanges(bool revertStaging)
const VcsBasePluginState state = currentState(); const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return); QTC_ASSERT(state.hasFile(), return);
FileChangeBlocker fcb(Utils::FilePath::fromString(state.currentFile())); FileChangeBlocker fcb(Utils::FilePath::fromString(state.currentFile()));
m_gitClient.revert({state.currentFile()}, revertStaging); m_gitClient.revertFiles({state.currentFile()}, revertStaging);
} }
class ResetItemDelegate : public LogItemDelegate class ResetItemDelegate : public LogItemDelegate
@@ -1526,34 +1515,6 @@ void GitPluginPrivate::startMergeTool()
m_gitClient.merge(state.topLevel()); m_gitClient.merge(state.topLevel());
} }
void GitPluginPrivate::continueOrAbortCommand()
{
if (!DocumentManager::saveAllModifiedDocuments())
return;
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
QObject *action = QObject::sender();
if (action == m_abortMergeAction)
m_gitClient.synchronousMerge(state.topLevel(), "--abort");
else if (action == m_abortRebaseAction)
m_gitClient.rebase(state.topLevel(), "--abort");
else if (action == m_abortCherryPickAction)
m_gitClient.synchronousCherryPick(state.topLevel(), "--abort");
else if (action == m_abortRevertAction)
m_gitClient.synchronousRevert(state.topLevel(), "--abort");
else if (action == m_skipRebaseAction)
m_gitClient.rebase(state.topLevel(), "--skip");
else if (action == m_continueRebaseAction)
m_gitClient.rebase(state.topLevel(), "--continue");
else if (action == m_continueCherryPickAction)
m_gitClient.cherryPick(state.topLevel(), "--continue");
else if (action == m_continueRevertAction)
m_gitClient.revert(state.topLevel(), "--continue");
updateContinueAndAbortCommands();
}
void GitPluginPrivate::cleanProject() void GitPluginPrivate::cleanProject()
{ {
const VcsBasePluginState state = currentState(); const VcsBasePluginState state = currentState();