catalogoqtoolbutton.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2006 by Arturo Martin Llado                             *
00003  *   amartin@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 <QWidget>
00022 #include "catalogoqtoolbutton.h"
00023 #include "funcaux.h"
00024 
00025 
00026 #include <stdio.h>
00027 #include <stdlib.h>
00028 
00029 #include <QFile>
00030 #include <QTextStream>
00031 
00032 
00033 #include <QString>
00034 #include <QFileDialog>
00035 #include <QMap>
00036 #include <QList>
00037 
00038 #include "fixed.h"
00039 
00040 
00041 #include "company.h"
00042 #include "dbrecord.h"
00043 
00044 
00046 
00050 CatalogoQToolButton::CatalogoQToolButton(ArticuloList *art , QWidget *parent) : QToolButton(parent), PEmpresaBase() {
00051     _depura("CatalogoQToolButton::CatalogoQToolButton", 0);
00052     m_articuloList = art;
00053     setBoton();
00054     _depura("END CatalogoQToolButton::CatalogoQToolButton", 0);
00055 }
00056 
00057 
00059 
00061 CatalogoQToolButton::~CatalogoQToolButton() {
00062     _depura("CatalogoQToolButton::~CatalogoQToolButton", 0);
00063     _depura("END CatalogoQToolButton::~CatalogoQToolButton", 0);
00064 }
00065 
00066 
00068 
00070 void CatalogoQToolButton::setBoton() {
00071     _depura("CatalogoQToolButton::setBoton", 0);
00072     connect(this, SIGNAL(clicked()), this, SLOT(click()));
00073     setObjectName(QString::fromUtf8("exporta"));
00074     setStatusTip("Imprimir Catalogo");
00075     setToolTip("Imprimir Catalogo");
00076     setMinimumSize(QSize(32, 32));
00077     setIcon(QIcon(QString::fromUtf8("/usr/share/bulmages/icons/catalogo.png")));
00078     setIconSize(QSize(22, 22));
00079     _depura("END CatalogoQToolButton::setBoton", 0);
00080 }
00081 
00082 
00084 
00086 void CatalogoQToolButton::click() {
00087     _depura("CatalogoQToolButton::click", 0);
00088 
00089     setEmpresaBase(m_articuloList->empresaBase());
00090 
00091     QString archivo = confpr->valor(CONF_DIR_OPENREPORTS) + "articulos.rml";
00092     QString archivod = confpr->valor(CONF_DIR_USER) + "articulos.rml";
00093     QString archivologo = confpr->valor(CONF_DIR_OPENREPORTS) + "logo.jpg";
00095 #ifdef WINDOWS
00096 
00097     archivo = "copy " + archivo + " " + archivod;
00098 #else
00099 
00100     archivo = "cp " + archivo + " " + archivod;
00101 #endif
00102 
00103     system (archivo.toAscii().constData());
00105 #ifdef WINDOWS
00106 
00107     archivologo = "copy " + archivologo + " " + confpr->valor(CONF_DIR_USER) + "logo.jpg";
00108 #else
00109 
00110     archivologo = "cp " + archivologo + " " + confpr->valor(CONF_DIR_USER) + "logo.jpg";
00111 #endif
00112 
00113     system(archivologo.toAscii().constData());
00114     QFile file;
00115     file.setFileName(archivod);
00116     file.open(QIODevice::ReadOnly);
00117     QTextStream stream(&file);
00118     QString buff = stream.readAll();
00119     file.close();
00120     QString texto;
00122     buff.replace("[detallearticulos]", detalleArticulos());
00123     if (file.open(QIODevice::WriteOnly)) {
00124         QTextStream stream(&file);
00125         stream << buff;
00126         file.close();
00127     } // end if
00128     invocaPDF("articulos");
00129 
00130     _depura("END CatalogoQToolButton::click", 0);
00131 }
00132 
00133 
00134 
00140 QString CatalogoQToolButton::detalleArticulos() {
00141     _depura("CatalogoQToolButton::detalleArticulos", 0);
00142     QString texto = "";
00143 
00144 
00145     cursor2 *cur = empresaBase()->cargacursor(m_articuloList->formaQuery());
00146     while (!cur->eof()) {
00147         texto += "<blockTable style=\"tabla1\">\n";
00148         texto += "<tr>\n";
00149         texto += "<td><para><H1>" + XMLProtect(cur->valor("nomarticulo")) + "</H1></para>";
00150         texto += "<para>" + XMLProtect(cur->valor("obserarticulo")) + "</para></td></tr><tr>\n";
00151         QString file = confpr->valor(CONF_DIR_IMG_ARTICLES) + XMLProtect(cur->valor("codigocompletoarticulo")) + ".jpg";
00152         QFile f(file);
00153         if (f.exists()) {
00154             texto += "<td><!-- illustration x=\"0\" y=\"0\" height=\"5cm\" -->\n"
00155                      "<image file=\"" + confpr->valor(CONF_DIR_IMG_ARTICLES) +
00156                      XMLProtect(cur->valor("codigocompletoarticulo")) +
00157                      ".jpg\" x=\"0\" y=\"0\" height=\"5cm\"/>\n"
00158                      "<!-- /illustration --></td>\n";
00159         } else {
00160             texto += "<td></td>\n";
00161         }
00162         texto += "</tr>\n";
00163         texto += "</blockTable>";
00164         cur->siguienteregistro();
00165     } // end while
00166     delete cur;
00167     _depura("END CatalogoQToolButton::detalleArticulos()", 0);
00168     return texto;
00169 }
00170 

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