예제 #1
0
int QgsAuxiliaryLayer::propertyFromIndex( int index ) const
{
  int p = -1;
  QgsPropertyDefinition aDef = propertyDefinitionFromIndex( index );

  if ( aDef.origin().compare( QLatin1String( "labeling" ) ) == 0 )
  {
    const QgsPropertiesDefinition defs = QgsPalLayerSettings::propertyDefinitions();
    QgsPropertiesDefinition::const_iterator it = defs.constBegin();
    for ( ; it != defs.constEnd(); ++it )
    {
      if ( it->name().compare( aDef.name(), Qt::CaseInsensitive ) == 0 )
      {
        p = it.key();
        break;
      }
    }
  }
  else if ( aDef.origin().compare( QLatin1String( "symbol" ) ) == 0 )
  {
    const QgsPropertiesDefinition defs = QgsSymbolLayer::propertyDefinitions();
    QgsPropertiesDefinition::const_iterator it = defs.constBegin();
    for ( ; it != defs.constEnd(); ++it )
    {
      if ( it->name().compare( aDef.name(), Qt::CaseInsensitive ) == 0 )
      {
        p = it.key();
        break;
      }
    }
  }
  else if ( aDef.origin().compare( QLatin1String( "diagram" ) ) == 0 )
  {
    const QgsPropertiesDefinition defs = QgsDiagramLayerSettings::propertyDefinitions();
    QgsPropertiesDefinition::const_iterator it = defs.constBegin();
    for ( ; it != defs.constEnd(); ++it )
    {
      if ( it->name().compare( aDef.name(), Qt::CaseInsensitive ) == 0 )
      {
        p = it.key();
        break;
      }
    }
  }

  return p;
}
예제 #2
0
QgsPropertyDefinition QgsAuxiliaryLayer::propertyDefinitionFromField( const QgsField &f )
{
  QgsPropertyDefinition def;
  const QStringList parts = f.name().split( '_' );

  if ( parts.size() <= 1 )
    return def;

  const QString origin = parts[0];
  const QString propertyName = parts[1];

  if ( origin.compare( "labeling", Qt::CaseInsensitive ) == 0 )
  {
    const QgsPropertiesDefinition props = QgsPalLayerSettings::propertyDefinitions();
    for ( auto it = props.constBegin(); it != props.constEnd(); ++it )
    {
      if ( it.value().name().compare( propertyName, Qt::CaseInsensitive ) == 0 )
      {
        def = it.value();
        if ( parts.size() == 3 )
          def.setComment( parts[2] );
        break;
      }
    }
  }
  else if ( origin.compare( "symbol", Qt::CaseInsensitive ) == 0 )
  {
    const QgsPropertiesDefinition props = QgsSymbolLayer::propertyDefinitions();
    for ( auto it = props.constBegin(); it != props.constEnd(); ++it )
    {
      if ( it.value().name().compare( propertyName, Qt::CaseInsensitive ) == 0 )
      {
        def = it.value();
        if ( parts.size() == 3 )
          def.setComment( parts[2] );
        break;
      }
    }
  }
  else if ( origin.compare( "diagram", Qt::CaseInsensitive ) == 0 )
  {
    const QgsPropertiesDefinition props = QgsDiagramLayerSettings::propertyDefinitions();
    for ( auto it = props.constBegin(); it != props.constEnd(); ++it )
    {
      if ( it.value().name().compare( propertyName, Qt::CaseInsensitive ) == 0 )
      {
        def = it.value();
        if ( parts.size() == 3 )
          def.setComment( parts[2] );
        break;
      }
    }
  }
  else
  {
    def.setOrigin( origin );
    def.setName( propertyName );

    if ( parts.size() == 3 )
      def.setComment( parts[2] );
  }

  return def;
}