[QGIS Commit] r14498 - trunk/qgis/src/core

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Nov 3 17:04:12 EDT 2010


Author: jef
Date: 2010-11-03 14:04:12 -0700 (Wed, 03 Nov 2010)
New Revision: 14498

Modified:
   trunk/qgis/src/core/qgsattributeaction.cpp
Log:
fix attribute replacement in actions

Modified: trunk/qgis/src/core/qgsattributeaction.cpp
===================================================================
--- trunk/qgis/src/core/qgsattributeaction.cpp	2010-11-03 11:57:34 UTC (rev 14497)
+++ trunk/qgis/src/core/qgsattributeaction.cpp	2010-11-03 21:04:12 UTC (rev 14498)
@@ -106,24 +106,28 @@
 
   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;
 }
 



More information about the QGIS-commit mailing list