Skip to content

Commit

Permalink
fix attribute replacement in actions
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@14498 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Nov 3, 2010
1 parent 485ae19 commit 1e7da44
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/core/qgsattributeaction.cpp
Expand Up @@ -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;

// 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() ) + "]";

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() );
for ( QgsAttributeMap::const_iterator it = attributes.begin(); it != attributes.end(); it++ )
{
QgsFieldMap::const_iterator fit = fields.find( it.key() );
if ( fit == fields.constEnd() )
continue;

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, it.value().toString() );
}
}


return expanded_action;
}

Expand Down

0 comments on commit 1e7da44

Please sign in to comment.