plugintipostrabajo.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 #include <QToolButton>
00023 
00024 #include "plugintipostrabajo.h"
00025 #include "listtipostrabajoview.h"
00026 #include "tiptrab.h"
00027 #include "busquedatipotrabajo.h"
00028 #include "busquedaarticulo.h"
00029 
00030 
00032 
00034 mytiptrab::mytiptrab() {
00035     _depura("mytiptrab::mytiptrab", 0);
00036     _depura("END mytiptrab::mytiptrab", 0);
00037 }
00038 
00039 
00041 
00043 mytiptrab::~mytiptrab() {
00044     _depura("mytiptrab::~mytiptrab", 0);
00045     _depura("END mytiptrab::~mytiptrab", 0);
00046 }
00047 
00048 
00050 
00052 void mytiptrab::elslot() {
00053     _depura("mytiptrab::elslot", 0);
00054    ListTiposTrabajoView *l = new ListTiposTrabajoView((Company *)m_bulmafact->getcompany(), 0);
00055     m_bulmafact->workspace()->addWindow(l);
00056     l->show();
00057     _depura("END mytiptrab::elslot", 0);
00058 }
00059 
00060 
00062 
00065 void mytiptrab::inicializa(Bulmafact *bges) {
00067     m_bulmafact = bges;
00068     QAction *accion = new QAction("&Tipos de Trabajo", 0);
00069     accion->setStatusTip("Tipos de Trabajo");
00070     accion->setWhatsThis("Tipos de Trabajo");
00071     connect(accion, SIGNAL(activated()), this, SLOT(elslot()));
00073     bges->menuMaestro->insertAction(bges->actionTrabajadores, accion);
00074 }
00075 
00076 
00078 
00082 int entryPoint(Bulmafact *bges) {
00083     _depura("Estoy dentro del plugin de tipos de trabajo", 0);
00084     mytiptrab *plug = new mytiptrab();
00085     plug->inicializa(bges);
00086     return 0;
00087 }
00088 
00089 
00091 
00095 int TrabajadorView_TrabajadorView_Post (TrabajadorView *trab) {
00096     _depura("TrabajadorView_TrabajadorView_Post", 0);
00097 
00098     QHBoxLayout *hboxLayout160 = new QHBoxLayout();
00099     hboxLayout160->setSpacing(2);
00100     hboxLayout160->setMargin(0);
00101     hboxLayout160->setObjectName(QString::fromUtf8("hboxLayout16"));
00102 
00103     QLabel *textLabel2_9_26 = new QLabel(trab->m_frameplugin);
00104     textLabel2_9_26->setObjectName(QString::fromUtf8("textLabel2_9_2"));
00105     hboxLayout160->addWidget(textLabel2_9_26);
00106     textLabel2_9_26->setText("Tipo Trabajo");
00107 
00108     BusquedaTipoTrabajo *tipotraba = new BusquedaTipoTrabajo(trab->m_frameplugin);
00109     tipotraba->setEmpresaBase(trab->empresaBase());
00110     tipotraba->setidtipotrabajo("");
00111     tipotraba->setObjectName(QString::fromUtf8("tipotraba"));
00112     hboxLayout160->addWidget(tipotraba);
00113 
00114 
00116     QVBoxLayout *m_hboxLayout1 = trab->m_frameplugin->findChild<QVBoxLayout *>("hboxLayout1");
00117     if (!m_hboxLayout1) {
00118         m_hboxLayout1 = new QVBoxLayout(trab->m_frameplugin);
00119         m_hboxLayout1->setSpacing(0);
00120         m_hboxLayout1->setMargin(0);
00121         m_hboxLayout1->setObjectName(QString::fromUtf8("hboxLayout1"));
00122     } // end if
00123 
00124     m_hboxLayout1->addLayout(hboxLayout160);
00125 
00126 //   trab->m_frameplugin->setLayout(hboxLayout160);
00127    return 0;
00128 }
00129 
00130 
00132 
00136 int TrabajadorView_on_mui_guardar_clicked(TrabajadorView *trab) {
00137 
00138     BusquedaTipoTrabajo *l = trab->findChild<BusquedaTipoTrabajo *>("tipotraba");
00139     QString query = "UPDATE trabajador SET ";
00140     query += " idtipotrabajo = " + l->idtipotrabajo();
00141     query += " WHERE idtrabajador=" + trab->empresaBase()->sanearCadena(trab->idtrabajador());
00142     trab->empresaBase()->begin();
00143     trab->empresaBase()->ejecuta(query);
00144     trab->empresaBase()->commit();
00145     return 0;
00146 }
00147 
00148 
00150 
00154 int TrabajadorView_on_mui_lista_currentItemChanged_Post(TrabajadorView *trab) {
00155     BusquedaTipoTrabajo *l = trab->findChild<BusquedaTipoTrabajo *>("tipotraba");
00156 
00157     cursor2 *cur = trab->empresaBase()->cargacursor("SELECT idtipotrabajo FROM trabajador WHERE idtrabajador = " + trab->idtrabajador());
00158     if (!cur->eof()) {
00159         l->setidtipotrabajo(cur->valor("idtipotrabajo")); 
00160     }
00161     delete cur;
00162     return 0;
00163 }
00164 
00165 
00167 
00171 int AlmacenView_AlmacenView(AlmacenView *alm) {
00172    _depura("esxtoy en la clase almacen", 0);
00173 
00174     SubForm2Bf *form = new SubForm2Bf(alm);
00175     delete form->m_delegate;
00176     form->m_delegate = new QSubForm3BfDelegate(form);
00177     form->mui_list->setItemDelegate(form->m_delegate);
00178     form->setObjectName("mui_tipostrabajo");
00179     form->setEmpresaBase(alm->empresaBase());
00180     form->setDBTableName("almacentipotrabajo");
00181     form->setDBCampoId("idalmacen");
00182     form->addSHeader("nomtipotrabajo", DBCampo::DBvarchar, DBCampo::DBNoSave , SHeader::DBNone, QApplication::translate("AlmacenView", "ID nom tipo Trabajo"));
00183     form->addSHeader("numpers", DBCampo::DBint, DBCampo::DBNotNull, SHeader::DBNone , QApplication::translate("AlmacenView", "Numero de Cargos Necesarios"));
00184     form->addSHeader("idalmacen", DBCampo::DBint, DBCampo::DBNotNull | DBCampo::DBPrimaryKey, SHeader::DBNoView | SHeader::DBNoWrite, QApplication::translate("AlmacenView", "ID almacen"));
00185     form->addSHeader("idtipotrabajo", DBCampo::DBint, DBCampo::DBNotNull, SHeader::DBNoView | SHeader::DBNoWrite, QApplication::translate("AlmacenView", "ID tipo Trabajo"));
00186     form->addSHeader("origidtipotrabajo", DBCampo::DBint, DBCampo::DBDupPrimaryKey | DBCampo::DBNoSave, SHeader::DBNoView, "idtipotrabajo");
00187 
00188     form->setinsercion(TRUE);
00189     form->setDelete(TRUE);
00190     form->setSortingEnabled(FALSE);
00191 
00192     alm->mui_tab->addTab(form, "Trabajadores Requeridos");
00193     return 0;
00194 }
00195 
00196 
00198 
00202 int Ficha_cargar(Ficha *fich) {
00203         SubForm3 *form = fich->findChild<SubForm3 *>("mui_tipostrabajo");
00204         if (form) 
00205                 form->cargar("SELECT *, tipotrabajo.idtipotrabajo AS origidtipotrabajo FROM almacentipotrabajo LEFT JOIN tipotrabajo ON almacentipotrabajo.idtipotrabajo = tipotrabajo.idtipotrabajo WHERE idalmacen = " + fich->DBvalue("idalmacen"));
00206         return 0;
00207 }
00208 
00209 
00211 
00215 int Ficha_guardar_Post(Ficha *fich) {
00216         SubForm3 *form = fich->findChild<SubForm3 *>("mui_tipostrabajo");
00217         if (form) {
00218                 form->setColumnValue("idalmacen", fich->DBvalue("idalmacen"));
00219                 form->guardar();
00220         }
00221         return 0;
00222 }
00223 
00228 
00229 
00231 
00234 QSubForm3BfDelegate::QSubForm3BfDelegate(QObject *parent = 0) : QSubForm2BfDelegate(parent) {
00235     _depura("QSubForm3BfDelegate::QSubForm3BfDelegate", 0);
00236     _depura("END QSubForm3BfDelegate::QSubForm3BfDelegate", 0);
00237 }
00238 
00239 
00241 
00243 QSubForm3BfDelegate::~QSubForm3BfDelegate() {
00244     _depura("QSubForm3BfDelegate::~QSubForm3BfDelegate", 0);
00245     _depura("END QSubForm3BfDelegate::~QSubForm3BfDelegate", 0);
00246 }
00247 
00248 
00250 
00256 QWidget *QSubForm3BfDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const {
00257     _depura("QSubForm3BfDelegate::createEditor", 0);
00258     SHeader *linea;
00259     linea = m_subform->cabecera()->at(index.column());
00260 
00261     if (linea->nomcampo() == "nomtipotrabajo") {
00262         BusquedaTipoTrabajoDelegate *editor = new BusquedaTipoTrabajoDelegate(parent);
00263         editor->setEmpresaBase((Company *)m_subform->empresaBase());
00264         return editor;
00265     } else  {
00266         return QSubForm2BfDelegate::createEditor(parent, option, index);
00267     } // end if
00268     _depura("END QSubForm3BfDelegate::createEditor", 0);
00269 }
00270 
00271 
00273 
00279 void QSubForm3BfDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const {
00280     _depura("QSubForm3BfDelegate::setModelData", 0);
00281 
00283     if (index.column() < 0 || index.row() < 0)
00284         return;
00285 
00286     SHeader *linea;
00287     linea = m_subform->cabecera()->at(index.column());
00288     if (linea->nomcampo() == "nomtipotrabajo") {
00289         BusquedaTipoTrabajoDelegate *comboBox = static_cast<BusquedaTipoTrabajoDelegate*>(editor);
00290         QString value = comboBox->currentText();
00291         model->setData(index, value);
00292         m_subform->lineaat(index.row())->setDBvalue("idtipotrabajo", comboBox->id());
00293     } else {
00294         QSubForm2BfDelegate::setModelData(editor, model, index);
00295     } // end if
00296     _depura("END QSubForm3BfDelegate::setModelData", 0);
00297 }
00298 
00299 
00301 
00305 void QSubForm3BfDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const {
00306     _depura("QSubForm3BfDelegate::setEditorData", 0);
00307     SHeader *linea;
00308     linea = m_subform->cabecera()->at(index.column());
00309     if (linea->nomcampo() == "nomtipotrabajo") {
00310         QString value = index.model()->data(index, Qt::DisplayRole).toString();
00311         BusquedaTipoTrabajoDelegate *comboBox = static_cast<BusquedaTipoTrabajoDelegate*>(editor);
00312         comboBox->set(value);
00313     } else {
00314         QSubForm2BfDelegate::setEditorData(editor, index);
00315     } // end if
00316     _depura("END QSubForm3BfDelegate::setEditorData", 0);
00317 }
00318 
00319 

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