1 | #include "formloadmatrix.H" |
---|
2 | #include "ui_formLoadMatrix.h" |
---|
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 | connect(ui.buttonSearch, SIGNAL(clicked()),this,SLOT(slotLoadMatrixFile())); |
---|
19 | connect(ui.buttonCancel, SIGNAL(clicked()),this,SLOT(close())); |
---|
20 | connect(ui.buttonOpen, SIGNAL(clicked()), this, |
---|
21 | SLOT(slotButtonAcceptClicked())); |
---|
22 | |
---|
23 | } |
---|
24 | |
---|
25 | void FormLoadMatrix::slotLoadMatrixFile() { |
---|
26 | QString filename = QFileDialog::getOpenFileName(this, |
---|
27 | "Seleccione archivo de Matriz", QDir::homePath(),"*.csv"); |
---|
28 | |
---|
29 | if(filename.isEmpty()) return; |
---|
30 | ui.editFilePath->setText(filename); |
---|
31 | } |
---|
32 | |
---|
33 | void FormLoadMatrix::slotButtonAcceptClicked() |
---|
34 | { |
---|
35 | if (ui.editFilePath->text().isEmpty()) |
---|
36 | { |
---|
37 | QMessageBox::critical(this, "Faltan datos", |
---|
38 | "Debe seleccionar un archivo"); |
---|
39 | |
---|
40 | ui.editFilePath->setFocus(); |
---|
41 | return; |
---|
42 | } |
---|
43 | |
---|
44 | emit formAccepted(ui.editFilePath->text(), ui.spinNumber->value(),ui.spinBox->value()); |
---|
45 | |
---|
46 | close(); |
---|
47 | } |
---|