subform2bc.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 <QMessageBox>
00022 #include <QMenu>
00023 #include <QKeyEvent>
00024 #include <QEvent>
00025 #include <QLocale>
00026 
00027 #include "subform2bc.h"
00028 #include "funcaux.h"
00029 #include "empresa.h"
00030 #include "asiento1view.h"
00031 #include "extractoview1.h"
00032 #include "balance1view.h"
00033 #include "qtexteditdelegate.h"
00034 #include "qdoublespinbox2.h"
00035 #include "busquedacanal.h"
00036 #include "balanceview.h"
00037 
00038 
00040 
00043 SubForm2Bc::SubForm2Bc(QWidget *parent) : SubForm3(parent) {
00044     _depura("SubForm2Bc::SubForm2Bc", 0);
00045     m_delegate = new QSubForm2BcDelegate(this);
00046     mui_list->setItemDelegate(m_delegate);
00047     _depura("END SubForm2Bc::SubForm2Bc", 0);
00048 }
00049 
00050 
00052 
00054 SubForm2Bc::~SubForm2Bc() {
00055     _depura("SubForm2Bc::~SubForm2Bc", 0);
00056     delete m_delegate;
00057     _depura("END SubForm2Bc::~SubForm2Bc", 0);
00058 }
00059 
00060 
00062 
00065 void SubForm2Bc::setEmpresaBase(EmpresaBase *c) {
00066     _depura("SubForm2Bc::setEmpresaBase", 0);
00067     PEmpresaBase::setEmpresaBase(c);
00068     m_delegate->setEmpresaBase(c);
00069     _depura("END SubForm2Bc::setEmpresaBase", 0);
00070 }
00071 
00072 
00074 
00077 Empresa *SubForm2Bc::empresaBase() {
00078     _depura("SubForm2Bc::empresaBase", 0);
00079     _depura("END SubForm2Bc::empresaBase", 0);
00080     return ((Empresa *) PEmpresaBase::empresaBase());
00081 }
00082 
00083 
00085 
00090 void SubForm2Bc::on_mui_list_pressedAsterisk(int row, int col) {
00091     _depura ("SubForm2Bc::on_mui_list_pressedAsterisk", 0);
00092 
00093     SDBRecord *rec = lineaat(row);
00094     SDBCampo *camp = (SDBCampo *) item(row, col);
00096     if (camp->nomcampo() != "codigo" && camp->nomcampo() != "codigoctacliente")
00097         return;
00098 
00099     m_procesacambios = FALSE;
00100 
00102 
00103     mui_list->setCurrentCell(row, col +1);
00104     QDialog *diag = new QDialog(0);
00105     diag->setModal(true);
00109     listcuentasview1 *listcuentas = new listcuentasview1((Empresa *)empresaBase(), diag, 0, listcuentasview1::SelectMode);
00110     listcuentas->inicializa();
00111     connect(listcuentas, SIGNAL(selected(QString)), diag, SLOT(accept()));
00112 
00113     diag->exec();
00114     QString codigo = listcuentas->codcuenta();
00115     //delete diag;
00116 
00117     if (codigo != "") {
00118         QString query = "SELECT * FROM cuenta WHERE codigo = '" + codigo + "'";
00119         cursor2 *cur = empresaBase()->cargacursor(query);
00120         if (!cur->eof()) {
00121             if (camp->nomcampo() == "codigo") {
00122                 rec->setDBvalue("idcuenta", cur->valor("idcuenta"));
00123                 rec->setDBvalue("codigo", cur->valor("codigo"));
00124                 rec->setDBvalue("tipocuenta", cur->valor("tipocuenta"));
00125                 rec->setDBvalue("descripcion", cur->valor("descripcion"));
00126                 if (rec->exists("idc_coste") && cur->valor("idc_coste") != "") {
00127                     rec->setDBvalue("idc_coste", cur->valor("idc_coste"));
00128                     QString query1 = "SELECT * FROM c_coste WHERE idc_coste = " +cur->valor("idc_coste");
00129                     cursor2 *curss = empresaBase()->cargacursor(query1);
00130                     rec->setDBvalue("nomc_coste", curss->valor("nombre"));
00131                     delete curss;
00132                 } // end if
00133 
00134             } // end if
00135             if (camp->nomcampo() == "codigoctacliente") {
00136                 rec->setDBvalue("idctacliente", cur->valor("idcuenta"));
00137                 rec->setDBvalue("codigoctacliente", cur->valor("codigo"));
00138                 rec->setDBvalue("tipoctacliente", cur->valor("tipocuenta"));
00139                 rec->setDBvalue("nomctacliente", cur->valor("descripcion"));
00140 
00141             } // end if
00142         } // end if
00143         delete cur;
00144     } // end if
00145 
00146     m_procesacambios = TRUE;
00148     on_mui_list_cellChanged(row, col);
00149     _depura ("END SubForm2Bc::on_mui_list_pressedAsterisk", 0);
00150 }
00151 
00152 
00154 
00159 void SubForm2Bc::on_mui_list_pressedSlash(int row, int col) {
00160     _depura("SubForm2Bc::on_mui_list_pressedSlash", 2);
00161     SDBCampo *camp = (SDBCampo *) item(row, col);
00162     if (camp->nomcampo() == "fecha") {
00163         if (row > 0) {
00164                 SDBCampo *campoant = (SDBCampo *) item(row - 1, col);
00165                 camp->set(campoant->text());
00166         } // end if
00167         return;
00168     } // end if
00169     if (camp->nomcampo() == "descripcion") {
00170         if (row > 0) {
00171                 SDBCampo *campoant = (SDBCampo *) item(row - 1, col);
00172                 camp->set(campoant->text());
00173         } // end if
00174         return;
00175     } // end if
00176     if (camp->nomcampo() == "conceptocontable") {
00177         if (row > 0) {
00178                 SDBCampo *campoant = (SDBCampo *) item(row - 1, col);
00179                 camp->set(campoant->text());
00180         } // end if
00181         return;
00182     } // end if
00183     QString text = editaTexto(camp->text());
00184     camp->set(text);
00185     _depura("END SubForm2Bc::on_mui_list_pressedSlash", 2);
00186 }
00187 
00188 
00190 
00195 void SubForm2Bc::on_mui_list_cellChanged(int row, int col) {
00196     _depura("SubForm2Bc::on_mui_list_cellChanged", 0, "Row: "+ QString::number(row) + " Col: "+QString::number(col));
00197 
00199     if (!m_procesacambios) {
00200         _depura("SubForm2Bc::on_mui_list_cellChanged", 0, QString::number(row) + " " + QString::number(col)+" m_procesacambios es FALSE");
00201         return;
00202     } // end if
00203 
00204     m_procesacambios = FALSE;
00205 
00207     int res = g_plugins->lanza("SubForm2Bc_on_mui_list_cellChanged", this);
00208     if (res != 0) {
00209         m_procesacambios = TRUE;
00210         return;
00211     } // end if
00212 
00213     SDBRecord *rec = lineaat(row);
00214     if (rec == NULL) {
00215         _depura ("END SubForm2Bc::on_mui_list_cellChanged", 0, QString::number(row) + " " + QString::number(col)+ "la linea no existe");
00216         m_procesacambios = TRUE;
00217         return;
00218     }
00219 
00220 
00222     SDBCampo *camp = (SDBCampo *) item(row, col);
00223     camp->refresh();
00224 
00225 
00227     if (!camp->cambiado()) {
00228         _depura ("END SubForm2Bc::on_mui_list_cellChanged", 0, QString::number(row) + " " + QString::number(col)+ "Sin cambios");
00229         SubForm3::on_mui_list_cellChanged(row, col);
00230         m_procesacambios = TRUE;
00231         return;
00232     } // end if
00233 
00234     if (camp->nomcampo() == "codigo" && camp->text() != "*") {
00235         QString codigoext = extiendecodigo(camp->text(), ((Empresa *) empresaBase())->numdigitosempresa());
00236         QString query = "SELECT idcuenta, codigo, tipocuenta, descripcion, idc_coste FROM cuenta WHERE codigo = '" + codigoext + "'";
00237         cursor2 *cur = empresaBase()->cargacursor(query);
00238         if (!cur->eof() ) {
00239             rec->setDBvalue("idcuenta", cur->valor("idcuenta"));
00240             rec->setDBvalue("codigo", cur->valor("codigo"));
00241             rec->setDBvalue("tipocuenta", cur->valor("tipocuenta"));
00242             rec->setDBvalue("descripcioncuenta", cur->valor("descripcion"));
00243             if (rec->exists("idc_coste") && cur->valor("idc_coste") != "") {
00244                 rec->setDBvalue("idc_coste", cur->valor("idc_coste"));
00245                 QString query1 = "SELECT * FROM c_coste WHERE idc_coste = " +cur->valor("idc_coste");
00246                 cursor2 *curss = empresaBase()->cargacursor(query1);
00247                 rec->setDBvalue("nomc_coste", curss->valor("nombre"));
00248                 delete curss;
00249             } // end if
00250         } else {
00251             _depura("No existe cuenta", 2);
00252             return;
00253         } // end if
00254         delete cur;
00255     } // end if
00256     if (camp->nomcampo() == "nomcanal") {
00257         QString query = "SELECT idcanal FROM canal WHERE nombre = '" + camp->text() + "'";
00258         cursor2 *cur = empresaBase()->cargacursor(query);
00259         if (!cur->eof() ) {
00260             rec->setDBvalue("idcanal", cur->valor("idcanal"));
00261         } else {
00262             rec->setDBvalue("idcanal", "");
00263         } // end if
00264         delete cur;
00265     } // end if
00266     if (camp->nomcampo() == "nomc_coste") {
00267         QString query = "SELECT idc_coste FROM c_coste WHERE nombre = '" + camp->text() + "'";
00268         cursor2 *cur = empresaBase()->cargacursor(query);
00269         if (!cur->eof() ) {
00270             rec->setDBvalue("idc_coste", cur->valor("idc_coste"));
00271         } else {
00272             rec->setDBvalue("idc_coste", "");
00273         } // end if
00274         delete cur;
00275     } // end if
00276     if (camp->nomcampo() == "fecha") {
00277         QString nfecha = normalizafecha(camp->text()).toString("dd/MM/yyyy");
00278         rec->setDBvalue("fecha", nfecha);
00279     } // end if
00280     if (camp->nomcampo() == "debe") {
00281         if (Fixed(camp->text()) != Fixed("0.00")) {
00282             rec->setDBvalue("haber", "0.00");
00283         } // end if
00284     } // end if
00285     if (camp->nomcampo() == "haber") {
00286         if (Fixed(camp->text()) != Fixed("0.00")) {
00287             rec->setDBvalue("debe", "0.00");
00288         } // end if
00289     } // end if
00290 
00291     g_plugins->lanza("SubForm2Bc_on_mui_list_cellChanged_post", this);
00292 
00293     SubForm3::on_mui_list_cellChanged(row, col);
00294     m_procesacambios = TRUE;
00295     _depura("END SubForm2Bc::on_mui_list_cellChanged", 0);
00296 }
00297 
00298 
00300 
00302 void SubForm2Bc::boton_asiento() {
00303     _depura("SubForm2Bc::boton_asiento", 0);
00304     Empresa *companyact = (Empresa *) empresaBase();
00305     QString numasiento = DBvalue("idasiento");
00306     if (numasiento != "") {
00307         companyact->intapuntsempresa()->muestraasiento(numasiento.toInt());
00308         companyact->muestraapuntes1();
00309     } // end if
00310     _depura("END SubForm2Bc::boton_asiento", 0);
00311 }
00312 
00313 
00318 
00321 void SubForm2Bc::boton_extracto1(int tipo) {
00322     _depura("SubForm2Bc::boton_extracto1", 0);
00323     Empresa *companyact = (Empresa *) empresaBase();
00324     QDate fecha1, fecha2, fechaact;
00325     QString fecha = DBvalue("fecha").left(10);
00326     QString codigo = DBvalue("codigo");
00327     if (fecha != "" && codigo != "") {
00328         fechaact = normalizafecha(fecha);
00329         switch (tipo) {
00330         case 0:
00331             fecha1.setYMD(fechaact.year(), fechaact.month(), fechaact.day());
00332             fecha2.setYMD(fechaact.year(), fechaact.month(), fechaact.day());
00333             break;
00334         case 1:
00335             fecha1.setYMD(fechaact.year(), fechaact.month(), 1);
00336             fecha2.setYMD(fechaact.year(), fechaact.month(), fechaact.daysInMonth());
00337             break;
00338         case 2:
00339             fecha1.setYMD(fechaact.year(), 1, 1);
00340             fecha2.setYMD(fechaact.year(), 12, 31);
00341             break;
00342         } // end switch
00343         companyact->extractoempresa()->inicializa1(codigo, codigo, fecha1.toString("dd/MM/yyyy"), fecha2.toString("dd/MM/yyyy"), 0);
00344         companyact->extractoempresa()->accept();
00345         companyact->libromayor();
00346     } // end if
00347     _depura("END SubForm2Bc::boton_extracto1", 0);
00348 }
00349 
00350 
00355 
00358 void SubForm2Bc::boton_diario1(int tipo) {
00359     _depura("SubForm2Bc::boton_diario1", 0);
00360     Empresa *companyact = (Empresa *) empresaBase();
00361     QDate fecha1, fecha2, fechaact, fechaact1;
00362     fechaact = normalizafecha(DBvalue("fecha").left(10));
00363     fechaact1 = normalizafecha(DBvalue("fecha").left(10));
00364     if (DBvalue("fecha").left(10) != "") {
00365         switch (tipo) {
00366         case 0:
00367             fecha1.setYMD(fechaact.year(), fechaact.month(), fechaact.day());
00368             fecha2.setYMD(fechaact1.year(), fechaact1.month(), fechaact1.day());
00369             break;
00370         case 1:
00371             fecha1.setYMD(fechaact.year(), fechaact.month(), 1);
00372             fecha2.setYMD(fechaact.year(), fechaact.month(), fechaact.daysInMonth());
00373             break;
00374         case 2:
00375             fecha1.setYMD(fechaact.year(), 1, 1);
00376             fecha2.setYMD(fechaact.year(), 12, 31);
00377             break;
00378         } // end switch
00379         companyact->diarioempresa()->inicializa1((char *) fecha1.toString("dd/MM/yyyy").toAscii().constData(), (char *) fecha2.toString("dd/MM/yyyy").toAscii().constData(), 0);
00380     } // end if
00381     companyact->diarioempresa()->accept();
00382     companyact->librodiario();
00383     _depura("SubForm2Bc::boton_diario1", 0);
00384 }
00385 
00386 
00391 
00394 void SubForm2Bc::boton_balance1(int tipo) {
00395     _depura("SubForm2Bc::boton_balance1", 0);
00396     Empresa *companyact = (Empresa *) empresaBase();
00397     QString fecha = DBvalue("fecha").left(10);
00398     QString codigo = DBvalue("codigo");
00399     QDate fecha1, fecha2, fechaact, fechaact1;
00400     if (fecha != "" && codigo != "") {
00401         fechaact = normalizafecha(fecha);
00402         switch (tipo) {
00403         case 0:
00404             fecha1.setYMD(fechaact.year(), fechaact.month(), fechaact.day());
00405             fecha2.setYMD(fechaact1.year(), fechaact.month(), fechaact.day());
00406             break;
00407         case 1:
00408             fecha1.setYMD(fechaact.year(), fechaact.month(), 1);
00409             fecha2.setYMD(fechaact.year(), fechaact.month(), fechaact.daysInMonth());
00410             break;
00411         case 2:
00412             fecha1.setYMD(fechaact.year(), 1, 1);
00413             fecha2.setYMD(fechaact.year(), 12, 31);
00414             break;
00415         } // end switch
00416         empresaBase()->balanceempresa()->inicializa1(codigo, codigo, fecha1.toString("dd/MM/yyyy"), fecha2.toString("dd/MM/yyyy"), "0");
00417         companyact->balanceempresa()->accept();
00418         companyact->librobalance();
00419     } // end if
00420     _depura("END SubForm2Bc::boton_balance1", 0);
00421 }
00422 
00423 
00424 
00427 
00430 void SubForm2Bc::creaMenu(QMenu *menu) {
00431     _depura("SubForm2Bc::pintaMenu", 0);
00432     menu->addAction(tr("Submenu de contabilidad"));
00433     menu->addSeparator();
00434     _depura("END SubForm2Bc::pintaMenu", 0);
00435 }
00436 
00437 
00439 
00441 void SubForm2Bc::procesaMenu(QAction *) {
00442     _depura("SubForm2Bc::procesaMenu", 0);
00443     _depura("END SubForm2Bc::procesaMenu", 0);
00444 }
00445 
00446 
00451 
00454 QSubForm2BcDelegate::QSubForm2BcDelegate(QObject *parent = 0) : QItemDelegate(parent), PEmpresaBase() {
00455     _depura("QSubForm2BcDelegate::QSubForm2BcDelegate", 0);
00456     m_subform = (SubForm2Bc *) parent;
00457     installEventFilter(this);
00458     _depura("END QSubForm2BcDelegate::QSubForm2BcDelegate", 0);
00459 }
00460 
00461 
00463 
00465 QSubForm2BcDelegate::~QSubForm2BcDelegate() {
00466     _depura("QSubForm2BcDelegate::~QSubForm2BcDelegate", 0);
00467     _depura("END QSubForm2BcDelegate::~QSubForm2BcDelegate", 0);
00468 }
00469 
00470 
00472 
00476 QWidget *QSubForm2BcDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const {
00477     _depura("QSubForm2BcDelegate::createEditor", 0);
00478     SHeader *linea;
00479     linea = m_subform->cabecera()->at(index.column());
00480     _depura("QSubForm2BcDelegate::createEditor", 0, "CurrentColumn: " + QString::number(index.column()));
00481     _depura("QSubForm2BcDelegate::createEditor", 0, "CurrentRow: " + QString::number(index.row()));
00482 
00483     if (linea->nomcampo().startsWith("desc")) {
00484         QTextEditDelegate *editor = new QTextEditDelegate(parent);
00485         editor->setObjectName("QTextEditDelegate");
00486         return editor;
00487     } else if (linea->nomcampo() == "debe" || linea->nomcampo() == "haber") {
00488         QDoubleSpinBox2 *editor = new QDoubleSpinBox2(parent);
00489         editor->setMinimum(-1000000);
00490         editor->setMaximum(1000000);
00491         return editor;
00492     } else if (linea->nomcampo() == "codigo") {
00493         BusquedaCuentaDelegate *editor = new BusquedaCuentaDelegate(parent);
00494         editor->setEmpresaBase((Empresa *)m_subform->empresaBase());
00495         return editor;
00496     } else if (linea->nomcampo() == "nomcanal") {
00497         BusquedaCanalDelegate *editor = new BusquedaCanalDelegate(parent);
00498         editor->setEmpresaBase(m_subform->empresaBase());
00499         return editor;
00500     } else if (linea->nomcampo() == "nomc_coste") {
00501         BusquedaCCosteDelegate *editor = new BusquedaCCosteDelegate(parent);
00502         editor->setEmpresaBase(m_subform->empresaBase());
00503         return editor;
00504     } else if (linea->nomcampo().startsWith("fecha")) {
00505         BusquedaFecha2 *editor = new BusquedaFecha2(parent);
00506         return editor;
00507     } else {
00509         //if (linea->tipo() == DBCampo::DBint) {
00510         //QSpinBox *editor = new QSpinBox(parent);
00511         //return editor;
00512         QLineEdit *editor = new QLineEdit(parent);
00513         return editor;
00514         //} else {
00515         //    return QItemDelegate::createEditor(parent, option, index);
00516         //} // end if
00517     } // end if
00518 }
00519 
00520 
00522 
00528 void QSubForm2BcDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const {
00529     _depura("QSubForm2BcDelegate::setModelData", 0);
00530     _depura("QSubForm2BcDelegate::setModelData", 0, "CurrentColumn: " + QString::number(index.column()));
00531     _depura("QSubForm2BcDelegate::setModelData", 0, "CurrentRow: " + QString::number(index.row()));
00532 
00534     if (index.column() < 0 || index.row() < 0)
00535         return;
00536 
00537     SHeader *linea;
00538     linea = m_subform->cabecera()->at(index.column());
00539     if (linea->nomcampo().startsWith("desc")) {
00540 
00541 //    if (linea->nomcampo() == "desc" + m_subform->tableName()) {
00542         QTextEditDelegate *textedit = qobject_cast<QTextEditDelegate *>(editor);
00543         model->setData(index, textedit->toPlainText());
00544         return;
00545 
00546         // TODO: 04/05/07 Se quita esta linea porque hacia que los valores en la celda "haber" no apareciese
00547         //        con decimales. Ademas no se que es lo que tiene que hacer
00548         //
00549         //    } else if (linea->nomcampo() == "debe" || linea->nomcampo() == "haber" + m_subform->tableName()) {
00550     } else if (linea->nomcampo() == "debe" || linea->nomcampo() == "haber") {
00551         QDoubleSpinBox2 *spinBox = static_cast<QDoubleSpinBox2*>(editor);
00552         spinBox->interpretText();
00553         QString value = spinBox->text();
00554         model->setData(index, value);
00555     } else if (linea->nomcampo() == "codigo") {
00556         BusquedaCuentaDelegate *comboBox = static_cast<BusquedaCuentaDelegate*>(editor);
00557         QString value = comboBox->currentText();
00558         value = value.left(value.indexOf(".-"));
00559         QString codigoext = extiendecodigo(value,  m_subform->empresaBase()->numdigitosempresa());
00560         model->setData(index, codigoext);
00561     } else if (linea->nomcampo() == "nomcanal") {
00562         BusquedaCanalDelegate *comboBox = static_cast<BusquedaCanalDelegate*>(editor);
00563         QString value = comboBox->currentText();
00564         model->setData(index, value);
00565     } else if (linea->nomcampo() == "nomc_coste") {
00566         BusquedaCCosteDelegate *comboBox = static_cast<BusquedaCCosteDelegate*>(editor);
00567         QString value = comboBox->currentText();
00568         model->setData(index, value);
00569     } else if (linea->nomcampo().startsWith("fecha")) {
00570         BusquedaFecha2 *comboBox = static_cast<BusquedaFecha2*>(editor);
00571         QString value = ((QLineEdit *)comboBox)->text();
00572         model->setData(index, value);
00573     } else {
00575         //if (linea->tipo() == DBCampo::DBint) {
00576         //    QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
00577         //    spinBox->interpretText();
00578         //    int value = spinBox->value();
00579         //    model->setData(index, value);
00580         //} else {
00581         //    QItemDelegate::setModelData(editor, model, index);
00582         //} // end if
00583         QLineEdit *lineedit = static_cast<QLineEdit*>(editor);
00584         QString value = lineedit->text();
00585         model->setData(index, value);
00586     } // end if
00587 
00588 
00589     _depura("END QSubForm2BcDelegate::setModelData", 0);
00590 }
00591 
00592 
00594 
00598 void QSubForm2BcDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const {
00599     _depura("QSubForm2BcDelegate::setEditorData", 0);
00600     _depura("QSubForm2BcDelegate::setEditorData", 0, "CurrentColumn: " + QString::number(index.column()));
00601     _depura("QSubForm2BcDelegate::setEditorData", 0, "CurrentRow: " + QString::number(index.row()));
00602     SHeader *linea;
00603     linea = m_subform->cabecera()->at(index.column());
00604     //if (linea->nomcampo() == "desc" + m_subform->tableName()) {
00605     if (linea->nomcampo().startsWith("desc")) {
00606         QString data = index.model()->data(index, Qt::DisplayRole).toString();
00607         QTextEditDelegate *textedit = qobject_cast<QTextEditDelegate*>(editor);
00608         textedit->setText(data);
00609         textedit->selectAll();
00610     } else if (linea->nomcampo() == "debe" || linea->nomcampo() == "haber") {
00611         QString value = index.model()->data(index, Qt::DisplayRole).toString();
00612         QDoubleSpinBox2 *spinBox = static_cast<QDoubleSpinBox2*>(editor);
00613         spinBox->setValue(value.toDouble());
00614         spinBox->selectAll();
00615     } else if (linea->nomcampo() == "codigo") {
00616         QString value = index.model()->data(index, Qt::DisplayRole).toString();
00617         BusquedaCuentaDelegate *comboBox = static_cast<BusquedaCuentaDelegate*>(editor);
00618         comboBox->addItem(value);
00619         //comboBox->lineEdit()->setText(value);
00620         comboBox->lineEdit()->selectAll();
00621     } else if (linea->nomcampo() == "nomcanal") {
00622         QString value = index.model()->data(index, Qt::DisplayRole).toString();
00623         BusquedaCanalDelegate *comboBox = static_cast<BusquedaCanalDelegate*>(editor);
00624         comboBox->set(value);
00625     } else if (linea->nomcampo() == "nomc_coste") {
00626         QString value = index.model()->data(index, Qt::DisplayRole).toString();
00627         BusquedaCCosteDelegate *comboBox = static_cast<BusquedaCCosteDelegate*>(editor);
00628         comboBox->set(value);
00629     } else if (linea->nomcampo().startsWith("fecha")) {
00630         QString value = index.model()->data(index, Qt::DisplayRole).toString();
00631         BusquedaFecha2 *bf = static_cast<BusquedaFecha2*>(editor);
00632         ((QLineEdit *)bf)->setText(value);
00633         ((QLineEdit *)bf)->selectAll();
00634     } else {
00636         //if (linea->tipo() == DBCampo::DBint) {
00637         //    int value = index.model()->data(index, Qt::DisplayRole).toInt();
00638         //    QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
00639         //    spinBox->setValue(value);
00640         //} else {
00641         //    QItemDelegate::setEditorData(editor, index);
00642         //} // end if
00643         QString value = index.model()->data(index, Qt::DisplayRole).toString();
00644         QLineEdit *lineedit = static_cast<QLineEdit*>(editor);
00645         lineedit->setText(value);
00646     } // end if
00647     _depura("END QSubForm2BcDelegate::setEditorData", 0);
00648 }
00649 
00650 
00652 
00657 bool QSubForm2BcDelegate::eventFilter(QObject *obj, QEvent *event) {
00659     if (event->type() == QEvent::KeyPress) {
00660         _depura("QSubForm2BcDelegate::eventFilter", 0, obj->objectName() + " --> " + QString::number(event->type()));
00661         QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
00662         int key = keyEvent->key();
00663         _depura("QSubForm2BcDelegate::key = : ", 0, QString::number(key));
00664         Qt::KeyboardModifiers mod = keyEvent->modifiers();
00666         switch (key) {
00667         case Qt::Key_Return:
00668         case Qt::Key_Enter:
00669             if (obj->objectName() == "QTextEditDelegate") {
00670                 obj->event(event);
00671                 return TRUE;
00672             } // end if
00673         case Qt::Key_Tab:
00674             return TRUE;
00675         } // end switch
00676         return QItemDelegate::eventFilter(obj, event);
00677     } // end if
00678 
00679     if (event->type() == QEvent::KeyRelease) {
00680         _depura("QSubForm2BcDelegate::eventFilter", 0, obj->objectName() + " --> " + QString::number(event->type()));
00681         QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
00682         int key = keyEvent->key();
00683         _depura("QSubForm2BcDelegate::key = : ", 0, QString::number(key));
00684         Qt::KeyboardModifiers mod = keyEvent->modifiers();
00686         switch (key) {
00687         case Qt::Key_Return:
00688         case Qt::Key_Enter:
00689             if (obj->objectName() == "QTextEditDelegate") {
00690                 obj->event(event);
00691                 return TRUE;
00692             } // end if
00693         case Qt::Key_Tab:
00694             QApplication::sendEvent(m_subform->mui_list, event);
00695             return TRUE;
00696         } // end switch
00697         return QItemDelegate::eventFilter(obj, event);
00698     } // end if
00699 
00700     return QItemDelegate::eventFilter(obj, event);
00701 }
00702 
00703 

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