File indexing completed on 2025-01-05 05:14:49
0001 /* 0002 SPDX-FileCopyrightText: 2021 Hamed Masafi <hamed.masfi@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #include "mergedialog.h" 0008 0009 #include "commands/commandmerge.h" 0010 #include "gitmanager.h" 0011 #include "models/branchesmodel.h" 0012 0013 void MergeDialog::init(Git::Manager *git) 0014 { 0015 comboBoxBranchName->setModel(git->branchesModel()); 0016 labelToBranchName->setText(git->currentBranch()); 0017 0018 checkBoxAllowUnrelatedHistories->setCheckState(Qt::PartiallyChecked); 0019 checkBoxSquash->setCheckState(Qt::PartiallyChecked); 0020 0021 stackedWidget->setCurrentWidget(pageEmpty); 0022 0023 initComboBox<Git::CommandMerge::Strategy>(comboBoxStrategy); 0024 initComboBox<Git::CommandMerge::DiffAlgorithm>(comboBoxDiffAlgoritm); 0025 0026 connect(comboBoxStrategy, &QComboBox::currentIndexChanged, this, &MergeDialog::slotComboBoxStrategyCurrentIndexChanged); 0027 } 0028 0029 MergeDialog::MergeDialog(Git::Manager *git, QWidget *parent) 0030 : AppDialog(git, parent) 0031 { 0032 setupUi(this); 0033 0034 init(git); 0035 } 0036 0037 MergeDialog::MergeDialog(Git::Manager *git, const QString &sourceBranch, QWidget *parent) 0038 : AppDialog(git, parent) 0039 , mSourceBranch(sourceBranch) 0040 { 0041 setupUi(this); 0042 0043 init(git); 0044 0045 comboBoxBranchName->setCurrentText(sourceBranch); 0046 } 0047 0048 Git::CommandMerge *MergeDialog::command() const 0049 { 0050 auto cmd = new Git::CommandMerge(mGit); 0051 0052 cmd->setAllowUnrelatedHistories(Git::checkStateToOptionalBool(checkBoxAllowUnrelatedHistories->checkState())); 0053 cmd->setSquash(Git::checkStateToOptionalBool(checkBoxSquash->checkState())); 0054 0055 switch (comboBoxFastForward->currentIndex()) { 0056 case 0: 0057 cmd->setFf(Git::FastForwardType::Unset); 0058 break; 0059 case 1: 0060 cmd->setFf(Git::FastForwardType::Yes); 0061 break; 0062 case 2: 0063 cmd->setFf(Git::FastForwardType::OnlyFastForward); 0064 break; 0065 case 3: 0066 cmd->setFf(Git::FastForwardType::No); 0067 break; 0068 } 0069 cmd->setStrategy(comboBoxCurrentValue<Git::CommandMerge::Strategy>(comboBoxStrategy)); 0070 cmd->setIgnoreAllSpace(checkBoxIgnoreAllSpace->isChecked()); 0071 cmd->setIgnoreSpaceAtEol(checkBoxIgnoreSpaceAtEol->isChecked()); 0072 cmd->setIgnoreSpaceChange(checkBoxIgnoreSpaceChanges->isChecked()); 0073 cmd->setIgnoreCrAtEol(checkBoxIgnoreCrAtEol->isChecked()); 0074 cmd->setRenormalize(checkBoxRenormalize->isChecked()); 0075 0076 cmd->setOurs(radioButtonOurs->isChecked()); 0077 cmd->setTheirs(radioButtonTheirs->isChecked()); 0078 cmd->setFromBranch(comboBoxBranchName->currentText()); 0079 cmd->setNoRenames(checkBoxNoRenames->isChecked()); 0080 cmd->setDiffAlgorithm(comboBoxCurrentValue<Git::CommandMerge::DiffAlgorithm>(comboBoxDiffAlgoritm)); 0081 0082 return cmd; 0083 } 0084 0085 void MergeDialog::slotComboBoxStrategyCurrentIndexChanged(int index) 0086 { 0087 Q_UNUSED(index) 0088 0089 auto strategy = comboBoxCurrentValue<Git::CommandMerge::Strategy>(comboBoxStrategy); 0090 0091 switch (strategy) { 0092 case Git::CommandMerge::Ort: 0093 stackedWidget->setCurrentWidget(pageStrategyOrt); 0094 break; 0095 case Git::CommandMerge::Recursive: 0096 stackedWidget->setCurrentWidget(pageStrategyRecursive); 0097 break; 0098 default: 0099 stackedWidget->setCurrentWidget(pageEmpty); 0100 break; 0101 } 0102 } 0103 0104 #include "moc_mergedialog.cpp"