[QGIS Commit] r11329 - trunk/qgis/src/plugins/grass

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Aug 10 11:41:33 EDT 2009


Author: rugginoso
Date: 2009-08-10 11:41:32 -0400 (Mon, 10 Aug 2009)
New Revision: 11329

Modified:
   trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp
   trunk/qgis/src/plugins/grass/qgsgrassmodule.h
Log:
Added the possibility to unselect an optional (required="no" into interface-description of the grass module) to fix #1134.


Modified: trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp	2009-08-10 14:55:27 UTC (rev 11328)
+++ trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp	2009-08-10 15:41:32 UTC (rev 11329)
@@ -2633,6 +2633,13 @@
   }
   adjustTitle();
 
+  // Check if this parameter is required
+  if (gnode.toElement().attribute("required") == "yes") {
+      mRequired = true;
+  } else {
+      mRequired = false;
+  }
+
   QDomNode promptNode = gnode.namedItem( "gisprompt" );
   QDomElement promptElem = promptNode.toElement();
   QString element = promptElem.attribute( "element" );
@@ -2700,6 +2707,14 @@
   mUri.resize( 0 );
   mOgrLayers.resize( 0 );
 
+  // If not required, add an empty item to combobox and a padding item into
+  // layer containers.
+  if (!mRequired){
+      mUri.push_back(QString());
+      mOgrLayers.push_back(QString());
+      mLayerComboBox->addItem(tr("Select a layer"), QVariant());
+  }
+
   QgsMapCanvas *canvas = mModule->qgisIface()->mapCanvas();
 
   int nlayers = canvas->layerCount();

Modified: trunk/qgis/src/plugins/grass/qgsgrassmodule.h
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrassmodule.h	2009-08-10 14:55:27 UTC (rev 11328)
+++ trunk/qgis/src/plugins/grass/qgsgrassmodule.h	2009-08-10 15:41:32 UTC (rev 11329)
@@ -695,6 +695,9 @@
 
     //! Ogr where clauses
     std::vector<QString> mOgrWheres;
+
+    //! Required field
+    bool mRequired;
 };
 
 /*********************** QgsGrassModuleField **********************/



More information about the QGIS-commit mailing list