@@ -809,31 +809,31 @@ bool QgsGrassModuleStandardOptions::usesRegion ()
809
809
#ifdef QGISDEBUG
810
810
std::cerr << " QgsGrassModuleStandardOptions::usesRegion()" << std::endl;
811
811
#endif
812
-
812
+
813
813
for ( int i = 0 ; i < mItems .size (); i++ )
814
814
{
815
815
if ( typeid (*(mItems [i])) == typeid (QgsGrassModuleInput) )
816
816
{
817
817
QgsGrassModuleInput *item =
818
818
dynamic_cast <QgsGrassModuleInput *>(mItems [i]);
819
819
820
- if ( item->type () == QgsGrassModuleInput::Raster )
820
+ if ( item->useRegion () )
821
821
return true ;
822
822
}
823
823
824
+ /* It only make sense to check input, right?
825
+ * Output has no region yet */
824
826
if ( typeid (*(mItems [i])) == typeid (QgsGrassModuleOption) )
825
827
{
826
828
QgsGrassModuleOption *item =
827
829
dynamic_cast <QgsGrassModuleOption *> ( mItems [i] );
828
830
829
- if ( item->isOutput ()
830
- && item->outputType () == QgsGrassModuleOption::Raster )
831
- {
831
+ if ( item->usesRegion () )
832
832
return true ;
833
- }
834
833
}
835
834
}
836
835
836
+ std::cerr << " NO usesRegion()" << std::endl;
837
837
return false ;
838
838
}
839
839
@@ -1583,6 +1583,23 @@ QgsGrassModuleOption::QgsGrassModuleOption ( QgsGrassModule *module, QString key
1583
1583
}
1584
1584
}
1585
1585
}
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;
1586
1603
}
1587
1604
1588
1605
void QgsGrassModuleOption::addLineEdit ()
@@ -1908,8 +1925,11 @@ QgsGrassModuleInput::QgsGrassModuleInput ( QgsGrassModule *module,
1908
1925
QSizePolicy:: Preferred );
1909
1926
l->addWidget ( mLayerComboBox );
1910
1927
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
+ )
1913
1933
{
1914
1934
QString iconPath = QgsApplication::themePath () + " /grass/" ;
1915
1935
@@ -1943,6 +1963,18 @@ QgsGrassModuleInput::QgsGrassModuleInput ( QgsGrassModule *module,
1943
1963
connect ( mapInput, SIGNAL (valueChanged ()), this , SLOT (updateQgisLayers ()) );
1944
1964
}
1945
1965
}
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
+ }
1946
1978
1947
1979
// Fill in QGIS layers
1948
1980
updateQgisLayers ();
@@ -1952,7 +1984,7 @@ bool QgsGrassModuleInput::useRegion()
1952
1984
{
1953
1985
std::cerr << " QgsGrassModuleInput::useRegion()" << std::endl;
1954
1986
1955
- if ( mType == Raster && mRegionButton &&
1987
+ if ( mUsesRegion && mType == Raster && mRegionButton &&
1956
1988
mRegionButton ->isChecked () )
1957
1989
{
1958
1990
return true ;
@@ -2344,8 +2376,11 @@ QgsGrassModuleGdalInput::QgsGrassModuleGdalInput (
2344
2376
2345
2377
// Connect to canvas
2346
2378
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 ()) );
2349
2384
2350
2385
// Fill in QGIS layers
2351
2386
updateQgisLayers ();
0 commit comments