Git: Move addChangeActions from GitEditor to GitClient

Change-Id: Id901994ac2909b00ca58a0a8a91d2d3a273c39b3
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Orgad Shaneh
2020-02-25 20:20:43 +02:00
committed by Orgad Shaneh
parent 7c4f0a9b1e
commit b52ffa2501
4 changed files with 53 additions and 51 deletions

View File

@@ -308,59 +308,10 @@ bool GitEditorWidget::isValidRevision(const QString &revision) const
return GitClient::instance()->isValidRevision(revision);
}
void GitEditorWidget::addChangeActions(QMenu *menu, const QString &change, const QString &workingDir)
{
menu->addAction(tr("Cherr&y-Pick Change %1").arg(change), [workingDir, change] {
GitClient::instance()->synchronousCherryPick(workingDir, change);
});
menu->addAction(tr("Re&vert Change %1").arg(change), [workingDir, change] {
GitClient::instance()->synchronousRevert(workingDir, change);
});
menu->addAction(tr("C&heckout Change %1").arg(change), [workingDir, change] {
GitClient::instance()->checkout(workingDir, change);
});
connect(menu->addAction(tr("&Interactive Rebase from Change %1...").arg(change)),
&QAction::triggered, [workingDir, change] {
GitPlugin::startRebaseFromCommit(workingDir, change);
});
menu->addAction(tr("&Log for Change %1").arg(change), [workingDir, change] {
GitClient::instance()->log(workingDir, QString(), false, {change});
});
menu->addAction(tr("Add &Tag for Change %1...").arg(change), [workingDir, change] {
QString output;
QString errorMessage;
GitClient::instance()->synchronousTagCmd(workingDir, QStringList(),
&output, &errorMessage);
const QStringList tags = output.split('\n');
BranchAddDialog dialog(tags, BranchAddDialog::Type::AddTag, Core::ICore::dialogParent());
if (dialog.exec() == QDialog::Rejected)
return;
GitClient::instance()->synchronousTagCmd(workingDir,
{dialog.branchName(), change},
&output, &errorMessage);
VcsOutputWindow::append(output);
if (!errorMessage.isEmpty())
VcsOutputWindow::append(errorMessage, VcsOutputWindow::MessageStyle::Error);
});
auto resetChange = [workingDir, change](const QByteArray &resetType) {
GitClient::instance()->reset(
workingDir, QLatin1String("--" + resetType), change);
};
auto resetMenu = new QMenu(tr("&Reset to Change %1").arg(change), menu);
resetMenu->addAction(tr("&Hard"), std::bind(resetChange, "hard"));
resetMenu->addAction(tr("&Mixed"), std::bind(resetChange, "mixed"));
resetMenu->addAction(tr("&Soft"), std::bind(resetChange, "soft"));
menu->addMenu(resetMenu);
}
void GitEditorWidget::addChangeActions(QMenu *menu, const QString &change)
{
if (contentType() != OtherContent)
addChangeActions(menu, change, sourceWorkingDirectory());
GitClient::addChangeActions(menu, change, sourceWorkingDirectory());
}
QString GitEditorWidget::revisionSubject(const QTextBlock &inBlock) const