Skip to content

Commit 1e7da44

Browse files
author
jef
committedNov 3, 2010
fix attribute replacement in actions
git-svn-id: http://svn.osgeo.org/qgis/trunk@14498 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 485ae19 commit 1e7da44

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed
 

‎src/core/qgsattributeaction.cpp

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,24 +106,28 @@ QString QgsAttributeAction::expandAction( QString action, const QgsAttributeMap
106106

107107
const QgsFieldMap &fields = mLayer->pendingFields();
108108

109-
for ( QgsAttributeMap::const_iterator it = attributes.begin(); it != attributes.end(); it++ )
109+
for ( int i = 0; i < 4; i++ )
110110
{
111-
QgsFieldMap::const_iterator fit = fields.find( it.key() );
112-
if ( fit == fields.constEnd() )
113-
continue;
114-
115-
// Check for a replace a quoted version and a non-quoted version.
116-
QString to_replace_1 = "[%" + fit->name() + "]";
117-
QString to_replace_2 = "%" + fit->name();
118-
QString to_replace_3 = "%" + mLayer->attributeDisplayName( it.key() );
119-
QString to_replace_4 = "[%" + mLayer->attributeDisplayName( it.key() ) + "]";
120-
121-
expanded_action = expanded_action.replace( to_replace_1, it.value().toString() );
122-
expanded_action = expanded_action.replace( to_replace_2, it.value().toString() );
123-
expanded_action = expanded_action.replace( to_replace_3, it.value().toString() );
124-
expanded_action = expanded_action.replace( to_replace_4, it.value().toString() );
111+
for ( QgsAttributeMap::const_iterator it = attributes.begin(); it != attributes.end(); it++ )
112+
{
113+
QgsFieldMap::const_iterator fit = fields.find( it.key() );
114+
if ( fit == fields.constEnd() )
115+
continue;
116+
117+
QString to_replace;
118+
switch ( i )
119+
{
120+
case 0: to_replace = "[%" + fit->name() + "]"; break;
121+
case 1: to_replace = "[%" + mLayer->attributeDisplayName( it.key() ) + "]"; break;
122+
case 2: to_replace = "%" + fit->name(); break;
123+
case 3: to_replace = "%" + mLayer->attributeDisplayName( it.key() ); break;
124+
}
125+
126+
expanded_action = expanded_action.replace( to_replace, it.value().toString() );
127+
}
125128
}
126129

130+
127131
return expanded_action;
128132
}
129133

0 commit comments

Comments
 (0)
Please sign in to comment.