00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <QObject>
00022 #include <QDomDocument>
00023 #include <QInputDialog>
00024
00025 #include "empresa.h"
00026 #include "abreempresaview.h"
00027 #include "listcuentasview1.h"
00028 #include "asiento1view.h"
00029 #include "asientosview.h"
00030 #include "amortizacionesview.h"
00031 #include "canualesview.h"
00032
00033 #include "cuentaview.h"
00034 #include "canalview.h"
00035 #include "ccosteview.h"
00036 #include "mpatrimonialesview.h"
00037 #include "propiedadesempresa.h"
00038 #include "cambiactaview.h"
00039 #include "tipoivaview.h"
00040 #include "fpagoview.h"
00041 #include "selectccosteview.h"
00042 #include "selectcanalview.h"
00043 #include "plugins.h"
00044 #include "bbloqfecha.h"
00045 #include "diarioview.h"
00046 #include "balanceview.h"
00047 #include "listado347.h"
00048 #include "paisview.h"
00049 #include "bulmacont.h"
00050
00051 #ifndef WIN32
00052 #include <unistd.h>
00053 #include <sys/types.h>
00054 #include <sys/wait.h>
00055 #endif
00056
00057
00059
00061 void Empresa::s_asiento1() {
00062 _depura("Empresa::s_asiento1", 0);
00063 introapunts2->setWindowState(introapunts2->windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
00064 _depura("Empresa::s_asiento1", 0);
00065 }
00066
00067
00069
00072 Empresa::Empresa(Bulmacont *bcont) : EmpresaBase() {
00073 _depura("Empresa::Empresa", 0);
00074 m_bulmacont = bcont;
00075 diario = NULL;
00076 extracto = NULL;
00077 balance = NULL;
00078 selccostes = NULL;
00079 selcanales = NULL;
00080 introapunts2 = NULL;
00081 m_listasientos = NULL;
00082 nombre = "";
00083 _depura("END Empresa::Empresa", 0);
00084 }
00085
00086
00088
00090 Empresa::~Empresa() {
00091 _depura("Empresa::~Empresa", 0);
00092 guardaConf();
00094 m_listventanas->vaciarCompleto();
00095 _depura("END Empresa::~Empresa", 0);
00096 }
00097
00098
00100
00103 postgresiface2 *Empresa::bdempresa() {
00104 return (this);
00105 }
00106
00107
00109
00112 BalanceView *Empresa::balanceempresa() {
00113 return balance;
00114 }
00115
00117
00120 extractoview1 *Empresa::extractoempresa() {
00121 return extracto;
00122 }
00123
00124
00126
00129 DiarioView *Empresa::diarioempresa() {
00130 return diario;
00131 }
00132
00133
00135
00138 Asiento1View *Empresa::intapuntsempresa() {
00139 return introapunts2;
00140 }
00141
00142
00144
00147 Asiento1View *Empresa::intapuntsempresa2() {
00148 return introapunts2;
00149 }
00150
00151
00153
00156 int Empresa::numdigitosempresa() {
00157 return numdigitos;
00158 }
00159
00160
00162
00165 QString Empresa::nomuserempresa() {
00166 return nombre;
00167 }
00168
00169
00171
00174 QString Empresa::nombreempresa() {
00175 return nombre;
00176 }
00177
00178
00180
00184 int Empresa::createMainWindows(Splash *splash) {
00185 _depura("Empresa::createMainWindows", 0);
00186 try {
00189 QString query = "SELECT length(valor) AS numdigitos FROM configuracion WHERE nombre = 'CodCuenta'";
00190 cursor2 *cursoraux1 = cargacursor(query);
00191 numdigitos = cursoraux1->valor("numdigitos").toInt();
00192 delete cursoraux1;
00193 if (extracto != NULL) {
00194 delete extracto;
00195 delete diario;
00196 delete balance;
00197 delete selccostes;
00198 delete selcanales;
00199 delete m_listasientos;
00200 }
00201
00203 selccostes = new SelectCCosteView(this, 0);
00204 selcanales = new selectcanalview(this, 0);
00205
00207
00210 splash->mensaje(QApplication::translate("Empresa", "Inicializando Extracto"));
00211 splash->setBarraProgreso(7);
00212 m_progressbar->setValue(0);
00213 extracto = new extractoview1(this, 0);
00214 m_pWorkspace->addWindow(extracto);
00215
00217 splash->mensaje(QApplication::translate("Empresa", "Inicializando Diario"));
00218 splash->setBarraProgreso(20);
00219 m_progressbar->setValue(20);
00220 diario = new DiarioView(this, 0);
00221 m_pWorkspace->addWindow(diario);
00222
00224 splash->mensaje(QApplication::translate("Empresa", "Inicializando Balance"));
00225 splash->setBarraProgreso(35);
00226 m_progressbar->setValue(35);
00227 balance = new BalanceView(this, 0);
00228 m_pWorkspace->addWindow(balance);
00229
00231
00232
00233
00234
00235
00236
00237
00238
00240 splash->mensaje(QApplication::translate("company", "Inicializando Asientos"));
00241 splash->setBarraProgreso(60);
00242 m_progressbar->setValue(60);
00243 introapunts2 = new Asiento1View(this, 0);
00244 m_pWorkspace->addWindow(introapunts2);
00245
00247 splash->mensaje(QApplication::translate("company", "Inicializando Asientos"));
00248 splash->setBarraProgreso(75);
00249 m_progressbar->setValue(75);
00250 m_listasientos = new AsientosView(this);
00251 m_listasientos->presentar();
00252 m_pWorkspace->addWindow(m_listasientos);
00253
00255 splash->mensaje(QApplication::translate("company", "Inicializando Cuentas"));
00256 splash->setBarraProgreso(90);
00257 m_progressbar->setValue(90);
00258 m_listcuentas = new listcuentasview1(this, 0);
00259 m_listcuentas->inicializa();
00260 m_pWorkspace->addWindow(m_listcuentas);
00261
00263 splash->mensaje(QApplication::translate("company", "Terminado"));
00264 splash->setBarraProgreso(100);
00265 m_progressbar->setValue(100);
00266
00268 int res = g_plugins->lanza("Empresa_createMainWindows_Post", this);
00269 if (res != 0) {
00270 return 0;
00271 }
00272
00273 cargaConf();
00274
00275 } catch (...) {
00276 _depura("Error al iniciar la clase company", 2);
00277 }
00278
00279 _depura("END Empresa::createMainWindows", 0);
00280 return(0);
00281 }
00282
00283
00285
00288 void Empresa::maximiza() {
00289 _depura("Empresa::maximiza", 0);
00290 diario->showMaximized();
00291 extracto->showMaximized();
00292 balance->showMaximized();
00293 _depura("END Empresa::maximiza", 0);
00294 }
00295
00296
00298
00301 int Empresa::muestracuentas() {
00302 _depura("Empresa::muestracuentas", 0);
00303 m_listcuentas->setWindowState(introapunts2->windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
00304 _depura("END Empresa::muestracuentas", 0);
00305 return 0;
00306 }
00307
00308
00310
00314 int Empresa::ccostes() {
00315 _depura("Empresa::ccostes", 0);
00316 ccosteview *ccoste = new ccosteview(this, 0);
00317 m_pWorkspace->addWindow(ccoste);
00318 ccoste->show();
00319 _depura("END Empresa::ccostes", 0);
00320 return 0;
00321 }
00322
00323
00325
00329 int Empresa::canales() {
00330 _depura("Empresa::canales", 0);
00331 canalview *canal = new canalview(this, 0);
00332 m_pWorkspace->addWindow(canal);
00333 canal->show();
00334 _depura("END Empresa::canales", 0);
00335 return 0;
00336 }
00337
00338
00340
00343 void Empresa::bloqueoFechas() {
00344 _depura("Empresa::bloqueoFechas", 0);
00345 BbloqFecha *tip = new BbloqFecha(this, 0);
00346 m_pWorkspace->addWindow(tip);
00347 tip->show();
00348 _depura("END Empresa::bloqueoFechas", 0);
00349 }
00350
00351
00353
00357 int Empresa::tiposIVA() {
00358 _depura("Empresa::tiposIVA", 0);
00359 tipoivaview *tip = new tipoivaview(this, 0);
00360 m_pWorkspace->addWindow(tip);
00361 tip->show();
00362 _depura("END Empresa::tiposIVA", 0);
00363 return 0;
00364 }
00365
00366
00368
00372 int Empresa::fPago() {
00373 _depura("Empresa::fPago", 0);
00374 fpagoview *fp = new fpagoview(this, 0);
00375 m_pWorkspace->addWindow(fp);
00376 fp->show();
00377 _depura("END Empresa::fPago", 0);
00378 return 0;
00379 }
00380
00381
00383
00386 int Empresa::cambioejercicio() {
00387 _depura("Empresa::cambioejercicio", 0);
00389 introapunts2->cargaasientos();
00390 introapunts2->boton_fin();
00391 _depura("END Empresa::cambioejercicio", 0);
00392 return 0;
00393 }
00394
00395
00397
00400 CuentaView* Empresa::newcuentaview() {
00401 _depura("Empresa::newcuentaview", 0);
00402 CuentaView *nuevae = new CuentaView(this, 0);
00403 _depura("END Empresa::newcuentaview", 0);
00404 return nuevae;
00405 }
00406
00407
00409
00412 int Empresa::nuevacuenta() {
00413 _depura("Empresa::nuevacuenta", 0);
00414 CuentaView *nuevae = newcuentaview();
00415 m_pWorkspace->addWindow(nuevae);
00416 nuevae->show();
00417 _depura("END Empresa::nuevacuenta", 0);
00418 return 0;
00419 }
00420
00421
00423
00426 int Empresa::muestraapuntes1() {
00427 _depura("Empresa::muestraapuntes1", 0);
00428 introapunts2->setWindowState(introapunts2->windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
00429 _depura("END Empresa::muestraapuntes1", 0);
00430 return 0;
00431 }
00432
00433
00435
00438 int Empresa::muestraasientos() {
00439 _depura("Empresa::muestraasientos", 0);
00440 m_listasientos->setWindowState(m_listasientos->windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
00441 _depura("END Empresa::muestraasientos", 0);
00442 return 0;
00443 }
00444
00445
00447
00450 int Empresa::propiedadempresa() {
00451 _depura("Empresa::propiedadempresa", 0);
00452 propiedadesempresa *nuevae = new propiedadesempresa(this, 0);
00453 m_pWorkspace->addWindow(nuevae);
00454 nuevae->show();
00455 _depura("END Empresa::propiedadempresa", 0);
00456 return 0;
00457 }
00458
00459
00461
00464 int Empresa::amortizaciones() {
00465 _depura("Empresa::amortizaciones", 0);
00466 AmortizacionesView *amors = new AmortizacionesView(this, 0);
00467 m_pWorkspace->addWindow(amors);
00468 amors->show();
00469 _depura("END Empresa::amortizaciones", 0);
00470 return 0;
00471 }
00472
00473
00476
00479 int Empresa::mpatrimoniales() {
00480 _depura("Empresa::mpatrimoniales", 0);
00481 mpatrimonialesview *nuevae = new mpatrimonialesview(this, 0);
00482 nuevae->inicializa();
00483 nuevae->exec();
00484 delete nuevae;
00485 _depura("END Empresa::mpatrimoniales", 0);
00486 return 0;
00487 }
00488
00489
00492
00495 int Empresa::compbalance() {
00496 _depura("Empresa::compbalance", 0);
00497 CAnualesView *nueva = new CAnualesView(this, 0);
00498 m_pWorkspace->addWindow(nueva);
00499 nueva->show();
00500 _depura("END Empresa::compbalance", 0);
00501 return 0;
00502 }
00503
00504
00506
00509 int Empresa::libromayor() {
00510 _depura("Empresa::libromayor", 0);
00511 extracto->setWindowState(extracto->windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
00512 _depura("END Empresa::libromayor", 0);
00513 return 0;
00514 }
00515
00516
00518
00521 int Empresa::boton_siguiente() {
00522 _depura("Empresa::boton_siguiente", 0);
00523 QWidget *widget;
00524 widget = m_pWorkspace->activeWindow();
00525 if (widget == extracto) {
00526 extracto->boton_siguiente();
00527 } else if (widget == introapunts2) {
00528 introapunts2->boton_siguiente();
00529 }
00530 _depura("END Empresa::boton_siguiente", 0);
00531 return 0;
00532 }
00533
00534
00536
00539 int Empresa::boton_anterior() {
00540 _depura("Empresa::boton_anterior", 0);
00541 QWidget *widget;
00542 widget = m_pWorkspace->activeWindow();
00543 if (widget == extracto) {
00544 extracto->boton_anterior();
00545 } else if (widget == introapunts2) {
00546 introapunts2->boton_anterior();
00547 }
00548 _depura("END Empresa::boton_anterior", 0);
00549 return 0;
00550 }
00551
00552
00554
00557 int Empresa::boton_guardar() {
00558 _depura("Empresa::boton_guardar", 0);
00559 QWidget *widget;
00560 widget = m_pWorkspace->activeWindow();
00561 if (widget == diario) {
00562 diario->boton_guardar();
00563 } else {
00564 extracto->boton_guardar();
00565 }
00566 _depura("END Empresa::boton_guardar", 0);
00567 return 0;
00568 }
00569
00570
00572
00575 int Empresa::boton_imprimir() {
00576 _depura("Empresa::boton_imprimir", 0);
00577 QWidget *widget = m_pWorkspace->activeWindow();
00578 if (widget == diario) {
00579 diario->boton_imprimir();
00580 } else if (widget == balance) {
00581 balance->on_mui_imprimir_clicked();
00582 } else if (widget == extracto) {
00583 extracto->boton_imprimir();
00584 }
00585 _depura("END Empresa::boton_imprimir", 0);
00586 return 0;
00587 }
00588
00589
00591
00594 int Empresa::boton_reload() {
00595 _depura("Empresa::boton_reload", 0);
00596 QWidget *widget;
00597 widget = m_pWorkspace->activeWindow();
00598 if (widget == diario) {
00599 diario->accept();
00600 } else if (widget == extracto) {
00601 extracto->accept();
00602 } else if (widget == balance) {
00603 balance->accept();
00604 }
00605 _depura("END Empresa::boton_reload", 0);
00606 return 0;
00607 }
00608
00609
00611
00614 int Empresa::boton_primero() {
00615 _depura("Empresa::boton_primero", 0);
00616 QWidget *widget;
00617 widget = m_pWorkspace->activeWindow();
00618 if (widget == introapunts2) {
00619 introapunts2->boton_inicio();
00620 } else if (widget == diario) {}
00621 else if (widget == extracto) {
00622 extracto->boton_inicio();
00623 }
00624 _depura("END Empresa::boton_primero", 0);
00625 return 0;
00626 }
00627
00628
00630
00633 int Empresa::boton_ultimo() {
00634 _depura("Empresa::boton_ultimo", 0);
00635 QWidget *widget;
00636 widget = m_pWorkspace->activeWindow();
00637 if (widget == introapunts2) {
00638 introapunts2->boton_fin();
00639 } else if (widget == diario) {}
00640 else if (widget == extracto) {
00641 extracto->boton_fin();
00642 }
00643 _depura("END Empresa::boton_ultimo", 0);
00644 return 0;
00645 }
00646
00647
00649
00652 int Empresa::librodiario() {
00653 _depura("Empresa::librodiario", 0);
00654 diario->setWindowState(diario->windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
00655 _depura("END Empresa::librodiario", 0);
00656 return 0;
00657 }
00658
00659
00661
00664 int Empresa::librobalance() {
00665 _depura("Empresa::librobalance", 0);
00666 balance->setWindowState(balance->windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
00667 _depura("END Empresa::librobalance", 0);
00668 return 0;
00669 }
00670
00671
00673
00675 void Empresa::Abrirasientos() {
00676 _depura("Empresa::Abrirasientos", 0);
00677 cursor2 *cur = NULL;
00678 try {
00679 cur = cargacursor("SELECT abreasientos()");
00680 g_main->statusBar()->showMessage(QObject::tr("Se han espaciado los asientos"), 2000);
00681 delete cur;
00682 _depura("END Empresa::Abrirasientos", 0);
00683 } catch (...) {
00684 mensajeError("Ha habido un error al espaciar los asientos");
00685 if (cur) delete cur;
00686 return;
00687 }
00688 }
00689
00690
00693 void Empresa::Ordenarasientos() {
00694 _depura("Empresa::Ordenarasientos", 10);
00695 QString query= "SELECT reordenaasientosall()";
00696 cursor2 *cur = NULL;
00697 try {
00698 cur = cargacursor(query);
00699 g_main->statusBar()->showMessage(QObject::tr("Se han ordenado los asientos"), 2000);
00700 delete cur;
00701 _depura("END Empresa::Ordenarasientos", 10);
00702 } catch (...) {
00703 mensajeError("Ha habido un error al ordenar los asientos");
00704 if (cur) delete cur;
00705 return;
00706 }
00707 }
00708
00709
00711
00714 int Empresa::listado347() {
00715 _depura("Empresa::modelo347", 0);
00716 Listado347 *dlg347 = new Listado347(this, "0");
00717 dlg347->exec();
00718 delete dlg347;
00719 _depura("END Empresa::modelo347", 0);
00720 return 0;
00721 }
00722
00723
00725
00727 void Empresa::cierraempresa() {
00728 _depura("Empresa::cierraempresa", 0);
00729 QString hoy = QDate::currentDate().toString("dd/MM/yyyy");
00730 QString finicial = "01/01/"+hoy.right(4);
00731
00732 bool ok;
00733 QString text = QInputDialog::getText(0,
00734 QApplication::translate("empresa","Fecha Inicial"), QApplication::translate("empresa", "Fecha Inicial Regularizacion:"), QLineEdit::Normal,
00735 finicial, &ok );
00736 if ( ok && !text.isEmpty() ) {
00737 finicial = text;
00738 } else {
00739 return;
00740 }
00741
00742 QString text1 = QInputDialog::getText(0,
00743 QApplication::translate("empresa", "Fecha Final"), QApplication::translate("empresa", "Fecha Final:"), QLineEdit::Normal,
00744 hoy, &ok );
00745 if ( ok && !text1.isEmpty() ) {
00746 hoy = text1;
00747 } else {
00748 return;
00749 }
00750
00751 introapunts2->show();
00752 introapunts2->asiento_cierre(finicial, hoy);
00753 _depura("END Empresa::cierraempresa", 0);
00754 }
00755
00756
00758
00760 void Empresa::abreempresa() {
00761 _depura("Empresa::abreempresa", 0);
00762 QString hoy = QDate::currentDate().toString("dd/MM/yyyy");
00763 QString finicial = "01/01/"+hoy.right(4);
00764
00765 bool ok;
00766 QString text1 = QInputDialog::getText(0,
00767 QApplication::translate("empresa", "Fecha"), QApplication::translate("empresa", "Fecha:"), QLineEdit::Normal,
00768 hoy, &ok );
00769 if ( ok && !text1.isEmpty() ) {
00770 hoy = text1;
00771 } else {
00772 return;
00773 }
00774
00775 introapunts2->show();
00776 introapunts2->asiento_apertura(hoy);
00777 _depura("END Empresa::abreempresa", 0);
00778 }
00779
00780
00782
00784 void Empresa::regularizaempresa() {
00785 _depura("Empresa::regularizaempresa", 0,"Sin parametros");
00786 QString hoy = QDate::currentDate().toString("dd/MM/yyyy");
00787 QString finicial = "01/01/"+hoy.right(4);
00788
00789 bool ok;
00790 QString text = QInputDialog::getText(0,
00791 QApplication::translate("empresa","Fecha Inicial"), QApplication::translate("empresa", "Fecha Inicial Regularizacion:"), QLineEdit::Normal,
00792 finicial, &ok );
00793 if ( ok && !text.isEmpty() ) {
00794 finicial = text;
00795 } else {
00796 return;
00797 }
00798
00799 QString text1 = QInputDialog::getText(0,
00800 QApplication::translate("empresa", "Fecha Final"), QApplication::translate("empresa", "Fecha Final Regularizacion:"), QLineEdit::Normal,
00801 hoy, &ok );
00802 if ( ok && !text1.isEmpty() ) {
00803 hoy = text1;
00804 } else {
00805 return;
00806 }
00807
00808 regularizaempresa(finicial, hoy);
00809 _depura("END Empresa::regularizaempresa", 0);
00810 }
00811
00812
00814
00818 void Empresa::regularizaempresa(QString finicial, QString ffinal) {
00819 _depura("Empresa::regularizaempresa", 0, finicial +"--"+ffinal);
00820 introapunts2->show();
00821 introapunts2->asiento_regularizacion(finicial, ffinal);
00822 _depura("END Empresa::regularizaempresa", 0);
00823 }
00824
00826
00828 void Empresa::Filtro() {
00829 _depura("Empresa::Filtro", 0);
00830 QWidget *widget;
00831 widget = m_pWorkspace->activeWindow();
00832 if (widget == introapunts2) {
00833 introapunts2->boton_filtrar();
00834 }
00835 _depura("END Empresa::Filtro", 0);
00836 }
00837
00840
00842 void Empresa::reemplazacuentaenasientos() {
00843 _depura("Empresa::reemplazacuentaenasientos", 0);
00844 CambiaCtaView *ctac = new CambiaCtaView(this, 0, false);
00845 ctac->exec();
00846 _depura("END Empresa::reemplazacuentaenasientos", 0);
00847 }
00848
00849
00851
00853 void Empresa::recalculasaldos() {
00854 _depura("Empresa::recalculasaldos", 0);
00855 ejecuta("SELECT recalculasaldos()");
00856 _depura("END Empresa::recalculasaldos", 0);
00857 }
00858
00859
00861
00864 SelectCCosteView *Empresa::getselccostes() {
00865 _depura("Empresa::getselccostes", 0);
00866 _depura("END Empresa::getselccostes", 0);
00867 return selccostes;
00868 }
00869
00870
00872
00875 selectcanalview *Empresa::getselcanales() {
00876 _depura("Empresa::getselcanales", 0);
00877 _depura("END Empresa::getselcanales", 0);
00878 return selcanales;
00879 }
00880
00881
00883
00885 void Empresa::centrocostedefecto() {
00886 _depura("Empresa::centrocostedefecto", 0);
00887 selccostes->exec();
00888 _depura("END Empresa::centrocostedefecto", 0);
00889 }
00890
00891
00893
00895 void Empresa::canaldefecto() {
00896 _depura("Empresa::canaldefecto", 0);
00897 selcanales->exec();
00898 _depura("END Empresa::canaldefecto", 0);
00899 }
00900
00901
00903
00905 void Empresa::guardaConf() {
00906 _depura("Empresa::guardaConf", 0);
00907 QFile file(confpr->valor(CONF_DIR_USER) + "bulmacont_" + nameDB() + ".cfn");
00909 if (file.open(QIODevice::WriteOnly)) {
00910 QTextStream stream(&file);
00911 stream << "<CONFIG>\n";
00912 stream << "\t<PRINCIPAL>\n";
00913 stream << "\t\t\t<X>" + QString::number(m_bulmacont->x()) + "</X>\n";
00914 stream << "\t\t\t<Y>" + QString::number(m_bulmacont->y()) + "</Y>\n";
00915 stream << "\t\t\t<WIDTH>" + QString::number(m_bulmacont->width()) + "</WIDTH>\n";
00916 stream << "\t\t\t<HEIGHT>" + QString::number(m_bulmacont->height()) + "</HEIGHT>\n";
00917 stream << "\t\t\t<INDEXADOR>" + (m_bulmacont->actionIndexador->isChecked() ? QString("TRUE") : QString("FALSE")) + "</INDEXADOR>\n";
00918 stream << "\t</PRINCIPAL>\n";
00919
00920
00921 for (int i = 0; i < m_listventanas->numVentanas(); i++) {
00922 QObject *obj = m_listventanas->ventana(i);
00923 QWidget *wid = (QWidget *) obj;
00924 stream << "\t<VENTANA>\n";
00925 stream << "\t\t<VNAME>" + obj->objectName() + "</VNAME>\n";
00926 stream << "\t\t<VX>" + QString::number(wid->parentWidget()->x()) + "</VX>\n";
00927 stream << "\t\t<VY>" + QString::number(wid->parentWidget()->y()) + "</VY>\n";
00928 stream << "\t\t<VWIDTH>" + QString::number(wid->width()) + "</VWIDTH>\n";
00929 stream << "\t\t<VHEIGHT>" + QString::number(wid->height()) + "</VHEIGHT>\n";
00930 stream << "\t\t<VVISIBLE>" + (wid->isVisible() ? QString("TRUE") : QString("FALSE")) + "</VVISIBLE>\n";
00931 stream << "\t\t<VMAXIMIZED>" + (wid->isMaximized() ? QString("TRUE") : QString("FALSE")) + "</VMAXIMIZED>\n";
00932 stream << "\t\t<VACTIVEWINDOW>" + (m_bulmacont->workspace()->activeWindow() == wid ? QString("TRUE") : QString("FALSE")) + "</VACTIVEWINDOW>";
00933 stream << "\t</VENTANA>\n";
00934 }
00935
00936 stream << "</CONFIG>\n";
00937 file.close();
00938 }
00939 _depura("END Empresa::guardaConf", 0);
00940 }
00941
00943
00946 void Empresa::cargaConf() {
00947 _depura("Empresa::cargaConf", 0);
00948 QFile file(confpr->valor(CONF_DIR_USER) + "bulmacont_" + nameDB() + ".cfn");
00949 QDomDocument doc("mydocument");
00950 if (!file.open(QIODevice::ReadOnly))
00951 return;
00952 if (!doc.setContent(&file)) {
00953 file.close();
00954 return;
00955 }
00956 file.close();
00957
00958
00959
00960 QDomElement docElem = doc.documentElement();
00961 QDomElement principal = docElem.firstChildElement("PRINCIPAL");
00963 QString nx = principal.firstChildElement("X").toElement().text();
00964
00966 QString ny = principal.firstChildElement("Y").toElement().text();
00967
00969 QString nwidth = principal.firstChildElement("WIDTH").toElement().text();
00970
00972 QString nheight = principal.firstChildElement("HEIGHT").toElement().text();
00973
00975 m_bulmacont->setGeometry(nx.toInt(), ny.toInt(), nwidth.toInt(), nheight.toInt());
00976
00978 QString indexador = principal.firstChildElement("INDEXADOR").toElement().text();
00979 if (indexador == "TRUE") {
00980 s_indexadorCambiaEstado(TRUE);
00981 m_bulmacont->actionIndexador->setChecked(TRUE);
00982 } else {
00983 s_indexadorCambiaEstado(FALSE);
00984 m_bulmacont->actionIndexador->setChecked(FALSE);
00985 }
00986
00988 QWidget *activewindow = NULL;
00989 QDomNodeList nodos = docElem.elementsByTagName("VENTANA");
00990 for (int i = 0; i < nodos.count(); i++) {
00991 QDomNode ventana = nodos.item(i);
00992 QDomElement e1 = ventana.toElement();
00993 if ( !e1.isNull() ) {
00994 QString vname = e1.firstChildElement("VNAME").toElement().text();
00995 for (int j = 0; j < m_listventanas->numVentanas(); j++) {
00996 QObject *obj = m_listventanas->ventana(j);
00997 QWidget *wid = (QWidget *) obj;
00998 if (obj->objectName() == vname) {
00999 QString vx = e1.firstChildElement("VX").toElement().text();
01000 QString vy = e1.firstChildElement("VY").toElement().text();
01001 QString vwidth = e1.firstChildElement("VWIDTH").toElement().text();
01002 QString vheight = e1.firstChildElement("VHEIGHT").toElement().text();
01003 QString vvisible = e1.firstChildElement("VVISIBLE").toElement().text();
01004 QString vmaximized = e1.firstChildElement("VMAXIMIZED").toElement().text();
01005 QString vactivewindow = e1.firstChildElement("VACTIVEWINDOW").toElement().text();
01007 wid->resize(vwidth.toInt(), vheight.toInt());
01008 wid->parentWidget()->move(vx.toInt(), vy.toInt());
01009 if ( vvisible == "TRUE") {
01010 wid->showNormal();
01011 } else {
01012 wid->hide();
01013 }
01014 if ( vmaximized == "TRUE") {
01015 wid->showMaximized();
01016 }
01017 if ( vactivewindow == "TRUE") {
01018 activewindow = wid;
01019 }
01020 }
01021 }
01022 }
01023 }
01025 if (activewindow)
01026 m_bulmacont->workspace()->setActiveWindow(activewindow);
01027 _depura("END Empresa::cargaConf", 0);
01028 }
01029
01030