[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) |
---|
| 13 | : QWidget(parent, Qt::Tool) |
---|
| 14 | { |
---|
| 15 | ui.setupUi(this); |
---|
| 16 | |
---|
| 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 | |
---|
| 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, |
---|
| 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; |
---|
| 33 | ui.editFilePath->setText(filename); |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | void FormLoadMatrix::slotButtonAcceptClicked() |
---|
| 37 | { |
---|
| 38 | if (ui.editFilePath->text().isEmpty()) |
---|
| 39 | { |
---|
| 40 | QMessageBox::critical(this, "Faltan datos", |
---|
| 41 | "Debe seleccionar un archivo"); |
---|
| 42 | |
---|
| 43 | ui.editFilePath->setFocus(); |
---|
| 44 | return; |
---|
| 45 | } |
---|
[588814f] | 46 | else if(!ui.radioAccount->isChecked() and !ui.radioComponent->isChecked()){ |
---|
| 47 | QMessageBox::critical(this, "Faltan datos", |
---|
| 48 | "Debe seleccionar si cargará cuentas y componentes o sólo componentes"); |
---|
| 49 | ui.editFilePath->setFocus(); |
---|
| 50 | return; |
---|
| 51 | } |
---|
[44d1e60] | 52 | |
---|
[96b0c4a] | 53 | emit formAccepted(ui.editFilePath->text(), ui.spinNumber->value(),ui.spinBox->value()); |
---|
[44d1e60] | 54 | |
---|
| 55 | close(); |
---|
| 56 | } |
---|