-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqgitpulldialog.cpp
More file actions
109 lines (85 loc) · 2.32 KB
/
qgitpulldialog.cpp
File metadata and controls
109 lines (85 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include "qgitpulldialog.h"
#include "ui_qgitpulldialog.h"
#include "qgitrepository.h"
#include "qgit.h"
#include <QStandardItemModel>
#include <QDialog>
QGitPullDialog::QGitPullDialog(QGitRepository *parent)
: QDialog(parent)
, ui(new Ui::QGitPullDialog)
{
ui->setupUi(this);
QGit *git = static_cast<QGitRepository *>(parent)->git();
auto remotes = git->remotes();
for(const auto &remote: std::as_const(remotes))
{
const auto name = remote.name;
const auto url = remote.url;
ui->remote_comboBox->addItem(name, url);
}
ui->remote_comboBox->addItem(tr("custom"));
auto branches = git->branches(GIT_BRANCH_LOCAL);
auto currentBranch = git->currentBranch();
auto branch_comboBox_model = static_cast<QStandardItemModel *>(ui->branch_comboBox->model());
for(const auto &branch: std::as_const(branches))
{
QStandardItem *item = new QStandardItem(branch.name());
if (branch.name() == currentBranch)
{
auto font = item->font();
font.setBold(true);
item->setFont(font);
}
branch_comboBox_model->appendRow(item);
}
ui->branch_comboBox->setCurrentText(currentBranch);
}
QGitPullDialog::~QGitPullDialog()
{
delete ui;
}
QGitRemote QGitPullDialog::remote() const
{
QGitRemote ret;
ret.name = ui->remote_comboBox->currentText();
ret.url = ui->url_lineEdit->text();
return ret;
}
QString QGitPullDialog::branch() const
{
return ui->branch_comboBox->currentText();
}
bool QGitPullDialog::commitMergedChanges() const
{
return ui->commit_merged_checkBox->isChecked();
}
bool QGitPullDialog::includeMessages() const
{
return ui->include_messages_checkBox->isChecked();
}
bool QGitPullDialog::createNewCommit() const
{
return ui->create_new_commit_checkBox->isChecked();
}
bool QGitPullDialog::rebase() const
{
return ui->rebase_checkBox->isChecked();
}
void QGitPullDialog::on_remote_comboBox_currentIndexChanged(int index)
{
QString url;
if (index >= 0)
{
url = ui->remote_comboBox->itemData(index).toString();
ui->url_lineEdit->setText(url);
}
if (!url.isEmpty())
{
ui->url_lineEdit->setEnabled(false);
}
else
{
ui->url_lineEdit->setEnabled(true);
ui->url_lineEdit->setFocus();
}
}