selectcanalview.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2003 by Tomeu Borras                                    *
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 "selectcanalview.h"
00022 #include "empresa.h"
00023 #include "funcaux.h"
00024 
00025 
00027 
00034 selectcanalview::selectcanalview(Empresa *emp,QWidget *parent)
00035         : QDialog(parent), PEmpresaBase(emp) {
00036     _depura("selectcanalview::selectcanalview", 0);
00037     setupUi(this);
00038     numdigitos = ((Empresa *)empresaBase())->numdigitosempresa();
00039     m_iterador = new QTreeWidgetItemIterator(m_listCanales);
00040 
00041     m_listCanales->setColumnCount(5);
00042 
00043     QStringList etiquetas;
00044     etiquetas << tr("nom_canal") << tr("desc_canal") << tr("Status") << tr("idcanal") << tr("Seleccion");
00045     m_listCanales->setHeaderLabels(etiquetas);
00046 
00047     cargacanales();
00048     _depura("END selectcanalview::selectcanalview", 0);
00049 }
00050 
00051 
00053 
00055 selectcanalview::~selectcanalview() {
00056     _depura("selectcanalview::~selectcanalview", 0);
00057     delete m_iterador;
00058     _depura("END selectcanalview::~selectcanalview", 0);
00059 }
00060 
00061 
00063 
00065 void selectcanalview::cargacanales() {
00066     _depura("selectcanalview::cargacanales", 0);
00067     QMap <int, QTreeWidgetItem *> Lista;
00068     QTreeWidgetItem *it;
00069 
00070     int idcanal = 0;
00071     cursor2 *cursoraux1;
00073     m_listCanales->clear();
00074     empresaBase()->begin();
00075     cursoraux1 = empresaBase()->cargacursor("SELECT * FROM canal", "canalillos");
00076     empresaBase()->commit();
00077     while (!cursoraux1->eof()) {
00078         idcanal = atoi(cursoraux1->valor("idcanal").toAscii());
00079         it = new QTreeWidgetItem(m_listCanales);
00080         Lista[idcanal] = it;
00081         it->setText(3, cursoraux1->valor("idcanal"));
00082         it->setText(1, cursoraux1->valor("descripcion"));
00083         it->setText(0, cursoraux1->valor("nombre"));
00084         it->setCheckState(0, Qt::Unchecked);
00085          it->setExpanded(TRUE);
00086         cursoraux1->siguienteregistro();
00087     } // end while
00088 
00089     delete cursoraux1;
00090     _depura("END selectcanalview::cargacanales", 0);
00091 }
00092 
00093 
00097 
00100 int selectcanalview::firstcanal() {
00101     _depura("selectcanalview::firstcanal", 0);
00102     delete m_iterador;
00103     m_iterador = new QTreeWidgetItemIterator(m_listCanales);
00104     _depura("END selectcanalview::firstcanal", 0);
00105     return nextcanal();
00106 }
00107 
00108 
00110 
00113 int selectcanalview::nextcanal() {
00114     _depura("selectcanalview::nextcanal", 0);
00115     int idcanal = 0;
00116     fprintf(stderr, "nextcanal\n");
00117     while ((**m_iterador) && idcanal == 0) {
00118         if ((**m_iterador)->checkState(0) == Qt::Checked) {
00119             idcanal = (**m_iterador)->text(3).toInt();
00120             fprintf(stderr, "siguiente canal:%d\n", idcanal);
00121             return idcanal;
00122         } // end if
00123         ++(*m_iterador);
00124     } // end while
00125 
00126     _depura("END selectcanalview::nextcanal", 0);
00127     return idcanal;
00128 }
00129 
00130 
00132 
00135 QString selectcanalview::cadcanal() {
00136     _depura("selectcanalview::cadcanal", 0);
00137 
00138     int idcanal;
00139     QString ccanales = "";
00140 
00141     idcanal = firstcanal();
00142     while (idcanal) {
00143         if (ccanales != "")
00144             ccanales.sprintf("%s, %d", ccanales.toAscii().constData(), idcanal);
00145         else
00146             ccanales.sprintf("%d", idcanal);
00147         idcanal = nextcanal();
00148     } // end while
00149 
00150     _depura("END selectcanalview::cadcanal", 0);
00151     return ccanales;
00152 }
00153 
00154 
00156 
00159 QString selectcanalview::nomcanal() {
00160     _depura("selectcanalview::nomcanal", 0);
00161     QTreeWidgetItemIterator m_iterador(m_listCanales);
00162     QString value= "";
00163 
00164     if ((*m_iterador)->checkState(0) == Qt::Checked) {
00165         value = (*m_iterador)->text(0);
00166     } // end if
00167 
00168     delete *m_iterador;
00169     _depura("END selectcanalview::nomcanal", 0);
00170     return value;
00171 }
00172 
00173 
00175 
00177 void selectcanalview::on_mui_todo_clicked() {
00178     _depura("selectcanalview::on_mui_todo_clicked", 0);
00179     QTreeWidgetItemIterator m_iterador(m_listCanales);
00180 
00181     while (*m_iterador) {
00182         (*m_iterador)->setCheckState(0, Qt::Checked);
00183         ++m_iterador;
00184     }
00185 
00186     delete *m_iterador;
00187     _depura("END selectcanalview::on_mui_todo_clicked", 0);
00188 }
00189 
00190 
00192 
00194 void selectcanalview::on_mui_nada_clicked() {
00195     _depura("selectcanalview::on_mui_nada_clicked", 0);
00196 
00197     QTreeWidgetItemIterator m_iterador(m_listCanales);
00198 
00199     while (*m_iterador) {
00200         (*m_iterador)->setCheckState(0, Qt::Unchecked);
00201         ++m_iterador;
00202     }
00203 
00204     delete *m_iterador;
00205     _depura("END selectcanalview::on_mui_nada_clicked", 0);
00206 }
00207 
00208 
00210 
00212 void selectcanalview::on_mui_invertir_clicked() {
00213     _depura("selectcanalview::on_mui_invertir_clicked", 0);
00214     QTreeWidgetItemIterator m_iterador(m_listCanales);
00215 
00216     while (*m_iterador) {
00217         if ((*m_iterador)->checkState(0) == Qt::Unchecked) {
00218             (*m_iterador)->setCheckState(0, Qt::Checked);
00219         } else {
00220             (*m_iterador)->setCheckState(0, Qt::Unchecked);
00221         } // end if
00222         ++m_iterador;
00223     } // end while
00224 
00225     delete *m_iterador;
00226     _depura("END selectcanalview::on_mui_invertir_clicked", 0);
00227 }
00228 

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