Skip to content

Commit

Permalink
better error message
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5109 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed Mar 29, 2006
1 parent c84a078 commit 6bde5e0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/plugins/grass/qgsgrassbrowser.cpp
Expand Up @@ -219,6 +219,11 @@ void QgsGrassBrowser::doubleClicked(const QModelIndex & index)
addMap();
}

QString QgsGrassBrowser::formatMessage( QString msg )
{
return msg.replace("<","&lt;").replace(">","&gt;").replace("\n","<br>");
}

void QgsGrassBrowser::copyMap()
{
#ifdef QGISDEBUG
Expand Down Expand Up @@ -274,14 +279,17 @@ void QgsGrassBrowser::copyMap()
module.append(".exe");
#endif
QProcess process(this);
process.start(module, QStringList( typeName + "=" + map + "@" + mapset + "," + newName ) );
QStringList args(typeName + "=" + map + "@" + mapset + "," + newName );
process.start(module, args );
if ( !process.waitForFinished() || process.exitCode() != 0 )
{
QString output ( process.readAllStandardOutput () );
QString error ( process.readAllStandardError () );
QMessageBox::warning( 0, "Warning", "Cannot copy map "
+ map + "@" + mapset + "<br>" + output.replace("\n","<br>")
+ "<br>" + error.replace("\n","<br>") );
+ map + "@" + mapset
+ "<br>command: " + module + " " + args.join(" ")
+ "<br>" + formatMessage(output)
+ "<br>" + formatMessage(error) );
}
else
{
Expand Down Expand Up @@ -337,14 +345,17 @@ void QgsGrassBrowser::renameMap()
module.append(".exe");
#endif
QProcess process(this);
QStringList args(typeName + "=" + map + "," + newName );
process.start(module, QStringList( typeName + "=" + map + "," + newName ) );
if ( !process.waitForFinished() || process.exitCode() != 0 )
{
QString output ( process.readAllStandardOutput () );
QString error ( process.readAllStandardError () );
QMessageBox::warning( 0, "Warning", "Cannot rename map "
+ map + "<br>" + output.replace("\n","<br>")
+ "<br>" + error.replace("\n","<br>") );
+ map
+ "<br>command: " + module + " " + args.join(" ")
+ "<br>" + formatMessage(output)
+ "<br>" + formatMessage(error) );
}
else
{
Expand Down Expand Up @@ -389,14 +400,17 @@ void QgsGrassBrowser::deleteMap()
module.append(".exe");
#endif
QProcess process(this);
QStringList args(typeName + "=" + map );
process.start(module, QStringList( typeName + "=" + map ) );
if ( !process.waitForFinished() || process.exitCode() != 0 )
{
QString output ( process.readAllStandardOutput () );
QString error ( process.readAllStandardError () );
QMessageBox::warning( 0, "Warning", "Cannot delete map "
+ map + "<br>" + output.replace("\n","<br>")
+ "<br>" + error.replace("\n","<br>") );
+ map
+ "<br>command: " + module + " " + args.join(" ")
+ "<br>" + formatMessage(output)
+ "<br>" + formatMessage(error) );
}
else
{
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/grass/qgsgrassbrowser.h
Expand Up @@ -101,6 +101,9 @@ public slots:
QAction *mActionRenameMap;
QAction *mActionSetRegion;
QAction *mActionRefresh;

//! Escape HTML tags and convert \n to <br>
QString formatMessage ( QString msg );
};

#endif // QGSGRASSBROWSER_H

0 comments on commit 6bde5e0

Please sign in to comment.