[44d1e60] | 1 | #include "formloadmatrix.H" |
---|
[9dd61b1] | 2 | #include "ui_formLoadMatrix.h" |
---|
[44d1e60] | 3 | |
---|
| 4 | void FormLoadMatrix::closeEvent(QCloseEvent *) |
---|
| 5 | { |
---|
| 6 | emit formClosed(); |
---|
| 7 | } |
---|
| 8 | |
---|
| 9 | FormLoadMatrix::FormLoadMatrix(QWidget * parent) |
---|
| 10 | : QWidget(parent, Qt::Tool) |
---|
| 11 | { |
---|
| 12 | ui.setupUi(this); |
---|
| 13 | |
---|
| 14 | int x = parent->pos().x() + parent->width()/2 - this->width()/2; |
---|
| 15 | int y = parent->pos().y() + parent->height()/2 - this->height()/2; |
---|
| 16 | this->move(x, y); |
---|
| 17 | |
---|
| 18 | ui.editYear->setValidator(new QIntValidator); |
---|
| 19 | connect(ui.buttonSearch, SIGNAL(clicked()),this,SLOT(slotLoadMatrixFile())); |
---|
| 20 | connect(ui.buttonCancel, SIGNAL(clicked()),this,SLOT(close())); |
---|
| 21 | connect(ui.buttonOpen, SIGNAL(clicked()), this, |
---|
| 22 | SLOT(slotButtonAcceptClicked())); |
---|
| 23 | |
---|
| 24 | } |
---|
[9dd61b1] | 25 | |
---|
[44d1e60] | 26 | void FormLoadMatrix::slotLoadMatrixFile() { |
---|
| 27 | QString filename = QFileDialog::getOpenFileName(this, |
---|
| 28 | "Seleccione archivo de Matriz", QDir::homePath(),"*.csv"); |
---|
| 29 | |
---|
| 30 | if(filename.isEmpty()) return; |
---|
| 31 | ui.editFilePath->setText(filename); |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | void FormLoadMatrix::slotButtonAcceptClicked() |
---|
| 35 | { |
---|
| 36 | if (ui.editFilePath->text().isEmpty()) |
---|
| 37 | { |
---|
| 38 | QMessageBox::critical(this, "Faltan datos", |
---|
| 39 | "Debe seleccionar un archivo"); |
---|
| 40 | |
---|
| 41 | ui.editFilePath->setFocus(); |
---|
| 42 | return; |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | emit formAccepted(ui.editFilePath->text(), ui.spinNumber->value(), |
---|
| 46 | ui.comboSeparator->currentText().toStdString()[0]); |
---|
| 47 | |
---|
| 48 | close(); |
---|
| 49 | } |
---|