Skip to content
Permalink
Browse files

fix attribute replacement in actions

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14498 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Nov 3, 2010
1 parent d3319b0 commit 63a117ab09d72e9cc84102a667dc0b1a085fee46
Showing with 19 additions and 15 deletions.
  1. +19 −15 src/core/qgsattributeaction.cpp
@@ -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;
}

0 comments on commit 63a117a

Please sign in to comment.
You can’t perform that action at this time.