Subversion Repositories OpenInventory

Compare Revisions

Ignore whitespace Rev 225 → Rev 226

/trunk/DBViewer/delegate.cpp
641,12 → 641,17
 
 
 
QString grtFieldType(QString class_id, QString fieldName)//îïðåäåëÿåì òèï äàííûõ ïîëÿ
QString FilterValueDelegate::getFieldType(QString class_id, QString fieldName)//îïðåäåëÿåì òèï äàííûõ ïîëÿ
{
 
}
 
 
 
 
 
 
 
//! [1]
QWidget *FilterValueDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &/* option */,
682,12 → 687,65
 
 
 
TField FilterValueDelegate::getField(const QModelIndex &index) // ïî èíäåêñó (â òàáëèöå ôèëüòðîâ) ïîëó÷èì èíôîðìàöèþ î ïîëå
{
const QAbstractItemModel * model = index.model();
 
TField field_result;
QSqlQuery q;
QString sql_str;
bool ok;
 
 
// QString fieldName = index.model()->data(model->index(index.row(),4), Qt::EditRole).toString();
// QString class_id = index.model()->data(model->index(index.row(),2), Qt::EditRole).toString();
field_result.FieldName = index.model()->data(model->index(index.row(),4), Qt::EditRole).toString();
field_result.ClassIdentifer = index.model()->data(model->index(index.row(),2), Qt::EditRole).toString();
 
sql_str = tr("select * from `DescriptionOfClasses` where `ClassIdentifer` = '");
sql_str.append(field_result.ClassIdentifer);
sql_str.append(tr("' and `FieldName` = '"));
sql_str.append(field_result.FieldName);
sql_str.append(tr("'"));
 
ok = q.prepare(sql_str);
 
if(!ok) return field_result;
 
ok = q.exec();
 
if(!ok) return field_result;
 
int ID_index = q.record().indexOf(tr("ID"));
 
int FieldAlias_index = q.record().indexOf(tr("FieldAlias"));
 
int FieldType_index = q.record().indexOf(tr("FieldType"));
 
int DefaultValue_index = q.record().indexOf(tr("DefaultValue"));
 
int Comment_index = q.record().indexOf(tr("Comment"));
 
 
 
while(q.next()){
field_result.ID = q.value(ID_index).asString();
field_result.FieldAlias = q.value(FieldAlias_index).asString();
field_result.FieldType = q.value(FieldType_index).asString();
field_result.DefaultValue = q.value(DefaultValue_index).asString();
field_result.Comment = q.value(Comment_index).asString();
}
 
return field_result;
 
 
 
}
 
 
 
 
 
//! [2]
void FilterValueDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
710,9 → 768,15
QString sql_str;
QStringList itemsList;
bool ok;
TField Field;
 
Field = getField(index);
 
 
 
 
 
 
fieldName = index.model()->data(model->index(index.row(),4), Qt::EditRole).toString();