Пример #1
0
bool BatchJob::StartJob()
{

    process = new QProcess(this);
    process->setProcessChannelMode(QProcess::MergedChannels);
    process->setStandardOutputFile(logFile);
    process->setWorkingDirectory(workingDirectory_);

    QStringList env = QProcess::systemEnvironment();
    env += QString("MIFIT_DIR=") + Application::instance()->GetMolimageHome().c_str();
    env += QString("MIFIT_JOB_ID=") + QString::number(jobId_);
    env += QString("MIFIT_SOCKET_ID=") + MIMainWindow::instance()->scriptPort();
    process->setEnvironment(env);

    connect(process, SIGNAL(finished(int)),
            this, SLOT(doJobFinished()));
    connect(process, SIGNAL(finished(int)),
            this, SLOT(signalJobChanged()));

    process->start(program_, arguments_);
    process->closeWriteChannel();

    bool started = process->waitForStarted();
    if (!started)
    {
        QMessageBox::warning(NULL, "Job Error", QString("Unable to start job %1").arg(jobId_));
        delete process;
        process = NULL;
    }
    jobChanged(this);
    return started;
}
Пример #2
0
void KTimerPref::loadJobs( KConfig *cfg )
{
    const int num = cfg->group("Jobs").readEntry( "Number", 0 );
    for( int n=0; n<num; n++ ) {
            KTimerJob *job = new KTimerJob;
            KTimerJobItem *item = new KTimerJobItem( job, m_list );

            connect(job, &KTimerJob::delayChanged, this, &KTimerPref::jobChanged);
            connect(job, &KTimerJob::valueChanged, this, &KTimerPref::jobChanged);
            connect(job, &KTimerJob::stateChanged, this, &KTimerPref::jobChanged);
            connect(job, &KTimerJob::commandChanged, this, &KTimerPref::jobChanged);
            connect(job, &KTimerJob::finished, this, &KTimerPref::jobFinished);

            job->load( cfg, QStringLiteral( "Job%1" ).arg(n) );

            job->setUser( item );
            jobChanged ( job);
    }

    m_list->update();
}
Пример #3
0
void BatchJob::signalJobChanged()
{
    jobChanged(this);
}