#include <subform2bt.h>
Inheritance diagram for QSubForm2BtDelegate:

Public Member Functions | |
| QSubForm2BtDelegate (QObject *) | |
| virtual | ~QSubForm2BtDelegate () |
| virtual void | setEditorData (QWidget *, const QModelIndex &index) const |
| virtual void | setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const |
| virtual QWidget * | createEditor (QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const |
| virtual bool | eventFilter (QObject *obj, QEvent *event) |
| virtual int | cerrarEditor (QWidget *editor) |
Protected Attributes | |
| SubForm2Bt * | m_subform |
Se encarga del control de los 'Widgets' de edición del sistema.
Definition at line 40 of file subform2bt.h.
| QSubForm2BtDelegate::QSubForm2BtDelegate | ( | QObject * | parent = 0 |
) |
| parent |
Definition at line 262 of file subform2bt.cpp.
References _depura(), and m_subform.
00262 : QItemDelegate(parent), PEmpresaBase() { 00263 _depura("QSubForm2BtDelegate::QSubForm2BtDelegate", 0); 00264 m_subform = (SubForm2Bt *) parent; 00265 installEventFilter(this); 00266 _depura("END QSubForm2BtDelegate::QSubForm2BtDelegate", 0); 00267 }
| QSubForm2BtDelegate::~QSubForm2BtDelegate | ( | ) | [virtual] |
Definition at line 273 of file subform2bt.cpp.
References _depura().
00273 { 00274 _depura("QSubForm2BtDelegate::~QSubForm2BtDelegate", 0); 00275 _depura("END QSubForm2BtDelegate::~QSubForm2BtDelegate", 0); 00276 }
| void QSubForm2BtDelegate::setEditorData | ( | QWidget * | editor, | |
| const QModelIndex & | index | |||
| ) | const [virtual] |
| editor | ||
| index |
Definition at line 403 of file subform2bt.cpp.
References _depura(), SubForm3::cabecera(), m_subform, SHeader::nomcampo(), QDoubleSpinBox2::setValue(), and SubForm3::tableName().
00403 { 00404 _depura("QSubForm2BtDelegate::setEditorData", 0); 00405 _depura("QSubForm2BtDelegate::setEditorData", 0, "CurrentColumn: " + QString::number(index.column())); 00406 _depura("QSubForm2BtDelegate::setEditorData", 0, "CurrentRow: " + QString::number(index.row())); 00407 SHeader *linea; 00408 linea = m_subform->cabecera()->at(index.column()); 00409 if (linea->nomcampo() == "desc" + m_subform->tableName()) { 00410 QString data = index.model()->data(index, Qt::DisplayRole).toString(); 00411 QTextEditDelegate *textedit = qobject_cast<QTextEditDelegate*>(editor); 00412 textedit->setText(data); 00413 00414 } else if (linea->nomcampo() == "cant" + m_subform->tableName() 00415 || linea->nomcampo() == "pvp" + m_subform->tableName() 00416 || linea->nomcampo() == "descuento" + m_subform->tableName() 00417 || linea->nomcampo() == "reqeq" + m_subform->tableName() 00418 || linea->nomcampo() == "iva" + m_subform->tableName()) { 00419 00420 QString value = index.model()->data(index, Qt::DisplayRole).toString(); 00421 QDoubleSpinBox2 *spinBox = static_cast<QDoubleSpinBox2*>(editor); 00422 spinBox->setValue(value.toDouble()); 00423 spinBox->selectAll(); 00424 00425 /* 00426 } else if (linea->nomcampo() == "codigocompletoarticulo") { 00427 QString value = index.model()->data(index, Qt::DisplayRole).toString(); 00428 BusquedaArticuloDelegate *comboBox = static_cast<BusquedaArticuloDelegate*>(editor); 00429 comboBox->addItem(value); 00430 } else if (linea->nomcampo() == "desctipo_iva") { 00431 QString value = index.model()->data(index, Qt::DisplayRole).toString(); 00432 BusquedaTipoIVADelegate *comboBox = static_cast<BusquedaTipoIVADelegate*>(editor); 00433 comboBox->set(value); 00434 } else if (linea->nomcampo() == "nomtrabajador") { 00435 QString value = index.model()->data(index, Qt::DisplayRole).toString(); 00436 BusquedaTrabajadorDelegate *comboBox = static_cast<BusquedaTrabajadorDelegate*>(editor); 00437 comboBox->set(value); 00438 } else if (linea->nomcampo() == "nomalmacen") { 00439 QString value = index.model()->data(index, Qt::DisplayRole).toString(); 00440 BusquedaAlmacenDelegate *comboBox = static_cast<BusquedaAlmacenDelegate*>(editor); 00441 comboBox->set(value); 00442 */ 00443 } else { 00444 QItemDelegate::setEditorData(editor, index); 00445 } // end if 00446 _depura("END QSubForm2BtDelegate::setEditorData", 0); 00447 }
| void QSubForm2BtDelegate::setModelData | ( | QWidget * | editor, | |
| QAbstractItemModel * | model, | |||
| const QModelIndex & | index | |||
| ) | const [virtual] |
| editor | ||
| model | ||
| index |
Si la fila o columna pasadas son inválidas salimos.
Definition at line 346 of file subform2bt.cpp.
References _depura(), SubForm3::cabecera(), m_subform, SHeader::nomcampo(), and SubForm3::tableName().
00346 { 00347 _depura("QSubForm2BtDelegate::setModelData", 0); 00348 _depura("QSubForm2BtDelegate::setModelData", 0, "CurrentColumn: " + QString::number(index.column())); 00349 _depura("QSubForm2BtDelegate::setModelData", 0, "CurrentRow: " + QString::number(index.row())); 00350 00352 if (index.column() < 0 || index.row() < 0) 00353 return; 00354 00355 SHeader *linea; 00356 linea = m_subform->cabecera()->at(index.column()); 00357 if (linea->nomcampo() == "desc" + m_subform->tableName()) { 00358 QTextEditDelegate *textedit = qobject_cast<QTextEditDelegate *>(editor); 00359 model->setData(index, textedit->toPlainText()); 00360 return; 00361 00362 } else if (linea->nomcampo() == "cant" + m_subform->tableName() 00363 || linea->nomcampo() == "pvp" + m_subform->tableName() 00364 || linea->nomcampo() == "descuento" + m_subform->tableName() 00365 || linea->nomcampo() == "reqeq" + m_subform->tableName() 00366 || linea->nomcampo() == "iva" + m_subform->tableName()) { 00367 00368 QDoubleSpinBox2 *spinBox = static_cast<QDoubleSpinBox2*>(editor); 00369 spinBox->interpretText(); 00370 QString value = spinBox->text(); 00371 model->setData(index, value); 00372 /* 00373 } else if (linea->nomcampo() == "codigocompletoarticulo") { 00374 BusquedaArticuloDelegate *comboBox = static_cast<BusquedaArticuloDelegate*>(editor); 00375 QString value = comboBox->currentText(); 00376 value = value.left(value.indexOf(".-")); 00377 model->setData(index, value); 00378 } else if (linea->nomcampo() == "desctipo_iva") { 00379 BusquedaTipoIVADelegate *comboBox = static_cast<BusquedaTipoIVADelegate*>(editor); 00380 QString value = comboBox->currentText(); 00381 model->setData(index, value); 00382 } else if (linea->nomcampo() == "nomtrabajador") { 00383 BusquedaTrabajadorDelegate *comboBox = static_cast<BusquedaTrabajadorDelegate*>(editor); 00384 QString value = comboBox->currentText(); 00385 model->setData(index, value); 00386 } else if (linea->nomcampo() == "nomalmacen") { 00387 BusquedaAlmacenDelegate *comboBox = static_cast<BusquedaAlmacenDelegate*>(editor); 00388 QString value = comboBox->currentText(); 00389 model->setData(index, value); 00390 */ 00391 } else { 00392 QItemDelegate::setModelData(editor, model, index); 00393 } // end if 00394 _depura("END QSubForm2BtDelegate::setModelData", 0); 00395 }
| QWidget * QSubForm2BtDelegate::createEditor | ( | QWidget * | parent, | |
| const QStyleOptionViewItem & | option, | |||
| const QModelIndex & | index | |||
| ) | const [virtual] |
| parent | ||
| option | ||
| index |
Definition at line 285 of file subform2bt.cpp.
References _depura(), SubForm3::cabecera(), m_subform, SHeader::nomcampo(), and SubForm3::tableName().
00285 { 00286 _depura("QSubForm2BtDelegate::createEditor", 0); 00287 SHeader *linea; 00288 linea = m_subform->cabecera()->at(index.column()); 00289 _depura("QSubForm2BtDelegate::createEditor", 0, "CurrentColumn: " + QString::number(index.column())); 00290 _depura("QSubForm2BtDelegate::createEditor", 0, "CurrentRow" + QString::number(index.row())); 00291 00292 if (linea->nomcampo() == "desc" + m_subform->tableName()) { 00293 QTextEditDelegate *editor = new QTextEditDelegate(parent); 00294 editor->setObjectName("QTextEditDelegate"); 00295 return editor; 00296 00297 } else if (linea->nomcampo() == "cant" + m_subform->tableName() 00298 || linea->nomcampo() == "pvp" + m_subform->tableName() 00299 || linea->nomcampo() == "descuento" + m_subform->tableName() 00300 || linea->nomcampo() == "iva" + m_subform->tableName() 00301 || linea->nomcampo() == "reqeq" + m_subform->tableName()) { 00302 00303 QDoubleSpinBox2 *editor = new QDoubleSpinBox2(parent); 00304 editor->setMinimum(-1000000); 00305 editor->setMaximum(1000000); 00306 return editor; 00307 00308 /* 00309 } else if (linea->nomcampo() == "codigocompletoarticulo") { 00310 BusquedaArticuloDelegate *editor = new BusquedaArticuloDelegate(parent); 00311 editor->setEmpresaBase((Company *)m_subform->empresaBase()); 00312 return editor; 00313 } else if (linea->nomcampo() == "desctipo_iva") { 00314 BusquedaTipoIVADelegate *editor = new BusquedaTipoIVADelegate(parent); 00315 editor->setEmpresaBase((Company *)m_subform->empresaBase()); 00316 return editor; 00317 } else if (linea->nomcampo() == "nomtrabajador") { 00318 BusquedaTrabajadorDelegate *editor = new BusquedaTrabajadorDelegate(parent); 00319 editor->setEmpresaBase((Company *)m_subform->empresaBase()); 00320 return editor; 00321 } else if (linea->nomcampo() == "nomalmacen") { 00322 BusquedaAlmacenDelegate *editor = new BusquedaAlmacenDelegate(parent); 00323 editor->setEmpresaBase((Company *)m_subform->empresaBase()); 00324 return editor; 00325 } else { 00326 // QWidget *it = QItemDelegate::createEditor(parent, option, index); 00327 // if (linea->tipo() == DBint) { 00329 // } else { 00330 00331 // } // end if 00332 */ 00333 return QItemDelegate::createEditor(parent, option, index); 00334 } // end if 00335 _depura("END QSubForm2BtDelegate::createEditor", 0); 00336 }
| bool QSubForm2BtDelegate::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 456 of file subform2bt.cpp.
References _depura(), m_subform, Ui_SubForm3Base::mui_list, and TRUE.
00456 { 00458 if (event->type() == QEvent::KeyPress) { 00459 _depura("QSubForm2BtDelegate::eventFilter", 0, obj->objectName() + " --> " + QString::number(event->type())); 00460 QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); 00461 int key = keyEvent->key(); 00462 _depura("QSubForm2BtDelegate::key = : ", 0, QString::number(key)); 00463 Qt::KeyboardModifiers mod = keyEvent->modifiers(); 00465 switch (key) { 00466 case Qt::Key_Return: 00467 case Qt::Key_Enter: 00468 if (obj->objectName() == "QTextEditDelegate") { 00469 obj->event(event); 00470 return TRUE; 00471 } // end if 00472 case Qt::Key_Tab: 00473 return TRUE; 00474 } // end switch 00475 return QItemDelegate::eventFilter(obj, event); 00476 } // end if 00477 00478 if (event->type() == QEvent::KeyRelease) { 00479 _depura("QSubForm2BtDelegate::eventFilter", 0, obj->objectName() + " --> " + QString::number(event->type())); 00480 QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); 00481 int key = keyEvent->key(); 00482 _depura("QSubForm2BtDelegate::key = : ", 0, QString::number(key)); 00483 Qt::KeyboardModifiers mod = keyEvent->modifiers(); 00485 switch (key) { 00486 case Qt::Key_Return: 00487 case Qt::Key_Enter: 00488 if (obj->objectName() == "QTextEditDelegate") { 00489 obj->event(event); 00490 return TRUE; 00491 } // end if 00492 case Qt::Key_Tab: 00493 QApplication::sendEvent(m_subform->mui_list, event); 00494 return TRUE; 00495 } // end switch 00496 return QItemDelegate::eventFilter(obj, event); 00497 } // end if 00498 00499 return QItemDelegate::eventFilter(obj, event); 00500 }
| int QSubForm2BtDelegate::cerrarEditor | ( | QWidget * | editor | ) | [virtual] |
| editor |
Definition at line 508 of file subform2bt.cpp.
References _depura().
Referenced by SubForm2Bt::cerrarEditor().
00508 { 00509 _depura("QSubForm2BtDelegate::cerrarEditor", 0); 00510 emit closeEditor(editor, QAbstractItemDelegate::NoHint); 00511 _depura("END QSubForm2BtDelegate::cerrarEditor", 0); 00512 return 0; 00513 }
SubForm2Bt* QSubForm2BtDelegate::m_subform [protected] |
Definition at line 42 of file subform2bt.h.
Referenced by createEditor(), eventFilter(), QSubForm2BtDelegate(), setEditorData(), and setModelData().
1.5.1