@@ -809,31 +809,31 @@ bool QgsGrassModuleStandardOptions::usesRegion ()
809809 #ifdef QGISDEBUG
810810 std::cerr << " QgsGrassModuleStandardOptions::usesRegion()" << std::endl;
811811 #endif
812-
812+
813813 for ( int i = 0 ; i < mItems .size (); i++ )
814814 {
815815 if ( typeid (*(mItems [i])) == typeid (QgsGrassModuleInput) )
816816 {
817817 QgsGrassModuleInput *item =
818818 dynamic_cast <QgsGrassModuleInput *>(mItems [i]);
819819
820- if ( item->type () == QgsGrassModuleInput::Raster )
820+ if ( item->useRegion () )
821821 return true ;
822822 }
823823
824+ /* It only make sense to check input, right?
825+ * Output has no region yet */
824826 if ( typeid (*(mItems [i])) == typeid (QgsGrassModuleOption) )
825827 {
826828 QgsGrassModuleOption *item =
827829 dynamic_cast <QgsGrassModuleOption *> ( mItems [i] );
828830
829- if ( item->isOutput ()
830- && item->outputType () == QgsGrassModuleOption::Raster )
831- {
831+ if ( item->usesRegion () )
832832 return true ;
833- }
834833 }
835834 }
836835
836+ std::cerr << " NO usesRegion()" << std::endl;
837837 return false ;
838838}
839839
@@ -1583,6 +1583,23 @@ QgsGrassModuleOption::QgsGrassModuleOption ( QgsGrassModule *module, QString key
15831583 }
15841584 }
15851585 }
1586+
1587+ mUsesRegion = false ;
1588+ QString region = qdesc.attribute (" region" );
1589+ if ( region.length () > 0 )
1590+ {
1591+ if ( region == " yes" )
1592+ mUsesRegion = true ;
1593+ }
1594+ else
1595+ {
1596+ std::cerr << " \n\n\n\n **************************" << std::endl;
1597+ std::cerr << " isOutput = " << isOutput () << std::endl;
1598+ std::cerr << " mOutputType = " << mOutputType << std::endl;
1599+ if ( isOutput () && mOutputType == Raster )
1600+ mUsesRegion = true ;
1601+ }
1602+ std::cerr << " mUsesRegion = " << mUsesRegion << std::endl;
15861603}
15871604
15881605void QgsGrassModuleOption::addLineEdit ()
@@ -1908,8 +1925,11 @@ QgsGrassModuleInput::QgsGrassModuleInput ( QgsGrassModule *module,
19081925 QSizePolicy:: Preferred );
19091926 l->addWidget ( mLayerComboBox );
19101927
1911- if ( mType == Raster &&
1912- QgsGrass::versionMajor () >= 6 && QgsGrass::versionMinor () >= 1 )
1928+ QString region = qdesc.attribute (" region" );
1929+ if ( mType == Raster
1930+ && QgsGrass::versionMajor () >= 6 && QgsGrass::versionMinor () >= 1
1931+ && region != " no"
1932+ )
19131933 {
19141934 QString iconPath = QgsApplication::themePath () + " /grass/" ;
19151935
@@ -1943,6 +1963,18 @@ QgsGrassModuleInput::QgsGrassModuleInput ( QgsGrassModule *module,
19431963 connect ( mapInput, SIGNAL (valueChanged ()), this , SLOT (updateQgisLayers ()) );
19441964 }
19451965 }
1966+
1967+ mUsesRegion = false ;
1968+ if ( region.length () > 0 )
1969+ {
1970+ if ( region == " yes" )
1971+ mUsesRegion = true ;
1972+ }
1973+ else
1974+ {
1975+ if ( type () == Raster )
1976+ mUsesRegion = true ;
1977+ }
19461978
19471979 // Fill in QGIS layers
19481980 updateQgisLayers ();
@@ -1952,7 +1984,7 @@ bool QgsGrassModuleInput::useRegion()
19521984{
19531985 std::cerr << " QgsGrassModuleInput::useRegion()" << std::endl;
19541986
1955- if ( mType == Raster && mRegionButton &&
1987+ if ( mUsesRegion && mType == Raster && mRegionButton &&
19561988 mRegionButton ->isChecked () )
19571989 {
19581990 return true ;
@@ -2344,8 +2376,11 @@ QgsGrassModuleGdalInput::QgsGrassModuleGdalInput (
23442376
23452377 // Connect to canvas
23462378 QgsMapCanvas *canvas = mModule ->qgisIface ()->getMapCanvas ();
2347- connect ( canvas, SIGNAL (addedLayer (QgsMapLayer *)), this , SLOT (updateQgisLayers ()) );
2348- connect ( canvas, SIGNAL (removedLayer (QString)), this , SLOT (updateQgisLayers ()) );
2379+
2380+ // It seems that addedLayer/removedLayer does not work
2381+ // connect ( canvas, SIGNAL(addedLayer(QgsMapLayer *)), this, SLOT(updateQgisLayers()) );
2382+ // connect ( canvas, SIGNAL(removedLayer(QString)), this, SLOT(updateQgisLayers()) );
2383+ connect ( canvas, SIGNAL (layersChanged ()), this , SLOT (updateQgisLayers ()) );
23492384
23502385 // Fill in QGIS layers
23512386 updateQgisLayers ();
0 commit comments