Exemplo n.º 1
0
void QgsServerProjectParser::addValueRelationLayersForLayer( const QgsVectorLayer *vl ) const
{
  if ( !vl )
    return;

  for ( int idx = 0; idx < vl->pendingFields().size(); idx++ )
  {
    if ( vl->editFormConfig()->widgetType( idx ) != "ValueRelation" )
      continue;

    QgsEditorWidgetConfig cfg( vl->editFormConfig()->widgetConfig( idx ) );
    if ( !cfg.contains( "Layer" ) )
      continue;

    QString layerId = cfg.value( "Layer" ).toString();
    if ( QgsMapLayerRegistry::instance()->mapLayer( layerId ) )
      continue;

    QgsMapLayer *layer = mapLayerFromLayerId( layerId );
    if ( !layer )
      continue;

    QgsMapLayerRegistry::instance()->addMapLayer( layer, false, false );
  }
}
Exemplo n.º 2
0
void QgsServerProjectParser::addValueRelationLayersForElement( const QDomElement& layerElem, bool useCache ) const
{
  QDomElement editTypesElem = layerElem.firstChildElement( "edittypes" );
  if ( editTypesElem.isNull() )
  {
    return;
  }

  QDomNodeList editTypeNodeList = editTypesElem.elementsByTagName( "edittype" );
  for ( int i = 0; i < editTypeNodeList.size(); ++i )
  {
    QDomElement editTypeElem = editTypeNodeList.at( i ).toElement();
    int type = editTypeElem.attribute( "type" ).toInt();
    if ( type == QgsVectorLayer::ValueRelation )
    {
      QString layerId = editTypeElem.attribute( "layer" );
      /*QString keyAttribute = editTypeEleml.attribute( "id" ); //relation attribute in other layer
      QString valueAttribute = editTypeElem.attribute( "value" ); //value attribute in other layer
      QString relationAttribute = editTypeElem.attribute( "name" );*/

      QgsMapLayer* layer = mapLayerFromLayerId( layerId, useCache );
      if ( layer )
      {
        QgsMapLayerRegistry::instance()->addMapLayer( layer, false, false );
      }
    }
  }
}
Exemplo n.º 3
0
void QgsServerProjectParser::addJoinLayersForElement( const QDomElement& layerElem ) const
{
  QDomElement vectorJoinsElem = layerElem.firstChildElement( "vectorjoins" );
  if ( vectorJoinsElem.isNull() )
  {
    return;
  }

  QDomNodeList joinNodeList = vectorJoinsElem.elementsByTagName( "join" );
  for ( int i = 0; i < joinNodeList.size(); ++i )
  {
    QString id = joinNodeList.at( i ).toElement().attribute( "joinLayerId" );
    QgsMapLayer* layer = mapLayerFromLayerId( id );
    if ( layer )
    {
      QgsMapLayerRegistry::instance()->addMapLayer( layer, false, false );
    }
  }
}