@@ -1992,7 +1992,7 @@ QgsGrassModuleInput::QgsGrassModuleInput( QgsGrassModule *module,
1992
1992
: QgsGrassModuleGroupBoxItem( module, key, qdesc, gdesc, gnode, parent ),
1993
1993
mModuleStandardOptions( options ),
1994
1994
mGeometryTypeOption( 0 ), mVectorLayerOption( 0 ),
1995
- mRegionButton( 0 ), mUpdate( false )
1995
+ mRegionButton( 0 ), mUpdate( false ), mRequired( false )
1996
1996
{
1997
1997
QgsDebugMsg ( " called." );
1998
1998
mGeometryTypeMask = GV_POINT | GV_LINE | GV_AREA;
@@ -2003,6 +2003,13 @@ QgsGrassModuleInput::QgsGrassModuleInput( QgsGrassModule *module,
2003
2003
}
2004
2004
adjustTitle ();
2005
2005
2006
+ // Check if this parameter is required
2007
+ if (gnode.toElement ().attribute (" required" ) == " yes" ) {
2008
+ mRequired = true ;
2009
+ } else {
2010
+ mRequired = false ;
2011
+ }
2012
+
2006
2013
QDomNode promptNode = gnode.namedItem ( " gisprompt" );
2007
2014
QDomElement promptElem = promptNode.toElement ();
2008
2015
QString element = promptElem.attribute ( " element" );
@@ -2212,6 +2219,15 @@ void QgsGrassModuleInput::updateQgisLayers()
2212
2219
mMapLayers .resize ( 0 );
2213
2220
mVectorFields .resize ( 0 );
2214
2221
2222
+ // If not required, add an empty item to combobox and a padding item into
2223
+ // layer containers.
2224
+ if (!mRequired ){
2225
+ mMaps .push_back (QString (" " ));
2226
+ mVectorLayerNames .push_back (QString (" " ));
2227
+ mMapLayers .push_back (NULL );
2228
+ mLayerComboBox ->addItem (tr (" Select a layer" ), QVariant ());
2229
+ }
2230
+
2215
2231
QgsMapCanvas *canvas = mModule ->qgisIface ()->mapCanvas ();
2216
2232
2217
2233
// Find map option
0 commit comments