QgsProperty QgsProperty::fromField( const QString &fieldName, bool isActive ) { QgsProperty p; p.setField( fieldName ); p.setActive( isActive ); return p; }
QgsProperty QgsProperty::fromValue( const QVariant &value, bool isActive ) { QgsProperty p; p.setStaticValue( value ); p.setActive( isActive ); return p; }
QgsProperty QgsProperty::fromExpression( const QString &expression, bool isActive ) { QgsProperty p; p.setExpressionString( expression ); p.setActive( isActive ); return p; }
void QgsSymbolsListWidget::createAuxiliaryField() { // try to create an auxiliary layer if not yet created if ( !mLayer->auxiliaryLayer() ) { QgsNewAuxiliaryLayerDialog dlg( mLayer, this ); dlg.exec(); } // return if still not exists if ( !mLayer->auxiliaryLayer() ) return; QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() ); QgsSymbolLayer::Property key = static_cast< QgsSymbolLayer::Property >( button->propertyKey() ); const QgsPropertyDefinition def = QgsSymbolLayer::propertyDefinitions()[key]; // create property in auxiliary storage if necessary if ( !mLayer->auxiliaryLayer()->exists( def ) ) mLayer->auxiliaryLayer()->addAuxiliaryField( def ); // update property with join field name from auxiliary storage QgsProperty property = button->toProperty(); property.setField( QgsAuxiliaryLayer::nameFromProperty( def, true ) ); property.setActive( true ); button->updateFieldLists(); button->setToProperty( property ); QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol ); QgsLineSymbol *lineSymbol = static_cast<QgsLineSymbol *>( mSymbol ); switch ( key ) { case QgsSymbolLayer::PropertyAngle: if ( markerSymbol ) markerSymbol->setDataDefinedAngle( button->toProperty() ); break; case QgsSymbolLayer::PropertySize: if ( markerSymbol ) { markerSymbol->setDataDefinedSize( button->toProperty() ); markerSymbol->setScaleMethod( QgsSymbol::ScaleDiameter ); } break; case QgsSymbolLayer::PropertyStrokeWidth: if ( lineSymbol ) lineSymbol->setDataDefinedWidth( button->toProperty() ); break; default: break; } emit changed(); }