Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
handle better mumltiple empty output
git-svn-id: http://svn.osgeo.org/qgis/trunk@12937 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed Feb 12, 2010
1 parent da64d77 commit 4952342
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/plugins/grass/qgsgrassmapcalc.h
Expand Up @@ -66,6 +66,7 @@ class QgsGrassMapcalc: public QMainWindow, private Ui::QgsGrassMapcalcBase,
QStringList checkRegion();
bool inputRegion( struct Cell_head *window, bool all );
QStringList output( int type );
bool hasOutput ( int type ) { return true; }

/** \brief recieves contentsMousePressEvent from view */
void mousePressEvent( QMouseEvent* );
Expand Down
31 changes: 27 additions & 4 deletions src/plugins/grass/qgsgrassmodule.cpp
Expand Up @@ -229,8 +229,8 @@ QgsGrassModule::QgsGrassModule( QgsGrassTools *tools, QString moduleName, QgisIn
}

// Hide display if there is no output
if ( mOptions->output( QgsGrassModuleOption::Vector ).size() == 0
&& mOptions->output( QgsGrassModuleOption::Raster ).size() == 0 )
if ( !mOptions->hasOutput( QgsGrassModuleOption::Vector )
&& !mOptions->hasOutput( QgsGrassModuleOption::Raster ) )
{
mViewButton->hide();
}
Expand Down Expand Up @@ -766,7 +766,6 @@ void QgsGrassModuleStandardOptions::thawOutput()
#endif
}


QStringList QgsGrassModuleStandardOptions::output( int type )
{
QgsDebugMsg( "called." );
Expand All @@ -785,14 +784,38 @@ QStringList QgsGrassModuleStandardOptions::output( int type )
if ( opt->outputType() == type )
{
QString out = opt->value();
list.append( out );
if ( !out.isEmpty() ) {
list.append( out );
}
}
}
}

return list;
}

bool QgsGrassModuleStandardOptions::hasOutput( int type )
{
QgsDebugMsg( "called." );
QStringList list;

for ( unsigned int i = 0; i < mItems.size(); i++ )
{
QgsGrassModuleOption *opt = dynamic_cast<QgsGrassModuleOption *>( mItems[i] );
if ( !opt )
continue;

QgsDebugMsg( "opt->key() = " + opt->key() );

if ( opt->isOutput() )
{
if ( opt->outputType() == type ) return true;
}
}

return false;
}

QStringList QgsGrassModuleStandardOptions::ready()
{
QgsDebugMsg( "entered." );
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/grass/qgsgrassmodule.h
Expand Up @@ -192,6 +192,9 @@ class QgsGrassModuleOptions
//! Get list of current output maps
virtual QStringList output( int type ) { return QStringList() ; }

//! Has any output
virtual bool hasOutput ( int type ) { return true; }

//! Has raster input or output
virtual bool usesRegion() { return false; }

Expand Down Expand Up @@ -265,6 +268,7 @@ class QgsGrassModuleStandardOptions: QWidget, public QgsGrassModuleOptions
void thawOutput();
QStringList ready() ;
QStringList output( int type );
bool hasOutput ( int type );
QStringList checkRegion();
bool usesRegion();
bool requestsRegion();
Expand Down

0 comments on commit 4952342

Please sign in to comment.