QGIS API Documentation  2.99.0-Master (716ff6c)
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 #include "qgis_core.h"
28 
29 class QgsMessageOutput;
30 
36 class CORE_EXPORT QgsRunProcess: public QObject
37 {
38  Q_OBJECT
39 
40  public:
41  // This class deletes itself, so to ensure that it is only created
42  // using new, the Named Consturctor Idiom is used, and one needs to
43  // use the create() static function to get an instance of this class.
44 
45  // The action argument contains string with the command.
46  // If capture is true, the standard output and error from the process
47  // will be sent to QgsMessageOutput - usually a dialog box.
48  static QgsRunProcess *create( const QString &action, bool capture )
49  { return new QgsRunProcess( action, capture ); }
50 
51  public slots:
52  void stdoutAvailable();
53  void stderrAvailable();
54  void processError( QProcess::ProcessError );
55  void processExit( int, QProcess::ExitStatus );
56  void dialogGone();
57 
58  private:
59  QgsRunProcess( const QString &action, bool capture );
60  ~QgsRunProcess();
61 
62  // Deletes the instance of the class
63  void die();
64 
65  QProcess *mProcess = nullptr;
66  QgsMessageOutput *mOutput = nullptr;
67  QString mCommand;
68 };
69 
70 #endif
A class that executes an external program/script.
Definition: qgsrunprocess.h:36
static QgsRunProcess * create(const QString &action, bool capture)
Definition: qgsrunprocess.h:48
Interface for showing messages from QGIS in GUI independent way.