@@ -580,9 +580,13 @@ QStringList QgsGrassModuleStandardOptions::checkRegion()
580
580
break ;
581
581
}
582
582
583
+ QStringList mm = item->currentMap ().split (" @" );
584
+ QString map = mm.at (0 );
585
+ QString mapset = QgsGrass::getDefaultMapset ();
586
+ if ( mm.size () > 1 ) mapset = mm.at (1 );
583
587
if ( !QgsGrass::mapRegion ( mapType,
584
588
QgsGrass::getDefaultGisdbase (),
585
- QgsGrass::getDefaultLocation (), " " , item-> currentMap () ,
589
+ QgsGrass::getDefaultLocation (), mapset, map ,
586
590
&window ) )
587
591
{
588
592
QMessageBox::warning ( 0 , " Warning" , " Cannot check region "
@@ -623,13 +627,13 @@ bool QgsGrassModuleStandardOptions::inputRegion ( struct Cell_head *window, bool
623
627
continue ;
624
628
}
625
629
626
- // TODO all flag
627
-
628
630
struct Cell_head mapWindow;
629
631
630
632
QgsGrassModuleInput *item = dynamic_cast <QgsGrassModuleInput *>
631
633
(mItems [i]);
632
634
635
+ if ( !all && !item->useRegion () ) continue ;
636
+
633
637
int mapType;
634
638
switch ( item->type () ) {
635
639
case QgsGrassModuleInput::Raster :
@@ -640,9 +644,13 @@ bool QgsGrassModuleStandardOptions::inputRegion ( struct Cell_head *window, bool
640
644
break ;
641
645
}
642
646
647
+ QStringList mm = item->currentMap ().split (" @" );
648
+ QString map = mm.at (0 );
649
+ QString mapset = QgsGrass::getDefaultMapset ();
650
+ if ( mm.size () > 1 ) mapset = mm.at (1 );
643
651
if ( !QgsGrass::mapRegion ( mapType,
644
652
QgsGrass::getDefaultGisdbase (),
645
- QgsGrass::getDefaultLocation (), " " , item-> currentMap () ,
653
+ QgsGrass::getDefaultLocation (), mapset, map ,
646
654
&mapWindow ) )
647
655
{
648
656
QMessageBox::warning ( 0 , " Warning" , " Cannot set region "
@@ -676,6 +684,26 @@ bool QgsGrassModuleStandardOptions::inputRegion ( struct Cell_head *window, bool
676
684
return true ;
677
685
}
678
686
687
+ bool QgsGrassModuleStandardOptions::requestsRegion ()
688
+ {
689
+ #ifdef QGISDEBUG
690
+ std::cerr << " QgsGrassModuleStandardOptions::requestsRegion()" << std::endl;
691
+ #endif
692
+
693
+ for ( int i = 0 ; i < mItems .size (); i++ )
694
+ {
695
+ if ( typeid (*(mItems [i])) != typeid (QgsGrassModuleInput) ) {
696
+ continue ;
697
+ }
698
+
699
+ QgsGrassModuleInput *item = dynamic_cast <QgsGrassModuleInput *>
700
+ (mItems [i]);
701
+
702
+ if ( item->useRegion () ) return true ;
703
+ }
704
+ return false ;
705
+ }
706
+
679
707
bool QgsGrassModuleStandardOptions::usesRegion ()
680
708
{
681
709
#ifdef QGISDEBUG
@@ -1559,10 +1587,11 @@ QgsGrassModuleInput::QgsGrassModuleInput ( QgsGrassModule *module,
1559
1587
QgsGrassModuleStandardOptions *options, QString key,
1560
1588
QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode,
1561
1589
QWidget * parent)
1562
- : Q3GroupBox ( 1 , Qt::Vertical, parent ),
1590
+ : QGroupBox ( parent ),
1563
1591
QgsGrassModuleItem ( module, key, qdesc, gdesc, gnode ),
1564
1592
mModuleStandardOptions(options),
1565
- mUpdate(false ), mVectorTypeOption(0 ), mVectorLayerOption(0 )
1593
+ mUpdate(false ), mVectorTypeOption(0 ), mVectorLayerOption(0 ),
1594
+ mRegionButton(0 )
1566
1595
{
1567
1596
#ifdef QGISDEBUG
1568
1597
std::cerr << " QgsGrassModuleInput::QgsGrassModuleInput" << std::endl;
@@ -1692,7 +1721,26 @@ QgsGrassModuleInput::QgsGrassModuleInput ( QgsGrassModule *module,
1692
1721
mUpdate = true ;
1693
1722
}
1694
1723
1695
- mLayerComboBox = new QComboBox ( this );
1724
+ QHBoxLayout *l = new QHBoxLayout (this );
1725
+ mLayerComboBox = new QComboBox ();
1726
+ mLayerComboBox ->setSizePolicy (QSizePolicy::Expanding,
1727
+ QSizePolicy:: Preferred );
1728
+ l->addWidget ( mLayerComboBox );
1729
+
1730
+ if ( mType == Raster &&
1731
+ QgsGrass::versionMajor () >= 6 && QgsGrass::versionMinor () >= 1 )
1732
+ {
1733
+ QString iconPath = QgsApplication::themePath () + " /grass/" ;
1734
+
1735
+ mRegionButton = new QPushButton (
1736
+ QIcon (iconPath+" grass_set_region.png" ), " " );
1737
+
1738
+ mRegionButton ->setToolTip ( " Use region of this map" );
1739
+ mRegionButton ->setCheckable ( true );
1740
+ mRegionButton ->setSizePolicy (QSizePolicy::Minimum,
1741
+ QSizePolicy:: Preferred );
1742
+ l->addWidget ( mRegionButton );
1743
+ }
1696
1744
1697
1745
// Of course, activated(int) is not enough, but there is no signal BEFORE the cobo is opened
1698
1746
// connect ( mLayerComboBox, SIGNAL( activated(int) ), this, SLOT(updateQgisLayers()) );
@@ -1719,6 +1767,19 @@ QgsGrassModuleInput::QgsGrassModuleInput ( QgsGrassModule *module,
1719
1767
updateQgisLayers ();
1720
1768
}
1721
1769
1770
+ bool QgsGrassModuleInput::useRegion ()
1771
+ {
1772
+ std::cerr << " QgsGrassModuleInput::useRegion()" << std::endl;
1773
+
1774
+ if ( mType == Raster && mRegionButton &&
1775
+ mRegionButton ->isChecked () )
1776
+ {
1777
+ return true ;
1778
+ }
1779
+
1780
+ return false ;
1781
+ }
1782
+
1722
1783
void QgsGrassModuleInput::updateQgisLayers ()
1723
1784
{
1724
1785
#ifdef QGISDEBUG
0 commit comments