mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-11 00:04:27 -04:00
fix attribute replacement in actions
git-svn-id: http://svn.osgeo.org/qgis/trunk@14498 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
485ae1921f
commit
1e7da443c6
@ -106,24 +106,28 @@ QString QgsAttributeAction::expandAction( QString action, const QgsAttributeMap
|
||||
|
||||
const QgsFieldMap &fields = mLayer->pendingFields();
|
||||
|
||||
for ( QgsAttributeMap::const_iterator it = attributes.begin(); it != attributes.end(); it++ )
|
||||
for ( int i = 0; i < 4; i++ )
|
||||
{
|
||||
QgsFieldMap::const_iterator fit = fields.find( it.key() );
|
||||
if ( fit == fields.constEnd() )
|
||||
continue;
|
||||
for ( QgsAttributeMap::const_iterator it = attributes.begin(); it != attributes.end(); it++ )
|
||||
{
|
||||
QgsFieldMap::const_iterator fit = fields.find( it.key() );
|
||||
if ( fit == fields.constEnd() )
|
||||
continue;
|
||||
|
||||
// Check for a replace a quoted version and a non-quoted version.
|
||||
QString to_replace_1 = "[%" + fit->name() + "]";
|
||||
QString to_replace_2 = "%" + fit->name();
|
||||
QString to_replace_3 = "%" + mLayer->attributeDisplayName( it.key() );
|
||||
QString to_replace_4 = "[%" + mLayer->attributeDisplayName( it.key() ) + "]";
|
||||
QString to_replace;
|
||||
switch ( i )
|
||||
{
|
||||
case 0: to_replace = "[%" + fit->name() + "]"; break;
|
||||
case 1: to_replace = "[%" + mLayer->attributeDisplayName( it.key() ) + "]"; break;
|
||||
case 2: to_replace = "%" + fit->name(); break;
|
||||
case 3: to_replace = "%" + mLayer->attributeDisplayName( it.key() ); break;
|
||||
}
|
||||
|
||||
expanded_action = expanded_action.replace( to_replace_1, it.value().toString() );
|
||||
expanded_action = expanded_action.replace( to_replace_2, it.value().toString() );
|
||||
expanded_action = expanded_action.replace( to_replace_3, it.value().toString() );
|
||||
expanded_action = expanded_action.replace( to_replace_4, it.value().toString() );
|
||||
expanded_action = expanded_action.replace( to_replace, it.value().toString() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return expanded_action;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user