busquedaprovincia.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 <QComboBox>
00022 
00023 #include "busquedaprovincia.h"
00024 #include "empresabase.h"
00025 #include "funcaux.h"
00026 
00027 
00035 BusquedaProvincia::BusquedaProvincia(QWidget *parent)
00036         : QComboBox2(parent) {
00037     _depura("BusquedaProvincia::BusquedaProvincia", 0);
00038     m_cursorcombo = NULL;
00039     connect(this, SIGNAL(activated(int)), this, SLOT(m_activated(int)));
00040     _depura("END BusquedaProvincia::BusquedaProvincia", 0);
00041 }
00042 
00043 
00045 
00047 BusquedaProvincia::~BusquedaProvincia() {
00048     _depura("BusquedaProvincia::~BusquedaProvincia", 0);
00049     if (m_cursorcombo != NULL)
00050         delete m_cursorcombo;
00051     _depura("END BusquedaProvincia::~BusquedaProvincia", 0);
00052 }
00053 
00054 
00062 void BusquedaProvincia::setIdProvincia(QString idprovincia) {
00063     _depura("BusquedaProvincia::setIdProvincia", 0, idprovincia);
00064     if (m_cursorcombo != NULL)
00065         delete m_cursorcombo;
00066     m_cursorcombo = empresaBase()->cargacursor("SELECT * FROM provincia LEFT JOIN pais ON provincia.idpais = pais.idpais ORDER BY descpais, provincia");
00068     if (!m_cursorcombo) return;
00069 
00070     int i = 0;
00071     int i1 = 0;
00072     clear();
00073     addItem("--");
00074 
00075     while (!m_cursorcombo->eof()) {
00076         i ++;
00077         if (m_cursorcombo->valor("idprovincia") == idprovincia)
00078             i1 = i;
00079         addItem(m_cursorcombo->valor("provincia")+" ("+m_cursorcombo->valor("descpais")+")");
00080         m_cursorcombo->siguienteregistro();
00081     } // end while
00082 
00083     setCurrentIndex(i1);
00084     _depura("END BusquedaProvincia::setIdProvincia", 0);
00085 }
00086 
00087 
00089 
00092 void BusquedaProvincia::setValorCampo(QString idprovincia) {
00093     _depura("BusquedaProvincia::setValorCampo", 0);
00094         setIdProvincia(idprovincia);
00095     _depura("END BusquedaProvincia::setValorCampo", 0);
00096 }
00097 
00098 
00100 
00103 void BusquedaProvincia::m_activated(int index) {
00104     _depura("BusquedaProvincia::m_activated", 0);
00105     if (index > 0) {
00106         emit(valueChanged(m_cursorcombo->valor("idprovincia", index-1)));
00107     } else {
00108         emit(valueChanged(""));
00109     }
00110     _depura("END BusquedaProvincia::m_activated", 0);
00111 }
00112 
00113 
00115 
00118 QString BusquedaProvincia::idProvincia() {
00119     _depura("BusquedaProvincia::idProvincia", 0);
00120     if (currentIndex() > 0) {
00121         return m_cursorcombo->valor("idprovincia", currentIndex()-1);
00122     } else {
00123         return "";
00124     } // end if
00125     _depura("END BusquedaProvincia::idProvincia", 0);
00126 }
00127 
00128 
00130 
00133 QString BusquedaProvincia::valorCampo() {
00134     _depura("BusquedaProvincia::valorCampo", 0);
00135     _depura("END BusquedaProvincia::valorCampo", 0);
00136         return idProvincia();
00137 }
00138 

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