Skip to content

Commit 1e1c65d

Browse files
author
rugginoso
committed
Added the possibility to unselect an optional (required="no" into interface-description of the grass module) to fix #1134.
git-svn-id: http://svn.osgeo.org/qgis/trunk@11328 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent e3467ff commit 1e1c65d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/plugins/grass/qgsgrassmodule.cpp

+17-1
Original file line numberDiff line numberDiff line change
@@ -1992,7 +1992,7 @@ QgsGrassModuleInput::QgsGrassModuleInput( QgsGrassModule *module,
19921992
: QgsGrassModuleGroupBoxItem( module, key, qdesc, gdesc, gnode, parent ),
19931993
mModuleStandardOptions( options ),
19941994
mGeometryTypeOption( 0 ), mVectorLayerOption( 0 ),
1995-
mRegionButton( 0 ), mUpdate( false )
1995+
mRegionButton( 0 ), mUpdate( false ), mRequired( false )
19961996
{
19971997
QgsDebugMsg( "called." );
19981998
mGeometryTypeMask = GV_POINT | GV_LINE | GV_AREA;
@@ -2003,6 +2003,13 @@ QgsGrassModuleInput::QgsGrassModuleInput( QgsGrassModule *module,
20032003
}
20042004
adjustTitle();
20052005

2006+
// Check if this parameter is required
2007+
if (gnode.toElement().attribute("required") == "yes") {
2008+
mRequired = true;
2009+
} else {
2010+
mRequired = false;
2011+
}
2012+
20062013
QDomNode promptNode = gnode.namedItem( "gisprompt" );
20072014
QDomElement promptElem = promptNode.toElement();
20082015
QString element = promptElem.attribute( "element" );
@@ -2212,6 +2219,15 @@ void QgsGrassModuleInput::updateQgisLayers()
22122219
mMapLayers.resize( 0 );
22132220
mVectorFields.resize( 0 );
22142221

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+
22152231
QgsMapCanvas *canvas = mModule->qgisIface()->mapCanvas();
22162232

22172233
// Find map option

src/plugins/grass/qgsgrassmodule.h

+3
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,9 @@ class QgsGrassModuleInput: public QgsGrassModuleGroupBoxItem
638638

639639
//! Uses region
640640
bool mUsesRegion;
641+
642+
//! Required field
643+
bool mRequired;
641644
};
642645

643646
/*********************** QgsGrassModuleGdalInput **********************/

0 commit comments

Comments
 (0)