Changeset 588814f in mmcs for mainwindow.C
- Timestamp:
- Jul 29, 2016, 3:00:25 PM (8 years ago)
- Branches:
- master
- Children:
- 50550b0
- Parents:
- 61e2bc2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mainwindow.C
r61e2bc2 r588814f 22 22 connect(formLoadMatrix, SIGNAL(formAccepted(QString,int,int)), 23 23 this, SLOT(slotFormLoadMatrixAccepted(QString,int,int))); 24 connect(formLoadMatrix->ui.radioAccount,SIGNAL(clicked()),this,SLOT(slotOnlyaccount())); 25 connect(formLoadMatrix->ui.radioComponent,SIGNAL(clicked()),this,SLOT(slotOnlycomponent())); 24 26 } 25 27 … … 31 33 numAccounts = accountNumber; 32 34 precission = pre; 33 34 35 createMatrixCentralWidget(); 36 35 37 } 36 38 … … 41 43 formLoadMatrix = 0; 42 44 } 45 46 /* 47 Función que permite agregar un mensaje en el label cuando se selecciona la opción de cuentas 48 Autor: Rodrigo Boet 49 Fecha: 29/07/2016 50 */ 51 void MainWindow::slotOnlyaccount() 52 { 53 formLoadMatrix->ui.label_info->setText("Info: Para esta opción debe agregar debe cargar un csv con las cuentas y componentes"); 54 55 } 56 57 /* 58 Función que permite agregar un mensaje en el label cuando se selecciona la opción de componentes 59 Autor: Rodrigo Boet 60 Fecha: 29/07/2016 61 */ 62 void MainWindow::slotOnlycomponent() 63 { 64 formLoadMatrix->ui.label_info->setText("Info: Para esta opción debe agregar debe cargar un csv con sólo los componentes"); 65 } 66 43 67 44 68 /* Funcion para crear un nuevo proyecto */ … … 548 572 549 573 /* *********** Se agrega la columna en la que se asignan los nombre ************** */ 550 tableWidget->insertRow(0); 551 tableWidget->insertColumn(0); 552 noEditColZero(tableWidget); 553 /* Se agregan elementos a la recien creada fila/columna */ 554 int contador=tableWidget->rowCount(); 555 for(int i=1;i<contador;i++) 556 { 557 QTableWidgetItem *ValoraInsertar = new QTableWidgetItem; 558 ValoraInsertar->setFlags(ValoraInsertar->flags() ^ Qt::ItemIsEditable); 559 tableWidget->setItem(0,i,ValoraInsertar); 560 561 QTableWidgetItem *ValoraInsertar2 = new QTableWidgetItem; 562 ValoraInsertar2->setFlags(ValoraInsertar2->flags() ^ Qt::ItemIsEditable); 563 tableWidget->setItem(i,0,ValoraInsertar2); 574 if(formLoadMatrix->ui.radioComponent->isChecked()) 575 { 576 tableWidget->insertRow(0); 577 tableWidget->insertColumn(0); 578 noEditColZero(tableWidget); 579 /* Se agregan elementos a la recien creada fila/columna */ 580 int contador=tableWidget->rowCount(); 581 for(int i=1;i<contador;i++) 582 { 583 QTableWidgetItem *ValoraInsertar = new QTableWidgetItem; 584 ValoraInsertar->setFlags(ValoraInsertar->flags() ^ Qt::ItemIsEditable); 585 tableWidget->setItem(0,i,ValoraInsertar); 586 587 QTableWidgetItem *ValoraInsertar2 = new QTableWidgetItem; 588 ValoraInsertar2->setFlags(ValoraInsertar2->flags() ^ Qt::ItemIsEditable); 589 tableWidget->setItem(i,0,ValoraInsertar2); 590 } 591 } 592 else if(formLoadMatrix->ui.radioAccount->isChecked()){ 593 loadsAccounts(tableWidget); 564 594 } 565 595 … … 591 621 int column = lines.count(); 592 622 CrearTablaVacia(column+2,tableWidget);//Se crea una tabla vacia a modo de matriz cuadrada 623 QStringList Accounts; 624 if(formLoadMatrix->ui.radioAccount->isChecked()) 625 { 626 Accounts = lines; 627 linea = in.readLine(); 628 lines = linea.split(";"); 629 } 593 630 //Se leen los componentes y se distribuyen en filas y columnas 594 631 for(int i=1;i<=column;i++) … … 638 675 } 639 676 } 677 //Se agregan las cuentas si se selecciono la opción correspondiente 678 if(formLoadMatrix->ui.radioAccount->isChecked()) 679 { 680 noEditColZero(tableWidget); 681 tableWidget->insertColumn(0); 682 tableWidget->insertRow(0); 683 int limit = tableWidget->rowCount(); 684 for(int i = 2;i<limit;i++) 685 { 686 QTableWidgetItem *itemFila = new QTableWidgetItem(Accounts.at(i-2)); 687 CellStyle(itemFila); 688 itemFila->setFlags(itemFila->flags() ^ Qt::ItemIsEditable); 689 itemFila->setTextAlignment(Qt::AlignCenter); 690 tableWidget->setItem(0,i,itemFila); 691 QTableWidgetItem *itemColumna = new QTableWidgetItem(Accounts.at(i-2)); 692 CellStyle(itemColumna); 693 itemColumna->setFlags(itemColumna->flags() ^ Qt::ItemIsEditable); 694 itemColumna->setTextAlignment(Qt::AlignCenter); 695 tableWidget->setItem(i,0,itemColumna); 696 } 697 ItemsNoEditable(tableWidget,1,2,0); 698 } 699 700 } 701 702 /* 703 Función para cargar las cuentas 704 Autor: Rodrigo Boet 705 Fecha: 29/07/2016 706 @param <QTableWidget> *tw -> Recibe como parametro una widget de tabla de qt 707 */ 708 void MainWindow::loadsAccounts(QTableWidget *tw) 709 { 710 int column = tw->rowCount(); 711 QStringList numberAccounts; 712 for(int i = 2;i<column;i++) 713 { 714 numberAccounts.append(tw->item(0,i)->text()); 715 } 716 QVector<QString> vector; 717 int init = 3; 718 foreach (QString item,numberAccounts) { 719 if(!vector.contains(item)) 720 { 721 int inicio = init; 722 int fin = (inicio+numberAccounts.count(item))-1; 723 init = fin+1; 724 vector.append(item); 725 vector.append(QString::number(inicio)); 726 vector.append(QString::number(fin)); 727 tw->setSpan(0,inicio-1,1,numberAccounts.count(item)); 728 tw->setSpan(inicio-1,0,numberAccounts.count(item),1); 729 } 730 } 731 //Se cargan los datos en la cuenta 732 for(int i=0;i<numAccounts;i++) 733 { 734 QLineEdit *le= findChild<QLineEdit *>(QString("linedit %1").arg(i + 1)); 735 QSpinBox *SBStart = findChild<QSpinBox *>(QString("accountstart %1").arg(i+1)); 736 QSpinBox *SBEnd = findChild<QSpinBox *>(QString("accountend %1").arg(i+1)); 737 if(i==0) 738 { 739 le->setText(vector.at(i)); 740 SBStart->setValue(vector.at(i+1).toInt()); 741 SBEnd->setValue(vector.at(i+2).toInt()); 742 } 743 else 744 { 745 le->setText(vector.at(i+2)); 746 SBStart->setValue(vector.at(i+3).toInt()); 747 SBEnd->setValue(vector.at(i+4).toInt()); 748 } 749 } 750 TotalPrincipalTable(tw,PrincipalTable,2); 751 bool iguales = true; 752 CalcularTotales(tw,2,iguales);//Se llama a la funcion que agregue una nueva fila y columna con los totales respectivos 753 if(!iguales) 754 { 755 QMessageBox::warning(this,"Alerta","El Total de una(s) fila(s)\n es distinto al Total de\nuna(s) columna(s)"); 756 } 757 setAccountTitle(tw); 758 759 //Se ocultan el StackedWidget con los datos de la cuenta 760 hideStackedWidget(); 761 762 /* Luego de calcular los totales se habilitan las opciones del menu herramientas */ 763 CoeficientesTecnicos.setEnabled(true); 764 actionCH.setEnabled(true); 765 actionCV.setEnabled(true); 766 actionVariableExogena.setEnabled(true); 767 /* Se habilitan las opciones del menú visualización */ 768 actionSeleccionarTabla.setEnabled(true); 769 connect(&actionSeleccionarTabla,SIGNAL(triggered()),this,SLOT(slotSeleccionarTabla())); 640 770 } 641 771 … … 767 897 Modificar->setIcon(QIcon(":/imgs/edit-deshabilitado")); 768 898 } 899 } 900 901 /* 902 Función para esconder el StackWidget que tiene los datos de las cuentas 903 Autor: Rodrigo Boet 904 Fecha: 29/07/2016 905 */ 906 void MainWindow::hideStackedWidget() 907 { 908 QPushButton *Agregar = findChild<QPushButton *>("AgregarCuentas"); 909 QPushButton *Restaurar = findChild<QPushButton *>("Restaurar"); 910 Agregar->setStyleSheet("background-color: gray; color: #fff;" 911 "font-weight: bold; height: 30px; border: none;" 912 "border-radius: 5px; margin-top: 40px;"); 913 Agregar->setEnabled(false); 914 Agregar->setVisible(false); 915 Restaurar->setStyleSheet("background-color: gray; color: #fff;" 916 "font-weight: bold; height: 30px; border: none;" 917 "border-radius: 5px; margin-top: 40px;"); 918 Restaurar->setEnabled(false); 919 Restaurar->setVisible(false); 920 QPushButton *Modificar = findChild<QPushButton *>("Modificar"); 921 Modificar->setStyleSheet("background-color: gray; color: #fff;" 922 "font-weight: bold; height: 30px; border: none;" 923 "border-radius: 5px; margin-top: 40px;"); 924 Modificar->setEnabled(false); 925 Modificar->setVisible(false); 926 927 QPushButton *Finalizar = findChild<QPushButton *>("Finalizar"); 928 Finalizar->setStyleSheet("background-color: gray; color: #fff;" 929 "font-weight: bold; height: 30px; border: none;" 930 "border-radius: 5px; margin-top: 40px;"); 931 Finalizar->setEnabled(false); 932 Finalizar->setVisible(false); 933 934 QGroupBox *groupbox = findChild<QGroupBox *>("GrupoCuentas"); 935 groupbox->setVisible(false); 769 936 } 770 937 … … 914 1081 if(Centinela) 915 1082 { 916 QPushButton *Agregar = findChild<QPushButton *>("AgregarCuentas"); 917 QPushButton *Restaurar = findChild<QPushButton *>("Restaurar"); 918 Agregar->setStyleSheet("background-color: gray; color: #fff;" 919 "font-weight: bold; height: 30px; border: none;" 920 "border-radius: 5px; margin-top: 40px;"); 921 Agregar->setEnabled(false); 922 Agregar->setVisible(false); 923 Restaurar->setStyleSheet("background-color: gray; color: #fff;" 924 "font-weight: bold; height: 30px; border: none;" 925 "border-radius: 5px; margin-top: 40px;"); 926 Restaurar->setEnabled(false); 927 Restaurar->setVisible(false); 928 QPushButton *Modificar = findChild<QPushButton *>("Modificar"); 929 Modificar->setStyleSheet("background-color: gray; color: #fff;" 930 "font-weight: bold; height: 30px; border: none;" 931 "border-radius: 5px; margin-top: 40px;"); 932 Modificar->setEnabled(false); 933 Modificar->setVisible(false); 934 935 QPushButton *Finalizar = findChild<QPushButton *>("Finalizar"); 936 Finalizar->setStyleSheet("background-color: gray; color: #fff;" 937 "font-weight: bold; height: 30px; border: none;" 938 "border-radius: 5px; margin-top: 40px;"); 939 Finalizar->setEnabled(false); 940 Finalizar->setVisible(false); 941 942 QGroupBox *groupbox = findChild<QGroupBox *>("GrupoCuentas"); 943 groupbox->setVisible(false); 1083 //Se oculta el widget con los datos de las cuentas 1084 hideStackedWidget(); 944 1085 945 1086 QTableWidget *tw = findChild<QTableWidget *>("TablaPrincipal");
Note: See TracChangeset
for help on using the changeset viewer.