-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrepoeditorview.cpp
85 lines (70 loc) · 2.59 KB
/
repoeditorview.cpp
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
#include "repoeditorview.h"
#include "ui_repoeditorview.h"
repoeditorview::repoeditorview(QString repo, int id, QWidget *parent) :
QDialog(parent),
ui(new Ui::repoeditorview)
{
ui->setupUi(this);
this->repository=repo;
this->id=id;
QFileInfo infoFile;
infoFile=QFileInfo(repository+"/replink.xml");
if(infoFile.exists()){
CXMLRepo repo = xmlM->XMLRepoInfo(repository+"/replink.xml");
if(repo.ObtenerName()!=""){
QPixmap repoPix;
repoPix.load(repository+"/icons/"+repo.ObtenerIcon());
repoIcon.addPixmap(repoPix);
ui->lIcon->setPixmap(repoIcon.pixmap(ui->lIcon->size()));
ui->lineEdit->setText(repository);
ui->eName->setText(repo.ObtenerName());
QString protocol= repo.ObtenerUrl().split("://").at(0);
for (int k = 0; k < ui->comboBox->count(); ++k) {
if(ui->comboBox->itemText(k)==protocol+"://"){
ui->comboBox->setCurrentIndex(k);
break;
}
}
ui->eBackup->setText(DatAccess().SelectRepoFromId(id).ObtenerPorPos(1).ObtenerBackUpDir());
ui->eUrl->setText(repo.ObtenerUrl().split("://").at(1));
ui->tDesc->setPlainText(repo.ObtenerDescription());
}else{
QMessageBox::warning(this, "Error", "There was a problem with the repo config files.");
this->hide();
}
}
}
repoeditorview::~repoeditorview()
{
delete ui;
}
void repoeditorview::on_buttonBox_accepted()
{
QFileInfo infoFile;
infoFile=QFileInfo(ui->lineEdit->text()+"/replink.xml");
if(infoFile.exists()){
RepoInfo repo=RepoInfo(id, ui->eName->text(), ui->lineEdit->text(), ui->comboBox->currentText()+ui->eUrl->text().replace("http://","").replace("https://","").replace("ftp://","").replace("://",""), ui->eBackup->text());
repo.SetDescription(ui->tDesc->toPlainText());
xmlM->UpdateRepoInfo(ui->lineEdit->text()+"/replink.xml",repo);
bool result = bd.UpdateRepoInfo(repo);
if(result){
emit finished(0);
}
}
}
void repoeditorview::on_pushButton_2_clicked()
{
catE = new CatEditor(ui->lineEdit->text());
catE->show();
}
void repoeditorview::on_bBackupDir_clicked()
{
QFileDialog abrir;
QString direc= abrir.getExistingDirectory(this, tr("Abrir Ruta"), ui->eBackup->text());
QDir d(direc);
if(d.exists()){
ui->eBackup->setText(QString(d.absolutePath()).replace("\\","/"));
}else{
QMessageBox::warning(this,"Error", "This directory it's not correct. ");
}
}