Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
qgsrunprocess.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrunprocess.h
3 
4  A class that runs an external program
5 
6  -------------------
7  begin : Jan 2005
8  copyright : (C) 2005 by Gavin Macaulay
9  email : gavin at macaulay dot co dot nz
10  ***************************************************************************/
11 
12 /***************************************************************************
13  * *
14  * This program is free software; you can redistribute it and/or modify *
15  * it under the terms of the GNU General Public License as published by *
16  * the Free Software Foundation; either version 2 of the License, or *
17  * (at your option) any later version. *
18  * *
19  ***************************************************************************/
20 /* $Id$ */
21 
22 #ifndef QGSRUNPROCESS_H
23 #define QGSRUNPROCESS_H
24 
25 #include <QObject>
26 #include <QProcess>
27 
28 class QgsMessageOutput;
29 
35 class CORE_EXPORT QgsRunProcess: public QObject
36 {
37  Q_OBJECT
38 
39  public:
40  // This class deletes itself, so to ensure that it is only created
41  // using new, the Named Consturctor Idiom is used, and one needs to
42  // use the create() static function to get an instance of this class.
43 
44  // The action argument contains string with the command.
45  // If capture is true, the standard output and error from the process
46  // will be sent to QgsMessageOuptut - usually a dialog box.
47  static QgsRunProcess* create( const QString& action, bool capture )
48  { return new QgsRunProcess( action, capture ); }
49 
50  public slots:
51  void stdoutAvailable();
52  void stderrAvailable();
53  void processError( QProcess::ProcessError );
54  void processExit( int, QProcess::ExitStatus );
55  void dialogGone();
56 
57  private:
58  QgsRunProcess( const QString& action, bool capture );
59  ~QgsRunProcess();
60 
61  // Deletes the instance of the class
62  void die();
63 
64  QProcess* mProcess;
66  QString mCommand;
67 };
68 
69 #endif