Skip to content

Commit

Permalink
check if mapcalc output exists
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@4892 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed Feb 21, 2006
1 parent c7b60f8 commit 23ad009
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
26 changes: 26 additions & 0 deletions src/plugins/grass/qgsgrassmapcalc.cpp
Expand Up @@ -486,6 +486,32 @@ QStringList QgsGrassMapcalc::arguments()
return QStringList ( cmd );
}

QStringList QgsGrassMapcalc::checkOutput()
{
#ifdef QGISDEBUG
std::cerr << "QgsGrassMapcalc::checkOutput()" << std::endl;
#endif
QStringList list;

QString value = mOutputLineEdit->text().trimmed();

if ( value.length() == 0 ) return QStringList();

QString path = QgsGrass::getDefaultGisdbase() + "/"
+ QgsGrass::getDefaultLocation() + "/"
+ QgsGrass::getDefaultMapset()
+ "/cell/" + value;

QFileInfo fi(path);

if ( fi.exists() )
{
return ( QStringList(value) );
}

return QStringList();
}

QgsGrassMapcalc::~QgsGrassMapcalc()
{
}
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/grass/qgsgrassmapcalc.h
Expand Up @@ -85,6 +85,10 @@ class QgsGrassMapcalc: public QMainWindow, private Ui::QgsGrassMapcalcBase,
//! Get module options as list of arguments for QProcess
QStringList arguments();

//! Check if output exists, reimplemented method from
// QgsGrassModuleOptions
QStringList checkOutput();

/** \brief recieves contentsMousePressEvent from view */
void contentsMousePressEvent(QMouseEvent*);

Expand Down
13 changes: 9 additions & 4 deletions src/plugins/grass/qgsgrassmodule.cpp
Expand Up @@ -627,8 +627,12 @@ void QgsGrassModule::run()

if ( ret == QMessageBox::No ) return;

mProcess.addArgument( "--o" );
command.append ( " --o" );
// r.mapcalc does not use standard parser
if ( typeid(*mOptions) != typeid(QgsGrassMapcalc) )
{
mProcess.addArgument( "--o" );
command.append ( " --o" );
}
}

QStringList list = mOptions->arguments();
Expand Down Expand Up @@ -1168,7 +1172,7 @@ QStringList QgsGrassModuleStandardOptions::checkOutput()
QString out = opt->outputExists();
if ( !out.isNull() )
{
list.append ( opt->key()+ ":" + out );
list.append ( out );
}
}
}
Expand Down Expand Up @@ -1255,6 +1259,7 @@ void QgsGrassModuleInput::updateQgisLayers()
//QDir locDir ( sep + split.join ( QString(sep) ) ) ;
//QString loc = locDir.canonicalPath();
QString loc = source.remove ( QRegExp("/[^/]+/[^/]+/[^/]+$") );
loc = QDir(loc).canonicalPath();

QDir curlocDir ( QgsGrass::getDefaultGisdbase() + sep + QgsGrass::getDefaultLocation() );
QString curloc = curlocDir.canonicalPath();
Expand All @@ -1267,7 +1272,7 @@ void QgsGrassModuleInput::updateQgisLayers()
#endif

if ( loc != curloc ) continue;

if ( mUpdate && mapset != QgsGrass::getDefaultMapset() ) continue;

// Check if it comes from source map if necessary
Expand Down

0 comments on commit 23ad009

Please sign in to comment.