Quantum GIS API Documentation  1.8
src/core/qgsrunprocess.h
Go to the documentation of this file.
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 
00021 #ifndef QGSRUNPROCESS_H
00022 #define QGSRUNPROCESS_H
00023 
00024 #include <QObject>
00025 #include <QProcess>
00026 
00027 class QgsMessageOutput;
00028 
00034 class CORE_EXPORT QgsRunProcess: public QObject
00035 {
00036     Q_OBJECT
00037 
00038   public:
00039     // This class deletes itself, so to ensure that it is only created
00040     // using new, the Named Consturctor Idiom is used, and one needs to
00041     // use the create() static function to get an instance of this class.
00042 
00043     // The action argument contains string with the command.
00044     // If capture is true, the standard output and error from the process
00045     // will be sent to QgsMessageOuptut - usually a dialog box.
00046     static QgsRunProcess* create( const QString& action, bool capture )
00047     { return new QgsRunProcess( action, capture ); }
00048 
00049   public slots:
00050     void stdoutAvailable();
00051     void stderrAvailable();
00052     void processError( QProcess::ProcessError );
00053     void processExit( int, QProcess::ExitStatus );
00054     void dialogGone();
00055 
00056   private:
00057     QgsRunProcess( const QString& action, bool capture );
00058     ~QgsRunProcess();
00059 
00060     // Deletes the instance of the class
00061     void die();
00062 
00063     QProcess* mProcess;
00064     QgsMessageOutput* mOutput;
00065     QString mCommand;
00066 };
00067 
00068 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines