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