[QGIS Commit] r12679 - in trunk/qgis/src/plugins/grass: . modules-common

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Jan 6 07:15:54 EST 2010


Author: rblazek
Date: 2010-01-06 07:15:53 -0500 (Wed, 06 Jan 2010)
New Revision: 12679

Modified:
   trunk/qgis/src/plugins/grass/modules-common/v.what.vect.qgm
   trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp
   trunk/qgis/src/plugins/grass/qgsgrassmodule.h
Log:
fixed #1619, and another not yet reported bug for field

Modified: trunk/qgis/src/plugins/grass/modules-common/v.what.vect.qgm
===================================================================
--- trunk/qgis/src/plugins/grass/modules-common/v.what.vect.qgm	2010-01-06 11:23:43 UTC (rev 12678)
+++ trunk/qgis/src/plugins/grass/modules-common/v.what.vect.qgm	2010-01-06 12:15:53 UTC (rev 12679)
@@ -5,5 +5,5 @@
 	<option key="vector" layeroption="layer" typemask="point"/>
 	<field key="column" layer="vector" type="integer,double,string"/>
 	<option key="qvector" layeroption="layer" typemask="area"/>
-	<option key="qcolumn" layer="qvector" type="string"/>
+	<field key="qcolumn" layer="qvector" type="string"/>
 </qgisgrassmodule>

Modified: trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp	2010-01-06 11:23:43 UTC (rev 12678)
+++ trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp	2010-01-06 12:15:53 UTC (rev 12679)
@@ -562,6 +562,23 @@
   return arg;
 }
 
+// id is not used in fact, was intended for field, but key is used instead
+QgsGrassModuleItem *QgsGrassModuleStandardOptions::itemByKey( QString key )
+{
+  QgsDebugMsg( "key = " + key );
+
+  for ( unsigned int i = 0; i < mItems.size(); i++ )
+  {
+    if ( mItems[i]->key() == key )
+    {
+      return mItems[i];
+    }
+  }
+
+  QMessageBox::warning( 0, tr( "Warning" ), tr( "Item with key %1 not found" ).arg( key ) );
+  return 0;
+}
+
 QgsGrassModuleItem *QgsGrassModuleStandardOptions::item( QString id )
 {
   QgsDebugMsg( "id = " + id );
@@ -2908,16 +2925,19 @@
   QDomElement promptElem = promptNode.toElement();
   QString element = promptElem.attribute( "element" );
 
-  mLayerId = qdesc.attribute( "layerid" );
-
   mType = qdesc.attribute( "type" );
 
-  QgsGrassModuleItem *item = mModuleStandardOptions->item( mLayerId );
-  // TODO check type
-  if ( item )
-  {
-    mLayerInput = dynamic_cast<QgsGrassModuleInput *>( item );
-    connect( mLayerInput, SIGNAL( valueChanged() ), this, SLOT( updateFields() ) );
+  mLayerKey = qdesc.attribute( "layer" );
+  if ( mLayerKey.isNull() || mLayerKey.length() == 0 ) {
+    QMessageBox::warning( 0, tr( "Warning" ), tr( "'layer' attribute in field tag with key= %1 is missing." ).arg( mKey ) );
+  } else {
+    QgsGrassModuleItem *item = mModuleStandardOptions->itemByKey( mLayerKey );
+    // TODO check type
+    if ( item )
+    {
+      mLayerInput = dynamic_cast<QgsGrassModuleInput *>( item );
+      connect( mLayerInput, SIGNAL( valueChanged() ), this, SLOT( updateFields() ) );
+    }
   }
 
   QHBoxLayout *l = new QHBoxLayout( this );

Modified: trunk/qgis/src/plugins/grass/qgsgrassmodule.h
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrassmodule.h	2010-01-06 11:23:43 UTC (rev 12678)
+++ trunk/qgis/src/plugins/grass/qgsgrassmodule.h	2010-01-06 12:15:53 UTC (rev 12679)
@@ -256,6 +256,9 @@
     // ! Get item by ID
     QgsGrassModuleItem *item( QString id );
 
+    // ! Get item by key
+    QgsGrassModuleItem *itemByKey( QString key );
+
     // Reimplemented methods from QgsGrassModuleOptions
     QStringList checkOutput();
     void freezeOutput();
@@ -749,7 +752,7 @@
     QgsGrassModuleStandardOptions *mModuleStandardOptions;
 
     //! Layer key
-    QString mLayerId;
+    QString mLayerKey;
 
     //! Pointer to layer input
     QgsGrassModuleInput *mLayerInput;



More information about the QGIS-commit mailing list