Skip to content

Commit d5e0f5a

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/qgis@11329 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent ee75633 commit d5e0f5a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/plugins/grass/qgsgrassmodule.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -2633,6 +2633,13 @@ QgsGrassModuleGdalInput::QgsGrassModuleGdalInput(
26332633
}
26342634
adjustTitle();
26352635

2636+
// Check if this parameter is required
2637+
if (gnode.toElement().attribute("required") == "yes") {
2638+
mRequired = true;
2639+
} else {
2640+
mRequired = false;
2641+
}
2642+
26362643
QDomNode promptNode = gnode.namedItem( "gisprompt" );
26372644
QDomElement promptElem = promptNode.toElement();
26382645
QString element = promptElem.attribute( "element" );
@@ -2700,6 +2707,14 @@ void QgsGrassModuleGdalInput::updateQgisLayers()
27002707
mUri.resize( 0 );
27012708
mOgrLayers.resize( 0 );
27022709

2710+
// If not required, add an empty item to combobox and a padding item into
2711+
// layer containers.
2712+
if (!mRequired){
2713+
mUri.push_back(QString());
2714+
mOgrLayers.push_back(QString());
2715+
mLayerComboBox->addItem(tr("Select a layer"), QVariant());
2716+
}
2717+
27032718
QgsMapCanvas *canvas = mModule->qgisIface()->mapCanvas();
27042719

27052720
int nlayers = canvas->layerCount();

src/plugins/grass/qgsgrassmodule.h

+3
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,9 @@ class QgsGrassModuleGdalInput: public QgsGrassModuleGroupBoxItem
695695

696696
//! Ogr where clauses
697697
std::vector<QString> mOgrWheres;
698+
699+
//! Required field
700+
bool mRequired;
698701
};
699702

700703
/*********************** QgsGrassModuleField **********************/

0 commit comments

Comments
 (0)