Subversion Repositories OpenInventory

Rev

Rev 225 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 225 Rev 226
Line 639... Line 639...
639
639
640
}
640
}
641
641
642
642
643
643
644
 QString grtFieldType(QString class_id, QString fieldName)//îïðåäåëÿåì òèï äàííûõ ïîëÿ
644
 QString FilterValueDelegate::getFieldType(QString class_id, QString fieldName)//îïðåäåëÿåì òèï äàííûõ ïîëÿ
645
 {
645
 {
646
646
647
 }
647
 }
648
648
649
649
-
 
650
-
 
651
-
 
652
-
 
653
-
 
654
650
//! [1]
655
//! [1]
651
QWidget *FilterValueDelegate::createEditor(QWidget *parent,
656
QWidget *FilterValueDelegate::createEditor(QWidget *parent,
652
    const QStyleOptionViewItem &/* option */,
657
    const QStyleOptionViewItem &/* option */,
653
    const QModelIndex &/* index */) const
658
    const QModelIndex &/* index */) const
654
{
659
{
Line 680... Line 685...
680
//! [1]
685
//! [1]
681
686
682
687
683
688
684
689
-
 
690
TField FilterValueDelegate::getField(const QModelIndex &index) // ïî èíäåêñó (â òàáëèöå ôèëüòðîâ) ïîëó÷èì èíôîðìàöèþ î ïîëå
-
 
691
{
-
 
692
    const QAbstractItemModel * model = index.model();
-
 
693
-
 
694
    TField field_result;
-
 
695
    QSqlQuery q;
-
 
696
    QString sql_str;
-
 
697
    bool ok;
-
 
698
-
 
699
-
 
700
    // QString fieldName = index.model()->data(model->index(index.row(),4), Qt::EditRole).toString();
-
 
701
  //  QString class_id = index.model()->data(model->index(index.row(),2), Qt::EditRole).toString();
-
 
702
    field_result.FieldName = index.model()->data(model->index(index.row(),4), Qt::EditRole).toString();
-
 
703
    field_result.ClassIdentifer = index.model()->data(model->index(index.row(),2), Qt::EditRole).toString();
-
 
704
-
 
705
    sql_str = tr("select * from `DescriptionOfClasses` where `ClassIdentifer` = '");
-
 
706
    sql_str.append(field_result.ClassIdentifer);
-
 
707
    sql_str.append(tr("' and `FieldName` = '"));
-
 
708
    sql_str.append(field_result.FieldName);
-
 
709
    sql_str.append(tr("'"));
-
 
710
-
 
711
    ok = q.prepare(sql_str);
-
 
712
-
 
713
    if(!ok)  return field_result;
-
 
714
-
 
715
    ok = q.exec();
-
 
716
-
 
717
    if(!ok)  return field_result;
-
 
718
-
 
719
    int ID_index = q.record().indexOf(tr("ID"));
685
720
-
 
721
    int FieldAlias_index = q.record().indexOf(tr("FieldAlias"));
-
 
722
-
 
723
    int FieldType_index = q.record().indexOf(tr("FieldType"));
-
 
724
-
 
725
    int DefaultValue_index = q.record().indexOf(tr("DefaultValue"));
-
 
726
-
 
727
    int Comment_index = q.record().indexOf(tr("Comment"));
-
 
728
-
 
729
-
 
730
-
 
731
    while(q.next()){
-
 
732
    field_result.ID = q.value(ID_index).asString();
-
 
733
    field_result.FieldAlias = q.value(FieldAlias_index).asString();
-
 
734
    field_result.FieldType = q.value(FieldType_index).asString();
-
 
735
    field_result.DefaultValue = q.value(DefaultValue_index).asString();
-
 
736
    field_result.Comment = q.value(Comment_index).asString();
-
 
737
    }
-
 
738
-
 
739
    return field_result;
-
 
740
-
 
741
-
 
742
-
 
743
}
686
744
687
745
688
746
689
747
690
748
Line 708... Line 766...
708
QString fieldName;//èìÿ ïîëÿ
766
QString fieldName;//èìÿ ïîëÿ
709
QSqlQuery q;
767
QSqlQuery q;
710
QString sql_str;
768
QString sql_str;
711
QStringList itemsList;
769
QStringList itemsList;
712
bool ok;
770
bool ok;
-
 
771
TField Field;
-
 
772
-
 
773
Field = getField(index);
-
 
774
-
 
775
-
 
776
713
777
714
778
715
779
716
fieldName = index.model()->data(model->index(index.row(),4), Qt::EditRole).toString();
780
fieldName = index.model()->data(model->index(index.row(),4), Qt::EditRole).toString();
717
781