pluginbarcodeopen.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Tomeu Borras Riera                              *
00003  *   tborras@conetxia.com                                                  *
00004  *   Copyright (C) 2006 by Fco. Javier M. C.                               *
00005  *   fcojavmc@todo-redes.com                                               *
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  *   This program is distributed in the hope that it will be useful,       *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00015  *   GNU General Public License for more details.                          *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU General Public License     *
00018  *   along with this program; if not, write to the                         *
00019  *   Free Software Foundation, Inc.,                                       *
00020  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00021  ***************************************************************************/
00022 
00023 #include <QMenu>
00024 #include <QAction>
00025 #include <QObject>
00026 #include <QMessageBox>
00027 #include <QInputDialog>
00028 #include <QStringList>
00029 #include <QTranslator>
00030 #include <QTextCodec>
00031 #include <QLocale>
00032 
00033 #include <stdio.h>
00034 
00035 #include "pluginbarcodeopen.h"
00036 #include "company.h"
00037 #include "funcaux.h"
00038 #include "facturaview.h"
00039 #include "presupuestoview.h"
00040 #include "pedidoclienteview.h"
00041 #include "albaranclienteview.h"
00042 #include "pedidoproveedorview.h"
00043 
00044 
00046 
00048 myplugin::myplugin() {
00049     _depura("myplugin::myplugin", 0);
00050     _depura("END myplugin::myplugin", 0);
00051 }
00052 
00053 
00055 
00057 myplugin::~myplugin() {
00058     _depura("myplugin::~myplugin", 0);
00059     _depura("END myplugin::~myplugin", 0);
00060 }
00061 
00062 
00064 
00067 void myplugin::elslot() {
00068     _depura("myplugin::elslot", 0);
00069     bool ok;
00070     QString text = QInputDialog::getText(0, tr("QInputDialog::getText()"),
00071                                          tr("Introduzca codigo"), QLineEdit::Normal, "", &ok);
00072     if (ok && !text.isEmpty()) {
00073         QStringList listaelem = text.split(" ");
00074         if (listaelem.at(0) == QString("FAC")) {
00075             FacturaView *prov = ((Company *)empresaBase())->newFacturaView();
00076             if (prov->cargar(listaelem.at(1))) {
00077                 delete prov;
00078                 return;
00079             } // end if
00080             empresaBase()->m_pWorkspace->addWindow(prov);
00081             prov->show();
00082         } else if (listaelem.at(0) == QString("PRE")) {
00083             PresupuestoView *prov = ((Company *)empresaBase())->nuevoPresupuestoView();
00084             if (prov->cargar(listaelem.at(1))) {
00085                 delete prov;
00086                 return;
00087             } // end if
00088             empresaBase()->m_pWorkspace->addWindow(prov);
00089             prov->show();
00090         } else if (listaelem.at(0) == QString("PED")) {
00091             PedidoClienteView *prov = new PedidoClienteView((Company *)empresaBase(), 0);
00092             if (prov->cargar(listaelem.at(1))) {
00093                 delete prov;
00094                 return;
00095             } // end if
00096             empresaBase()->m_pWorkspace->addWindow(prov);
00097             prov->show();
00098         } else if (listaelem.at(0) == QString("ALB")) {
00099             AlbaranClienteView *prov = ((Company *)empresaBase())->newAlbaranClienteView();
00100             if (prov->cargar(listaelem.at(1))) {
00101                 delete prov;
00102                 return;
00103             } // end if
00104             empresaBase()->m_pWorkspace->addWindow(prov);
00105             prov->show();
00106         } else if (listaelem.at(0) == QString("PEDP")) {
00107             PedidoProveedorView *prov = new PedidoProveedorView((Company *)empresaBase(), 0);
00108             if (prov->cargar(listaelem.at(1))) {
00109                 delete prov;
00110                 return;
00111             } // end if
00112             empresaBase()->m_pWorkspace->addWindow(prov);
00113             prov->show();
00114         } // end if
00115     } // end if
00116     _depura("END myplugin::elslot", 0);
00117 }
00118 
00119 
00121 
00124 void myplugin::inicializa(Bulmafact *bges) {
00125     _depura("myplugin::inicializa", 0);
00127     setEmpresaBase(bges->getcompany());
00128     m_bulmafact = bges;
00129     QMenu *pPluginMenu;
00131     pPluginMenu = bges->menuBar()->findChild<QMenu *>("Herramientas");
00132 
00134     if (!pPluginMenu) {
00135         pPluginMenu = new QMenu("&Herramientas", bges->menuBar());
00136         pPluginMenu->setObjectName(QString::fromUtf8("Herramientas"));
00137     } // end if
00138 
00139     QAction *accion = new QAction("&Apertura Rapida", 0);
00140     accion->setStatusTip("Abre documentos a partir del codigo de barras");
00141     accion->setWhatsThis("Abre documentos a partir del codigo de barras");
00142     connect(accion, SIGNAL(activated()), this, SLOT(elslot()));
00143     pPluginMenu->addAction(accion);
00145     bges->menuBar()->insertMenu(bges->menuVentana->menuAction(), pPluginMenu);
00146     _depura("END myplugin::inicializa", 0);
00147 }
00148 
00149 
00151 
00154 void entryPoint(Bulmafact *bges) {
00155         _depura("entryPoint", 0);
00157         QTranslator *traductor = new QTranslator(0);
00158         if (confpr->valor(CONF_TRADUCCION) == "locales") {
00159             traductor->load(QString("pluginbarcodeopen_") + QLocale::system().name(),
00160                             confpr->valor(CONF_DIR_TRADUCCION).toAscii().constData());
00161         } else {
00162             QString archivo = "pluginbarcodeopen_" + confpr->valor(CONF_TRADUCCION);
00163            traductor->load(archivo, confpr->valor(CONF_DIR_TRADUCCION).toAscii().constData());
00164         } // end if
00165         theApp->installTranslator(traductor);
00166 
00167     myplugin *plug = new myplugin();
00168     plug->inicializa(bges);
00169         _depura("END entryPoint", 0);
00170 }
00171 

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