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; }
void QgsPropertyOverrideButton::init( int propertyKey, const QgsProperty &property, const QgsPropertiesDefinition &definitions, const QgsVectorLayer *layer, bool auxiliaryStorageEnabled ) { mVectorLayer = layer; mAuxiliaryStorageEnabled = auxiliaryStorageEnabled; setToProperty( property ); mPropertyKey = propertyKey; mDefinition = definitions.value( propertyKey ); mDataTypes = mDefinition.dataType(); mInputDescription = mDefinition.helpText(); mFullDescription.clear(); mUsageInfo.clear(); // set up data types string mDataTypesString.clear(); QStringList ts; switch ( mDataTypes ) { case QgsPropertyDefinition::DataTypeBoolean: ts << tr( "boolean" ); FALLTHROUGH; case QgsPropertyDefinition::DataTypeNumeric: ts << tr( "int" ); ts << tr( "double" ); FALLTHROUGH; case QgsPropertyDefinition::DataTypeString: ts << tr( "string" ); break; } if ( !ts.isEmpty() ) { mDataTypesString = ts.join( QStringLiteral( ", " ) ); mActionDataTypes->setText( tr( "Field type: " ) + mDataTypesString ); } updateFieldLists(); updateGui(); }
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; }
void QgsPropertyOverrideButton::init( int propertyKey, const QgsProperty &property, const QgsPropertiesDefinition &definitions, const QgsVectorLayer *layer, bool auxiliaryStorageEnabled ) { init( propertyKey, property, definitions.value( propertyKey ), layer, auxiliaryStorageEnabled ); }