1#include "gitmergedialog.h"
2#include "ui_gitmergedialog.h"
3#include "gitmanager.h"
4#include "../widgets/infomessagebox.h"
5
6GitMergeDialog::GitMergeDialog(const QString& folder, QWidget *parent) :
7 QDialog(parent),
8 ui(new Ui::GitMergeDialog)
9{
10 ui->setupUi(this);
11 mManager = new GitManager();
12 mCurrentBranchIndex=-1;
13 QStringList branches =mManager->listBranches(mFolder,mCurrentBranchIndex);
14 ui->cbBranch->addItems(branches);
15 ui->cbBranch->setCurrentIndex(mCurrentBranchIndex);
16 ui->btnOk->setEnabled(false);
17 ui->rbBranch->setChecked(true);
18 ui->txtMergeMessage->setPlainText(QObject::tr("<Auto Generated by Git>"));
19 mFolder = mManager->rootFolder(folder);
20 if (branches.isEmpty()) {
21 QString currentBranch;
22 if (mManager->hasRepository(folder,currentBranch)) {
23 ui->cbBranch->addItem(currentBranch);
24 ui->btnOk->setEnabled(false);
25 }
26 ui->grpOptions->setEnabled(false);
27 ui->txtMergeMessage->setEnabled(false);
28 }
29}
30
31GitMergeDialog::~GitMergeDialog()
32{
33 delete mManager;
34 delete ui;
35}
36
37void GitMergeDialog::on_btnCancel_clicked()
38{
39 reject();
40}
41
42void GitMergeDialog::closeEvent(QCloseEvent */* event */)
43{
44 reject();
45}
46
47
48void GitMergeDialog::on_btnOk_clicked()
49{
50 QString output;
51 if (mManager->merge(mFolder,ui->cbBranch->currentText(),
52 ui->chkSquash->isChecked(),
53 ui->chkFastForwardOnly->isChecked(),
54 ui->chkNoFastFoward->isChecked(),
55 ui->chkNoCommit->isChecked(),
56 output,
57 ui->txtMergeMessage->toPlainText()
58 )) {
59 InfoMessageBox box;
60 box.setMessage(output);
61 box.exec();
62 accept();
63 } else {
64 InfoMessageBox box;
65 box.setMessage(output);
66 box.exec();
67 reject();
68 }
69}
70
71
72void GitMergeDialog::on_cbBranch_currentIndexChanged(int index)
73{
74 ui->btnOk->setEnabled(mCurrentBranchIndex!=index);
75}
76
77