busquedatrabajador.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005 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 "qcombobox2.h"
00022 
00023 #include "busquedatrabajador.h"
00024 #include "company.h"
00025 
00026 
00034 BusquedaTrabajador::BusquedaTrabajador(QWidget *parent)
00035         : QComboBox2(parent) {
00036     _depura("BusquedaTrabajador::BusquedaTrabajador", 0);
00037     m_cursorcombo = NULL;
00038     connect(this, SIGNAL(activated(int)), this, SLOT(m_activated(int)));
00039     _depura("END BusquedaTrabajador::BusquedaTrabajador", 0);
00040 }
00041 
00042 
00047 BusquedaTrabajador::~BusquedaTrabajador() {
00048     _depura("BusquedaTrabajador::~BusquedaTrabajador", 0);
00049     if (m_cursorcombo != NULL)
00050         delete m_cursorcombo;
00051     _depura("END BusquedaTrabajador::~BusquedaTrabajador", 0);
00052 }
00053 
00054 
00063 void BusquedaTrabajador::setidtrabajador(QString idtrabajador) {
00064     _depura("BusquedaTrabajador::setidtrabajador", 0);
00065     if (m_cursorcombo != NULL)
00066         delete m_cursorcombo;
00067     m_cursorcombo = empresaBase()->cargacursor("SELECT * FROM trabajador");
00068     if (!m_cursorcombo) return;
00069     int i = 0;
00070     int i1 = 0;
00071     clear();
00072     addItem("--");
00073     while (!m_cursorcombo->eof()) {
00074         i ++;
00075         if (m_cursorcombo->valor("idtrabajador") == idtrabajador)
00076             i1 = i;
00077         addItem(m_cursorcombo->valor("apellidostrabajador") + ", " + m_cursorcombo->valor("nomtrabajador"));
00078         m_cursorcombo->siguienteregistro();
00079     } // end while
00080     setCurrentIndex(i1);
00081     _depura("END BusquedaTrabajador::setidtrabajador", 0);
00082 }
00083 
00084 
00086 
00089 void BusquedaTrabajador::setValorCampo(QString idtrabajador) {
00090     _depura("BusquedaTrabajador::setValorCampo", 0);
00091         setidtrabajador(idtrabajador);
00092     _depura("END BusquedaTrabajador::setValorCampo", 0);
00093 }
00094 
00095 
00101 QString BusquedaTrabajador::idtrabajador() {
00102     _depura("BusquedaTrabajador::idtrabajador", 0);
00103     _depura("END BusquedaTrabajador::idtrabajador", 0);
00104     if (!m_cursorcombo) return "0";
00105     return m_cursorcombo->valor("idtrabajador", currentIndex() - 1);
00106 }
00107 
00108 
00110 
00113 QString BusquedaTrabajador::valorCampo() {
00114     _depura("BusquedaTrabajador::valorCampo", 0);
00115     _depura("END BusquedaTrabajador::valorCampo", 0);
00116         return idtrabajador();
00117 }
00118 
00119 
00125 void BusquedaTrabajador::m_activated(int index) {
00126     _depura("BusquedaTrabajador::m_activated", 0);
00127     if (index > 0) {
00128         emit(valueChanged(m_cursorcombo->valor("idtrabajador", index - 1)));
00129     } else {
00130         emit(valueChanged(""));
00131     }
00132     _depura("END BusquedaTrabajador::m_activated", 0);
00133 }
00134 
00136 
00144 BusquedaTrabajadorDelegate::BusquedaTrabajadorDelegate(QWidget *parent)
00145         : QComboBox2(parent) {
00146     _depura("BusquedaTrabajadorDelegate::BusquedaTrabajadorDelegate", 0);
00147     m_cursorcombo = NULL;
00148     setSizeAdjustPolicy(QComboBox::AdjustToContents);
00149     connect(this, SIGNAL(activated(int)), this, SLOT(m_activated(int)));
00150     _depura("END BusquedaTrabajadorDelegate::BusquedaTrabajadorDelegate", 0);
00151 }
00152 
00153 
00158 BusquedaTrabajadorDelegate::~BusquedaTrabajadorDelegate() {
00159     _depura("BusquedaTrabajadorDelegate::~BusquedaTrabajadorDelegate", 0);
00160     if (m_cursorcombo != NULL)
00161         delete m_cursorcombo;
00162     _depura("END BusquedaTrabajadorDelegate::~BusquedaTrabajadorDelegate", 0);
00163 }
00164 
00165 
00173 void BusquedaTrabajadorDelegate::set(const QString &cod) {
00174     _depura("BusquedaTrabajadorDelegate::set", 0);
00175     int index = 0;
00176     QString codigo = cod;
00177 
00178     if (m_cursorcombo != NULL)
00179         delete m_cursorcombo;
00180 
00181     m_cursorcombo = empresaBase()->cargacursor("SELECT nomtrabajador, apellidostrabajador FROM trabajador ");
00182     clear();
00183     while (!m_cursorcombo->eof()) {
00184         addItem(m_cursorcombo->valor("apellidostrabajador")+", "+m_cursorcombo->valor("nomtrabajador"));
00185         m_cursorcombo->siguienteregistro();
00186         if(m_cursorcombo->valor("apellidostrabajador")+", "+m_cursorcombo->valor("nomtrabajador") == cod)
00187                 index = m_cursorcombo->regactual();
00188     }// end while
00189     setEditText(cod);
00190     setCurrentIndex(index);
00191 
00192     _depura("END BusquedaTrabajadorDelegate::set", 0);
00193 }
00194 
00195 
00196 

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