@@ -106,24 +106,28 @@ QString QgsAttributeAction::expandAction( QString action, const QgsAttributeMap
106
106
107
107
const QgsFieldMap &fields = mLayer ->pendingFields ();
108
108
109
- for ( QgsAttributeMap::const_iterator it = attributes. begin (); it != attributes. end (); it ++ )
109
+ for ( int i = 0 ; i < 4 ; i ++ )
110
110
{
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
+ }
125
128
}
126
129
130
+
127
131
return expanded_action;
128
132
}
129
133
0 commit comments