process.cpp
author insilmaril
Tue, 02 Mar 2010 13:59:19 +0000
changeset 825 1ad892c1a709
parent 429 69a4c16bd85b
permissions -rw-r--r--
Added file for later dockwidget showing all search results at once
     1 #include "process.h"
     2 
     3 #include <QMessageBox>
     4 #include <QDebug>
     5 
     6 extern bool debug;
     7 
     8 /////////////////////////////////////////////////////////////////
     9 // Process
    10 /////////////////////////////////////////////////////////////////
    11 Process::Process()
    12 {
    13 	connect( this, SIGNAL(readyReadStandardError()),
    14 			 this, SLOT(readProcErrout()) );
    15 	connect( this, SIGNAL(readyReadStandardOutput()),
    16 			 this, SLOT(readProcStdout()) );
    17 	clear();		 
    18 }
    19 
    20 Process::~Process()
    21 {
    22 }
    23 
    24 void Process::clear()
    25 {
    26 	errOut="";
    27 	stdOut="";
    28 }
    29 
    30 void Process::runScript(QString spath, QString fpath)
    31 {
    32 	spath.replace ("%f",fpath);
    33 	QStringList args=QStringList::split (' ',spath,false);
    34 	spath=args.takeFirst();
    35 		
    36 	if (debug)
    37 		qDebug()<<"Process::runScript : " + spath+" "+args.join(" ");	
    38 
    39 	start (spath,args);
    40 	if (!waitForStarted() )
    41 	{
    42 		QMessageBox::critical( 0, tr( "Critical Error" ),
    43 					   tr("Could not start %1").arg(spath) );
    44 	} else
    45 	{
    46 		if (!waitForFinished())
    47 			QMessageBox::critical( 0, tr( "Critical Error" ),
    48 			   tr("%1 didn't exit normally").arg(spath) +
    49 			   getErrout() );
    50 	//	else
    51 	//		if (exitStatus()>0) showOutput=true;
    52 			
    53 	}	
    54 	/* FIXME-3	output for Process::runScript
    55 	qDebug()<<readAllStandardOutput();
    56 	qDebug()<<getStdout();
    57 	qDebug()<<getErrout();
    58 	addOutput ("\n");
    59 	addOutput (getErrout());
    60 	addOutput (getStdout());
    61 	*/
    62 }
    63 
    64 void Process::readProcErrout()
    65 {
    66 	errOut+=readAllStandardError();
    67 }
    68 
    69 void Process::readProcStdout()
    70 {
    71 	stdOut+=readAllStandardOutput();
    72 }
    73 
    74 QString Process::getErrout()
    75 {
    76 	return errOut;
    77 }
    78 
    79 QString Process::getStdout()
    80 {
    81 	return stdOut;
    82 }