1
/***************************************************************************
2
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
4
* This program is free software; you can redistribute it and/or modify *
5
* it under the terms of the GNU General Public License as published by *
6
* the Free Software Foundation; either version 2 of the License, or *
7
* (at your option) any later version. *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program; if not, write to the *
16
* Free Software Foundation, Inc., *
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18
***************************************************************************/
20
#if !defined(EXTERNALCOMMAND__H)
22
#define EXTERNALCOMMAND__H
25
#include <QStringList>
31
/** @brief An external command.
33
Runs an external command as a child process.
37
class ExternalCommand : public QProcess
40
Q_DISABLE_COPY(ExternalCommand)
43
explicit ExternalCommand(const QString& cmd = QString(), const QStringList& args = QStringList());
44
explicit ExternalCommand(Report& report, const QString& cmd = QString(), const QStringList& args = QStringList());
47
void setCommand(const QString& cmd) { m_Command = cmd; } /**< @param cmd the command to run */
48
const QString& command() const { return m_Command; } /**< @return the command to run */
50
void addArg(const QString& s) { m_Args << s; } /**< @param s the argument to add */
51
const QStringList& args() const { return m_Args; } /**< @return the arguments */
52
void setArgs(const QStringList& args) { m_Args = args; } /**< @param args the new arguments */
54
bool start(int timeout = 30000);
55
bool waitFor(int timeout = 30000);
56
bool run(int timeout = 30000);
58
int exitCode() const { return m_ExitCode; } /**< @return the exit code */
60
const QString& output() const { return m_Output; } /**< @return the command output */
62
Report* report() { return m_Report; } /**< @return pointer to the Report or NULL */
65
void setExitCode(int i) { m_ExitCode = i; }
69
void onFinished(int exitCode);