-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqgitclonerepositorydialog.cpp
More file actions
106 lines (82 loc) · 3 KB
/
qgitclonerepositorydialog.cpp
File metadata and controls
106 lines (82 loc) · 3 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
#include "qgitclonerepositorydialog.h"
#include "ui_qgitclonerepositorydialog.h"
#include <QShowEvent>
QGitCloneRepositoryDialog::QGitCloneRepositoryDialog(const QString &url, const QString &path, QWidget *parent)
: QDialog(parent)
, ui(new Ui::QGitCloneRepositoryDialog)
, m_url(url)
, m_path(path)
, m_git(new QGit())
{
ui->setupUi(this);
ui->label->setText(tr("Cloning <a href=\"%1\">%1</a> into <b>%2</b>").arg(url, path));
m_git->moveToThread(&m_thread);
connect(this, &QGitCloneRepositoryDialog::clone, m_git, &QGit::clone);
connect(m_git, &QGit::cloneReply, this, &QGitCloneRepositoryDialog::cloneReply);
connect(m_git, &QGit::cloneTransferReply, this, &QGitCloneRepositoryDialog::cloneTransferReply);
connect(m_git, &QGit::cloneProgressReply, this, &QGitCloneRepositoryDialog::cloneProgressReply);
m_git->setPath(m_path);
m_thread.setObjectName("QGit(clone)");
m_thread.start();
}
QGitCloneRepositoryDialog::~QGitCloneRepositoryDialog()
{
m_thread.quit();
m_thread.wait();
delete m_git; m_git = nullptr;
delete ui;
}
void QGitCloneRepositoryDialog::showEvent(QShowEvent *event)
{
if (event->type() == QEvent::Show)
{
emit clone(m_url);
}
}
void QGitCloneRepositoryDialog::on_pushButton_close_clicked()
{
if (ui->pushButton_close->text() == tr("&Close"))
{
accept();
}
else
{
ui->pushButton_close->setText(tr("&Aborting"));
ui->pushButton_close->setEnabled(false);
m_thread.requestInterruption();
}
}
void QGitCloneRepositoryDialog::cloneReply(QGitError error)
{
Q_UNUSED(error)
if (m_thread.isRunning())
{
reject();
return;
}
ui->pushButton_close->setText(tr("&Close"));
ui->pushButton_close->setEnabled(true);
}
void QGitCloneRepositoryDialog::cloneTransferReply(unsigned int total_objects, unsigned int indexed_objects, unsigned int received_objects, unsigned int local_objects, unsigned int total_deltas, unsigned int indexed_deltas, size_t received_bytes)
{
Q_UNUSED(local_objects)
if (total_objects > 0)
{
ui->progressBar_recievingObjects->setMaximum(static_cast<int>(total_objects));
ui->progressBar_recievingObjects->setValue(static_cast<int>(received_objects));
ui->progressBar_recievingIndexes->setMaximum(static_cast<int>(total_objects));
ui->progressBar_recievingIndexes->setValue(static_cast<int>(indexed_objects));
}
if (total_deltas > 0)
{
ui->progressBar_indexingDeltas->setMaximum(static_cast<int>(total_deltas));
ui->progressBar_indexingDeltas->setValue(static_cast<int>(indexed_deltas));
}
ui->label_status->setText(tr("Recieved %1 bytes.").arg(received_bytes));
}
void QGitCloneRepositoryDialog::cloneProgressReply(QString path, size_t completed_steps, size_t total_steps)
{
Q_UNUSED(path)
ui->progressBar_creatingFiles->setMaximum(static_cast<int>(total_steps));
ui->progressBar_creatingFiles->setValue(static_cast<int>(completed_steps));
}