void XComboBox::setDataWidgetMap(XDataWidgetMapper* m) { disconnect(this, SIGNAL(editTextChanged(QString)), this, SLOT(updateMapperData())); disconnect(this, SIGNAL(newID(int)), this, SLOT(updateMapperData())); if (!_listTableName.isEmpty()) { QString tableName=""; if (_listSchemaName.length()) tableName=_listSchemaName + "."; tableName+=_listTableName; static_cast<XSqlTableModel*>(m->model())->setRelation(static_cast<XSqlTableModel*>(m->model())->fieldIndex(_fieldName), QSqlRelation(tableName, _listIdFieldName, _listDisplayFieldName)); QSqlTableModel *rel =static_cast<XSqlTableModel*>(m->model())->relationModel(static_cast<XSqlTableModel*>(m->model())->fieldIndex(_fieldName)); setModel(rel); setModelColumn(rel->fieldIndex(_listDisplayFieldName)); m->setItemDelegate(new QSqlRelationalDelegate(this)); m->addMapping(this, _fieldName); return; } else if (_codes.count()) m->addMapping(this, _fieldName, "code", "currentDefault"); else m->addMapping(this, _fieldName, "text", "text"); _mapper=m; connect(this, SIGNAL(editTextChanged(QString)), this, SLOT(updateMapperData())); connect(this, SIGNAL(newID(int)), this, SLOT(updateMapperData())); }
void XTextEdit::setDataWidgetMap(XDataWidgetMapper* m) { disconnect(this, SIGNAL(textChanged()), this, SLOT(updateMapperData())); if (acceptRichText()) m->addMapping(this, _fieldName, "html", "defaultText"); else m->addMapping(this, _fieldName, "plainText", "defaultText"); _mapper = m; connect(this, SIGNAL(textChanged()), this, SLOT(updateMapperData())); }