void ProcessWidget::slotProcessExited(KProcess *)
{
    procLineMaker->flush();
    if( !stdoutbuf.isEmpty() ) 
        insertStdoutLine("");
    if( !stderrbuf.isEmpty() ) 
        insertStderrLine("");
    childFinished(childproc->normalExit(), childproc->exitStatus());
    maybeScrollToBottom();
    emit processExited(childproc);
}
bool ProcessWidget::startJob(const QString &dir, const QString &command)
{
    procLineMaker->reset();
    clear();
    addItem(new ProcessListBoxItem(command, ProcessListBoxItem::Diagnostic));
    if(!dir.isEmpty()) {
        childproc->setWorkingDirectory(dir);
    }
    childproc->start(command);
    bool childProcStarted = childproc->waitForStarted();
    if (!childProcStarted) {
        insertStderrLine(childproc->errorString());
        childFinished((childproc->exitStatus() == QProcess::NormalExit), childproc->exitStatus());
        emit processNotStarted();
    }
    return childProcStarted;
}
ProcessWidget::ProcessWidget(QWidget *parent, const char *name)
    : QListWidget(parent)
{   
    //No selection will be possible
    setSelectionMode(QAbstractItemView::NoSelection);
    
    setFocusPolicy(Qt::NoFocus);
    QPalette pal = palette();
    pal.setColor(QPalette::HighlightedText,
                 pal.color(QPalette::Normal, QPalette::Text));
    pal.setColor(QPalette::Highlight,
                 pal.color(QPalette::Normal, QPalette::Mid));
    setPalette(pal);

    setCursor(QCursor(Qt::ArrowCursor));

    //Create the process
    childproc = new QProcess();

    procLineMaker = new ProcessLineMaker( childproc );

    connect( procLineMaker, SIGNAL(receivedStdoutLine(QString)),
             this, SLOT(insertStdoutLine(QString)));
    connect( procLineMaker, SIGNAL(receivedStderrLine(QString)),
             this, SLOT(insertStderrLine(QString)));
    connect( procLineMaker, SIGNAL(outputTreatmentOver()),
             this, SLOT(slotOutputTreatmentOver()));

    connect(this, SIGNAL(hidden()),
            procLineMaker, SLOT(slotWidgetHidden()));

    connect(childproc, SIGNAL(finished(int,QProcess::ExitStatus)),
            this, SLOT(slotProcessExited(int,QProcess::ExitStatus))) ;
    connect(this, SIGNAL(finished(int,QProcess::ExitStatus)),
            procLineMaker, SLOT(slotProcessExited()));
}