void JobManager::endCurrentJob() { currentJob->setPrinting(false); currentJob->setprinted(true); qDebug() << "Ended job " << currentJob->getId(); startNextJob(); }
void JobsQueue::passJobPercentChanged(QString fileName, int percent) { emit jobProgressChanged(fileName, percent); if (percent == 100) { startNextJob(); } }
void JobsQueue::startJobs() { m_timer = new QElapsedTimer(); m_timer->start(); for (int i = 0; i<QThread::idealThreadCount(); i++) { m_dwarfs.append(new Dwarf(m_directory, m_directory+QString("/jpeg/"), m_save_exif, this)); connect(m_dwarfs.last(), SIGNAL(jobPercentChanged(QString, int)), this, SLOT(passJobPercentChanged(QString, int))); } for (int i = 0; i<m_dwarfs.size();i++) { startNextJob(); } }
void JobManager::startNextJob() { disconnect(this, SIGNAL(listUpdated()), this, SLOT(startNextJob())); int i = 0; currentJob = 0; while( i < list_.size() && !currentJob) { Job* job = qobject_cast<Job*>(list_.at(i)); if (!job->isPrinted()) { currentJob = job; } i++; } if (currentJob) { currentJob->setPrinting(true); qDebug() << "Start job " << currentJob->getId() << " time: " << currentJob->getPrintTime(); QTimer::singleShot(currentJob->getPrintTime()*1000, this, SLOT(endCurrentJob())); } else { connect(this, SIGNAL(listUpdated()), this, SLOT(startNextJob()), Qt::UniqueConnection); } }
void JobManager::start() { startNextJob(); }