[239e1ea] | 1 | /* |
---|
| 2 | realizado por José Ruiz en Mayo de 2015 |
---|
| 3 | */ |
---|
[44d1e60] | 4 | #include "formloadmatrix.H" |
---|
[9dd61b1] | 5 | #include "ui_formLoadMatrix.h" |
---|
[44d1e60] | 6 | |
---|
| 7 | void FormLoadMatrix::closeEvent(QCloseEvent *) |
---|
| 8 | { |
---|
| 9 | emit formClosed(); |
---|
| 10 | } |
---|
| 11 | |
---|
| 12 | FormLoadMatrix::FormLoadMatrix(QWidget * parent) |
---|
[e62517a] | 13 | : QWidget(parent, Qt::Tool), |
---|
| 14 | ui(new Ui::FormLoadMatrix) |
---|
[44d1e60] | 15 | { |
---|
[e62517a] | 16 | ui->setupUi(this); |
---|
[44d1e60] | 17 | int x = parent->pos().x() + parent->width()/2 - this->width()/2; |
---|
| 18 | int y = parent->pos().y() + parent->height()/2 - this->height()/2; |
---|
| 19 | this->move(x, y); |
---|
| 20 | |
---|
[e62517a] | 21 | connect(ui->buttonSearch, SIGNAL(clicked()),this,SLOT(slotLoadMatrixFile())); |
---|
| 22 | connect(ui->buttonCancel, SIGNAL(clicked()),this,SLOT(close())); |
---|
| 23 | connect(ui->buttonOpen, SIGNAL(clicked()), this, |
---|
[44d1e60] | 24 | SLOT(slotButtonAcceptClicked())); |
---|
| 25 | |
---|
| 26 | } |
---|
[9dd61b1] | 27 | |
---|
[44d1e60] | 28 | void FormLoadMatrix::slotLoadMatrixFile() { |
---|
| 29 | QString filename = QFileDialog::getOpenFileName(this, |
---|
| 30 | "Seleccione archivo de Matriz", QDir::homePath(),"*.csv"); |
---|
| 31 | |
---|
| 32 | if(filename.isEmpty()) return; |
---|
[e62517a] | 33 | ui->editFilePath->setText(filename); |
---|
[44d1e60] | 34 | } |
---|
| 35 | |
---|
| 36 | void FormLoadMatrix::slotButtonAcceptClicked() |
---|
| 37 | { |
---|
[e62517a] | 38 | if (ui->editFilePath->text().isEmpty()) |
---|
[44d1e60] | 39 | { |
---|
| 40 | QMessageBox::critical(this, "Faltan datos", |
---|
| 41 | "Debe seleccionar un archivo"); |
---|
| 42 | |
---|
[e62517a] | 43 | ui->editFilePath->setFocus(); |
---|
[44d1e60] | 44 | return; |
---|
| 45 | } |
---|
[e62517a] | 46 | else if(!ui->radioAccount->isChecked() and !ui->radioComponent->isChecked()){ |
---|
[588814f] | 47 | QMessageBox::critical(this, "Faltan datos", |
---|
| 48 | "Debe seleccionar si cargará cuentas y componentes o sólo componentes"); |
---|
[e62517a] | 49 | ui->editFilePath->setFocus(); |
---|
[588814f] | 50 | return; |
---|
| 51 | } |
---|
[44d1e60] | 52 | |
---|
[e62517a] | 53 | emit formAccepted(ui->editFilePath->text(), ui->spinNumber->value(),ui->spinBox->value()); |
---|
[44d1e60] | 54 | |
---|
| 55 | close(); |
---|
| 56 | } |
---|