File tree 2 files changed +18
-0
lines changed
2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -2633,6 +2633,13 @@ QgsGrassModuleGdalInput::QgsGrassModuleGdalInput(
2633
2633
}
2634
2634
adjustTitle ();
2635
2635
2636
+ // Check if this parameter is required
2637
+ if (gnode.toElement ().attribute (" required" ) == " yes" ) {
2638
+ mRequired = true ;
2639
+ } else {
2640
+ mRequired = false ;
2641
+ }
2642
+
2636
2643
QDomNode promptNode = gnode.namedItem ( " gisprompt" );
2637
2644
QDomElement promptElem = promptNode.toElement ();
2638
2645
QString element = promptElem.attribute ( " element" );
@@ -2700,6 +2707,14 @@ void QgsGrassModuleGdalInput::updateQgisLayers()
2700
2707
mUri .resize ( 0 );
2701
2708
mOgrLayers .resize ( 0 );
2702
2709
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
+
2703
2718
QgsMapCanvas *canvas = mModule ->qgisIface ()->mapCanvas ();
2704
2719
2705
2720
int nlayers = canvas->layerCount ();
Original file line number Diff line number Diff line change @@ -695,6 +695,9 @@ class QgsGrassModuleGdalInput: public QgsGrassModuleGroupBoxItem
695
695
696
696
// ! Ogr where clauses
697
697
std::vector<QString> mOgrWheres ;
698
+
699
+ // ! Required field
700
+ bool mRequired ;
698
701
};
699
702
700
703
/* ********************** QgsGrassModuleField **********************/
You can’t perform that action at this time.
0 commit comments