00001 /*************************************************************************** 00002 qgsrunprocess.h 00003 00004 A class that runs an external program 00005 00006 ------------------- 00007 begin : Jan 2005 00008 copyright : (C) 2005 by Gavin Macaulay 00009 email : gavin at macaulay dot co dot nz 00010 ***************************************************************************/ 00011 00012 /*************************************************************************** 00013 * * 00014 * This program is free software; you can redistribute it and/or modify * 00015 * it under the terms of the GNU General Public License as published by * 00016 * the Free Software Foundation; either version 2 of the License, or * 00017 * (at your option) any later version. * 00018 * * 00019 ***************************************************************************/ 00020 /* $Id$ */ 00021 00022 #ifndef QGSRUNPROCESS_H 00023 #define QGSRUNPROCESS_H 00024 00025 #include <QObject> 00026 #include <QProcess> 00027 00028 class QgsMessageOutput; 00029 00035 class CORE_EXPORT QgsRunProcess: public QObject 00036 { 00037 Q_OBJECT 00038 00039 public: 00040 // This class deletes itself, so to ensure that it is only created 00041 // using new, the Named Consturctor Idiom is used, and one needs to 00042 // use the create() static function to get an instance of this class. 00043 00044 // The action argument contains string with the command. 00045 // If capture is true, the standard output and error from the process 00046 // will be sent to QgsMessageOuptut - usually a dialog box. 00047 static QgsRunProcess* create( const QString& action, bool capture ) 00048 { return new QgsRunProcess( action, capture ); } 00049 00050 public slots: 00051 void stdoutAvailable(); 00052 void stderrAvailable(); 00053 void processError( QProcess::ProcessError ); 00054 void processExit( int, QProcess::ExitStatus ); 00055 void dialogGone(); 00056 00057 private: 00058 QgsRunProcess( const QString& action, bool capture ); 00059 ~QgsRunProcess(); 00060 00061 // Deletes the instance of the class 00062 void die(); 00063 00064 QProcess* mProcess; 00065 QgsMessageOutput* mOutput; 00066 QString mCommand; 00067 }; 00068 00069 #endif