QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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 
21 #ifndef QGSRUNPROCESS_H
22 #define QGSRUNPROCESS_H
23 
24 #include <QObject>
25 #include <QProcess>
26 
27 class QgsMessageOutput;
28 
34 class CORE_EXPORT QgsRunProcess: public QObject
35 {
36  Q_OBJECT
37 
38  public:
39  // This class deletes itself, so to ensure that it is only created
40  // using new, the Named Consturctor Idiom is used, and one needs to
41  // use the create() static function to get an instance of this class.
42 
43  // The action argument contains string with the command.
44  // If capture is true, the standard output and error from the process
45  // will be sent to QgsMessageOuptut - usually a dialog box.
46  static QgsRunProcess* create( const QString& action, bool capture )
47  { return new QgsRunProcess( action, capture ); }
48 
49  public slots:
50  void stdoutAvailable();
51  void stderrAvailable();
52  void processError( QProcess::ProcessError );
53  void processExit( int, QProcess::ExitStatus );
54  void dialogGone();
55 
56  private:
57  QgsRunProcess( const QString& action, bool capture );
58  ~QgsRunProcess();
59 
60  // Deletes the instance of the class
61  void die();
62 
63  QProcess* mProcess;
64  QgsMessageOutput* mOutput;
65  QString mCommand;
66 };
67 
68 #endif