void PoitemTableDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { const QAbstractItemModel *model = index.model(); QLineEdit *lineedit = 0; switch (index.column()) { case ITEM_NUMBER_COL: { ItemLineEdit *item = static_cast<ItemLineEdit*>(editor); if (model->data(model->index(index.row(), POITEM_ITEMSITE_ID_COL)).toInt() > 0) item->setItemsiteid(model->data(model->index(index.row(), POITEM_ITEMSITE_ID_COL)).toInt()); break; } case WAREHOUS_CODE_COL: { WComboBox *whs = static_cast<WComboBox*>(editor); whs->setId(model->data(model->index(index.row(), WAREHOUS_ID_COL)).toInt()); break; } case POITEM_VEND_ITEM_NUMBER_COL: case POITEM_QTY_ORDERED_COL: case POITEM_UNITPRICE_COL: case POITEM_FREIGHT_COL: lineedit = static_cast<QLineEdit*>(editor); lineedit->setText(model->data(index).toString()); break; case POITEM_DUEDATE_COL: { DLineEdit *duedate = static_cast<DLineEdit*>(editor); duedate->setDate(index.data().toDate()); break; } #ifdef QE_PROJECT case PRJ_NUMBER_COL: { ProjectLineEdit *prj = static_cast<ProjectLineEdit*>(editor); prj->setId(model->data(model->index(index.row(), POITEM_PRJ_ID_COL)).toInt()); break; } #endif #ifdef QE_NONINVENTORY case EXPCAT_CODE_COL: { ExpenseLineEdit *exp = static_cast<ExpenseLineEdit*>(editor); exp->setId(model->data(model->index(index.row(), POITEM_EXPCAT_ID_COL)).toInt()); break; } #endif default: break; } }
void ToitemTableDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { const QAbstractItemModel *model = index.model(); QLineEdit *lineedit = 0; switch (index.column()) { case ITEM_NUMBER_COL: { ItemLineEdit *item = static_cast<ItemLineEdit*>(editor); item->setId(model->data(model->index(index.row(), TOITEM_ITEM_ID_COL)).toInt()); break; } case TOITEM_QTY_ORDERED_COL: case TOITEM_FREIGHT_COL: lineedit = static_cast<QLineEdit*>(editor); lineedit->setText(model->data(index).toString()); break; case TOITEM_DUEDATE_COL: { DLineEdit *duedate = static_cast<DLineEdit*>(editor); duedate->setDate(index.data().toDate()); break; } #ifdef QE_PROJECT case PRJ_NUMBER_COL: { ProjectLineEdit *prj = static_cast<ProjectLineEdit*>(editor); prj->setId(model->data(model->index(index.row(), TOITEM_PRJ_ID_COL)).toInt()); break; } #endif default: break; } }