1 | /** |
---|
2 | Sistema de Manejo de Matrices de Contabilidad Social, desarrollado a partir de Mayo de 2015. |
---|
3 | @file formloadmatrix.c |
---|
4 | @brief Clases y métodos del formulario que permite generar cargar la matriz |
---|
5 | @date 01/05/2015 |
---|
6 | @author José Ruiz |
---|
7 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
8 | */ |
---|
9 | #include "formloadmatrix.H" |
---|
10 | #include "ui_formLoadMatrix.h" |
---|
11 | |
---|
12 | /** |
---|
13 | @brief Método que permite cerrar el formulario |
---|
14 | @date 01/05/2015 |
---|
15 | @author José Ruiz |
---|
16 | */ |
---|
17 | void FormLoadMatrix::closeEvent(QCloseEvent *) |
---|
18 | { |
---|
19 | emit formClosed(); |
---|
20 | } |
---|
21 | |
---|
22 | /** |
---|
23 | @brief Clase principal que inicializa la interfaz |
---|
24 | @date 01/05/2015 |
---|
25 | @author José Ruiz |
---|
26 | @param <parent> Recibe el widget que será el padre |
---|
27 | */ |
---|
28 | FormLoadMatrix::FormLoadMatrix(QWidget * parent) |
---|
29 | : QWidget(parent, Qt::Tool), |
---|
30 | ui(new Ui::FormLoadMatrix) |
---|
31 | { |
---|
32 | ui->setupUi(this); |
---|
33 | int x = parent->pos().x() + parent->width()/2 - this->width()/2; |
---|
34 | int y = parent->pos().y() + parent->height()/2 - this->height()/2; |
---|
35 | this->move(x, y); |
---|
36 | |
---|
37 | connect(ui->buttonSearch, SIGNAL(clicked()),this,SLOT(slotLoadMatrixFile())); |
---|
38 | connect(ui->buttonCancel, SIGNAL(clicked()),this,SLOT(close())); |
---|
39 | connect(ui->buttonOpen, SIGNAL(clicked()), this, |
---|
40 | SLOT(slotButtonAcceptClicked())); |
---|
41 | |
---|
42 | } |
---|
43 | |
---|
44 | /** |
---|
45 | @brief Método que permite generar el diálogo para cargar un archivo |
---|
46 | @date 01/05/2015 |
---|
47 | @author José Ruiz |
---|
48 | */ |
---|
49 | void FormLoadMatrix::slotLoadMatrixFile() { |
---|
50 | QString filename = QFileDialog::getOpenFileName(this, |
---|
51 | "Seleccione archivo de Matriz", QDir::homePath(),"*.csv"); |
---|
52 | |
---|
53 | if(filename.isEmpty()) return; |
---|
54 | ui->editFilePath->setText(filename); |
---|
55 | } |
---|
56 | |
---|
57 | /** |
---|
58 | @brief Método que valida al pulsar el boton cargar y emite una SIGNAL |
---|
59 | @date 01/05/2015 |
---|
60 | @author José Ruiz |
---|
61 | */ |
---|
62 | void FormLoadMatrix::slotButtonAcceptClicked() |
---|
63 | { |
---|
64 | if (ui->editFilePath->text().isEmpty()) |
---|
65 | { |
---|
66 | QMessageBox::critical(this, "Faltan datos", |
---|
67 | "Debe seleccionar un archivo"); |
---|
68 | |
---|
69 | ui->editFilePath->setFocus(); |
---|
70 | return; |
---|
71 | } |
---|
72 | else if(!ui->radioAccount->isChecked() and !ui->radioComponent->isChecked()){ |
---|
73 | QMessageBox::critical(this, "Faltan datos", |
---|
74 | "Debe seleccionar si cargará cuentas y componentes o sólo componentes"); |
---|
75 | ui->editFilePath->setFocus(); |
---|
76 | return; |
---|
77 | } |
---|
78 | |
---|
79 | emit formAccepted(ui->editFilePath->text(), ui->spinNumber->value(),ui->spinBox->value()); |
---|
80 | |
---|
81 | close(); |
---|
82 | } |
---|