Skip to content

Commit

Permalink
Added the possibility to unselect an optional (required="no" into int…
Browse files Browse the repository at this point in the history
…erface-description of the grass module) to fix #1134.

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11328 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rugginoso committed Aug 10, 2009
1 parent 6a10de8 commit ee75633
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/plugins/grass/qgsgrassmodule.cpp
Expand Up @@ -1992,7 +1992,7 @@ QgsGrassModuleInput::QgsGrassModuleInput( QgsGrassModule *module,
: QgsGrassModuleGroupBoxItem( module, key, qdesc, gdesc, gnode, parent ),
mModuleStandardOptions( options ),
mGeometryTypeOption( 0 ), mVectorLayerOption( 0 ),
mRegionButton( 0 ), mUpdate( false )
mRegionButton( 0 ), mUpdate( false ), mRequired( false )
{
QgsDebugMsg( "called." );
mGeometryTypeMask = GV_POINT | GV_LINE | GV_AREA;
Expand All @@ -2003,6 +2003,13 @@ QgsGrassModuleInput::QgsGrassModuleInput( QgsGrassModule *module,
}
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" );
Expand Down Expand Up @@ -2212,6 +2219,15 @@ void QgsGrassModuleInput::updateQgisLayers()
mMapLayers.resize( 0 );
mVectorFields.resize( 0 );

// If not required, add an empty item to combobox and a padding item into
// layer containers.
if (!mRequired){
mMaps.push_back(QString(""));
mVectorLayerNames.push_back(QString(""));
mMapLayers.push_back(NULL);
mLayerComboBox->addItem(tr("Select a layer"), QVariant());
}

QgsMapCanvas *canvas = mModule->qgisIface()->mapCanvas();

// Find map option
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/grass/qgsgrassmodule.h
Expand Up @@ -638,6 +638,9 @@ class QgsGrassModuleInput: public QgsGrassModuleGroupBoxItem

//! Uses region
bool mUsesRegion;

//! Required field
bool mRequired;
};

/*********************** QgsGrassModuleGdalInput **********************/
Expand Down

0 comments on commit ee75633

Please sign in to comment.