process.cpp
author insilmaril
Fri, 08 Dec 2006 20:18:58 +0000
changeset 409 81ffad43d53f
parent 408 c2a05fa925a1
child 414 bc23a0157a39
permissions -rw-r--r--
1.6.1 Port to QGraphics
insilmaril@0
     1
#include "process.h"
insilmaril@0
     2
insilmaril@0
     3
/////////////////////////////////////////////////////////////////
insilmaril@0
     4
// Process
insilmaril@0
     5
/////////////////////////////////////////////////////////////////
insilmaril@0
     6
Process::Process()
insilmaril@0
     7
{
insilmaril@408
     8
	connect( this, SIGNAL(readyReadStandardError()),
insilmaril@0
     9
			 this, SLOT(readProcErrout()) );
insilmaril@408
    10
	connect( this, SIGNAL(readyReadStandardOutput()),
insilmaril@0
    11
			 this, SLOT(readProcStdout()) );
insilmaril@0
    12
	clear();		 
insilmaril@0
    13
}
insilmaril@0
    14
insilmaril@0
    15
Process::~Process()
insilmaril@0
    16
{
insilmaril@0
    17
}
insilmaril@0
    18
insilmaril@0
    19
void Process::clear()
insilmaril@0
    20
{
insilmaril@0
    21
	errOut="";
insilmaril@0
    22
	stdOut="";
insilmaril@0
    23
}
insilmaril@0
    24
insilmaril@0
    25
void Process::waitFinished()
insilmaril@0
    26
{
insilmaril@408
    27
	while (state()==QProcess::Running)
insilmaril@0
    28
	{
insilmaril@216
    29
		// FIXME use some kind of sleep here...
insilmaril@216
    30
		system ("sleep 1");
insilmaril@0
    31
	}
insilmaril@0
    32
}
insilmaril@0
    33
insilmaril@0
    34
void Process::readProcErrout()
insilmaril@0
    35
{
insilmaril@408
    36
	errOut+=readAllStandardError();
insilmaril@0
    37
}
insilmaril@0
    38
insilmaril@0
    39
void Process::readProcStdout()
insilmaril@0
    40
{
insilmaril@408
    41
	stdOut+=readAllStandardOutput();
insilmaril@0
    42
}
insilmaril@0
    43
insilmaril@0
    44
QString Process::getErrout()
insilmaril@0
    45
{
insilmaril@0
    46
	return errOut;
insilmaril@0
    47
}
insilmaril@0
    48
insilmaril@0
    49
QString Process::getStdout()
insilmaril@0
    50
{
insilmaril@0
    51
	return stdOut;
insilmaril@0
    52
}