canualesview.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2003 by Tomeu Borras Riera                              *
00003  *   tborras@conetxia.com                                                  *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #include <QMessageBox>
00022 
00023 #include "canualesview.h"
00024 #include "canualesprintview.h"
00025 #include "importbalance.h"
00026 #include "empresa.h"
00027 
00028 #define COL_ARCHIVO 0
00029 #define COL_NOMBRE 1
00030 
00031 
00033 
00037 CAnualesView::CAnualesView(Empresa  *emp, QWidget *parent)
00038         : FichaBc(emp, parent) {
00039     _depura("CAnualesView::CAnualesView", 0);
00040     setTitleName(tr("Cuentas Anuales"));
00042     setDBTableName("asiento");
00043 
00044     this->setAttribute(Qt::WA_DeleteOnClose);
00045     setupUi(this);
00046     m_modo = 0;
00047     inicializatabla();
00048     empresaBase()->meteWindow(windowTitle(), this);
00049     _depura("END CAnualesView::CAnualesView", 0);
00050 }
00051 
00052 
00054 
00056 CAnualesView::~CAnualesView() {
00057     _depura("CAnualesView::~CAnualesView\n", 0);
00058     empresaBase()->sacaWindow(this);
00059     _depura("END CAnualesView::~CAnualesView\n", 0);
00060 }
00061 
00062 
00064 
00066 void CAnualesView::setmodoselector() {
00067     _depura("CAnualesView::setmodoselector", 0);
00068     m_modo = 1;
00069     _depura("END CAnualesView::setmodoselector", 0);
00070 }
00071 
00072 
00074 
00076 void CAnualesView::setmodoeditor() {
00077     _depura("CAnualesView::setmodoeditor", 0);
00078     m_modo = 0;
00079     _depura("END CAnualesView::setmodoeditor", 0);
00080 }
00081 
00082 
00084 
00087 QString CAnualesView::nomBalance() {
00088     _depura("CAnualesView::nomBalance", 0);
00089     _depura("END CAnualesView::nomBalance", 0);
00090     return m_nomBalance;
00091 }
00092 
00093 
00095 
00098 QString CAnualesView::idBalance() {
00099     _depura("CAnualesView::idBalance", 0);
00100     _depura("END CAnualesView::idBalance", 0);
00101     return m_idBalance;
00102 }
00103 
00104 
00106 
00109 void CAnualesView::inicializatabla() {
00110     _depura("CAnualesView::inicializatabla", 0);
00111 
00112     mui_listado->clear();
00113     mui_listado->setColumnCount(2);
00114     QStringList headerlabels;
00115     headerlabels << tr("Archivo") << tr("Archivo");
00116     mui_listado->setHorizontalHeaderLabels(headerlabels);
00117 
00118     mui_listado->setColumnWidth(COL_ARCHIVO, 290);
00119     mui_listado->setColumnWidth(COL_NOMBRE, 290);
00120     mui_listado->hideColumn(COL_ARCHIVO);
00121 
00122     QDir dir(confpr->valor(CONF_DIR_CANUALES));
00123 
00124     dir.setFilter(QDir::Files );
00125     dir.setSorting(QDir::Size | QDir::Reversed);
00126 
00127     QFileInfoList list = dir.entryInfoList();
00128     mui_listado->setRowCount(list.size());
00129 
00130     for (int i = 0; i < list.size(); ++i) {
00131         QFileInfo fileInfo = list.at(i);
00132         QTableWidgetItem *newItem1 = new QTableWidgetItem(fileInfo.filePath(), 0);
00133         mui_listado->setItem(i, COL_ARCHIVO, newItem1);
00134 
00136         QDomDocument doc;
00137         QFile f(newItem1->text());
00138         if (!f.open(QIODevice::ReadOnly)) {
00139             return;
00140         } // end if
00141         if (!doc.setContent(&f)) {
00142             f.close();
00143             return;
00144         } // end if
00145         f.close();
00146         QDomElement nodo = doc.namedItem("BALANCE").namedItem("TITULO").toElement();
00147         QTableWidgetItem *newItem2 = new QTableWidgetItem(nodo.text(), 0);
00148 
00149         mui_listado->setItem(i, COL_NOMBRE, newItem2);
00150     } // end for
00151     _depura("END CAnualesView::inicializatabla", 0);
00152 }
00153 
00154 
00156 
00158 void CAnualesView::on_mui_listado_itemDoubleClicked(QTableWidgetItem *) {
00159     _depura("CAnualesView::on_listado_itemDoubleclicked", 0);
00160     imprimir();
00161     _depura("END CAnualesView::on_listado_itemDoubleclicked", 0);
00162 }
00163 
00164 
00166 
00168 void CAnualesView::imprimir() {
00169     _depura("CAnualesView::imprimir", 0);
00170     QString idbalance = mui_listado->item(mui_listado->currentRow(), COL_ARCHIVO)->text();
00171     CAnualesPrintView *b = new CAnualesPrintView(empresaBase(), 0);
00172     b->setidbalance(idbalance);
00173     b->exec();
00174     delete b;
00175     _depura("END CAnualesView::imprimir", 0);
00176 
00177 }
00178 

Generated on Sat Dec 15 00:01:02 2007 for BulmaGes by  doxygen 1.5.1