Пример #1
0
void ListInputField::setXMLData(const QDomElement &element)
{
    InputField::List::Iterator it;
    for(it = mFields.begin(); it != mFields.end(); ++it)
    {
        delete *it;
    }
    mFields.clear();

    QDomNode node = element.firstChild();
    while(!node.isNull())
    {
        QDomElement child = node.toElement();
        if(!child.isNull())
        {
            InputField *field = InputFieldFactory::self()->createField(name(), mTypeName);
            if(field)
            {
                field->setXMLData(child);
                appendChild(field);
            }
            else
                qDebug("ListInputField: Unable to create field of type %s", mTypeName.latin1());
        }

        node = node.nextSibling();
    }
}
Пример #2
0
void ComplexBaseInputField::setXMLData( const QDomElement &element )
{
  if ( mName != element.tagName() ) {
    qDebug( "ComplexBaseInputField: Wrong dom element passed: expected %s, got %s", qPrintable( mName ), qPrintable( element.tagName() ) );
    return;
  }

  // elements
  if ( mType->isArray() ) {
    InputField *field = childField( "item" );
    field->setXMLData( element );
  } else {
    QDomNode node = element.firstChild();
    while ( !node.isNull() ) {
      QDomElement child = node.toElement();
      if ( !child.isNull() ) {
        InputField *field = childField( child.tagName() );
        if ( !field ) {
          qDebug( "ComplexBaseInputField: Child field %s does not exists", qPrintable( child.tagName() ) );
        } else {
          field->setXMLData( child );
        }
      }

      node = node.nextSibling();
    }
  }

  // attributes
  QDomNamedNodeMap nodes = element.attributes();
  for ( int i = 0; i < nodes.count(); ++i ) {
    QDomNode node = nodes.item( i );
    QDomAttr attr = node.toAttr();

    InputField *field = childField( attr.name() );
    if ( !field ) {
      qDebug( "ComplexBaseInputField: Child field %s does not exists", qPrintable( attr.name() ) );
    } else {
      field->setData( attr.value() );
    }
  }
}
Пример #3
0
void SimpleBaseInputField::setXMLData( const QDomElement &element )
{
  if ( mName != element.tagName() ) {
    qDebug( "SimpleBaseInputField: Wrong dom element passed: expected %s, got %s", mName.latin1(), element.tagName().latin1() );
    return;
  }

  if ( mType->subType() == Schema::SimpleType::TypeRestriction ) {
    InputField *field = childField( element.tagName() );
    if ( !field ) {
      qDebug( "SimpleBaseInputField: Child field %s does not exists", element.tagName().latin1() );
    } else {
      field->setXMLData( element );
    }
  } else {
    qDebug( "SimpleBaseInputField: Unsupported subtype" );
  }
}
Пример #4
0
void PageInputField::setXMLData( const QDomElement &element )
{
    if ( mName != element.tagName() ) {
        qDebug( "PageInputField: Wrong dom element passed: expected %s, got %s", qPrintable( mName ), qPrintable( element.tagName() ) );
        return;
    }

    QDomNode node = element.firstChild();
    while ( !node.isNull() ) {
        QDomElement child = node.toElement();
        if ( !child.isNull() ) {
            InputField *field = childField( child.tagName() );
            if ( !field ) {
                qDebug( "PageInputField: Child field %s does not exists", qPrintable( child.tagName() ) );
            } else {
                field->setXMLData( child );
            }
        }

        node = node.nextSibling();
    }
}