#include <subform2bc.h>
Inheritance diagram for QSubForm2BcDelegate:

Public Member Functions | |
| QSubForm2BcDelegate (QObject *) | |
| ~QSubForm2BcDelegate () | |
| void | setEditorData (QWidget *, const QModelIndex &index) const |
| void | setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const |
| QWidget * | createEditor (QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const |
| virtual bool | eventFilter (QObject *obj, QEvent *event) |
Private Attributes | |
| SubForm2Bc * | m_subform |
| Clase padre y acceso a base de datos. | |
Se encarga del control de los Widgets de Edicion del sistema.
Definition at line 37 of file subform2bc.h.
| QSubForm2BcDelegate::QSubForm2BcDelegate | ( | QObject * | parent = 0 |
) |
| parent |
Definition at line 454 of file subform2bc.cpp.
References _depura(), and m_subform.
00454 : QItemDelegate(parent), PEmpresaBase() { 00455 _depura("QSubForm2BcDelegate::QSubForm2BcDelegate", 0); 00456 m_subform = (SubForm2Bc *) parent; 00457 installEventFilter(this); 00458 _depura("END QSubForm2BcDelegate::QSubForm2BcDelegate", 0); 00459 }
| QSubForm2BcDelegate::~QSubForm2BcDelegate | ( | ) |
Definition at line 465 of file subform2bc.cpp.
References _depura().
00465 { 00466 _depura("QSubForm2BcDelegate::~QSubForm2BcDelegate", 0); 00467 _depura("END QSubForm2BcDelegate::~QSubForm2BcDelegate", 0); 00468 }
| void QSubForm2BcDelegate::setEditorData | ( | QWidget * | editor, | |
| const QModelIndex & | index | |||
| ) | const |
| editor | ||
| index |
DBint = 1, DBvarchar = 2, DBdate = 3, DBnumeric = 4, DBboolean
Definition at line 598 of file subform2bc.cpp.
References _depura(), SubForm3::cabecera(), m_subform, SHeader::nomcampo(), BusquedaCCosteDelegate::set(), BusquedaCanalDelegate::set(), and QDoubleSpinBox2::setValue().
00598 { 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 }
| void QSubForm2BcDelegate::setModelData | ( | QWidget * | editor, | |
| QAbstractItemModel * | model, | |||
| const QModelIndex & | index | |||
| ) | const |
| editor | ||
| model | ||
| index |
Si la fila o columna pasadas son invalidas salimos.
DBint = 1, DBvarchar = 2, DBdate = 3, DBnumeric = 4, DBboolean
Definition at line 528 of file subform2bc.cpp.
References _depura(), SubForm3::cabecera(), SubForm2Bc::empresaBase(), extiendecodigo(), m_subform, SHeader::nomcampo(), and Empresa::numdigitosempresa().
00528 { 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 }
| QWidget * QSubForm2BcDelegate::createEditor | ( | QWidget * | parent, | |
| const QStyleOptionViewItem & | option, | |||
| const QModelIndex & | index | |||
| ) | const |
| parent | ||
| index |
DBint = 1, DBvarchar = 2, DBdate = 3, DBnumeric = 4, DBboolean
Definition at line 476 of file subform2bc.cpp.
References _depura(), SubForm3::cabecera(), SubForm2Bc::empresaBase(), m_subform, and SHeader::nomcampo().
00476 { 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 }
| bool QSubForm2BcDelegate::eventFilter | ( | QObject * | obj, | |
| QEvent * | event | |||
| ) | [virtual] |
| obj | ||
| event |
Si es un release de tecla se hace la funcionalidad especificada.
Anulamos el caso de una pulsacion de tabulador o de enter
En caso de pulsacion de un retorno de carro o similar procesamos por nuestra cuenta.
Definition at line 657 of file subform2bc.cpp.
References _depura(), m_subform, Ui_SubForm3Base::mui_list, and TRUE.
00657 { 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 }
SubForm2Bc* QSubForm2BcDelegate::m_subform [private] |
Clase padre y acceso a base de datos.
Definition at line 40 of file subform2bc.h.
Referenced by createEditor(), eventFilter(), QSubForm2BcDelegate(), setEditorData(), and setModelData().
1.5.1