void K3bThreadJob::customEvent( QCustomEvent* e ) { if( K3bDataEvent* de = dynamic_cast<K3bDataEvent*>(e) ) { emit data( de->data(), de->length() ); } else { K3bProgressInfoEvent* be = static_cast<K3bProgressInfoEvent*>(e); switch( be->type() ) { case K3bProgressInfoEvent::Progress: emit percent( be->firstValue() ); break; case K3bProgressInfoEvent::SubProgress: emit subPercent( be->firstValue() ); break; case K3bProgressInfoEvent::ProcessedSize: emit processedSize( be->firstValue(), be->secondValue() ); break; case K3bProgressInfoEvent::ProcessedSubSize: emit processedSubSize( be->firstValue(), be->secondValue() ); break; case K3bProgressInfoEvent::InfoMessage: emit infoMessage( be->firstString(), be->firstValue() ); break; case K3bProgressInfoEvent::Started: jobStarted(); break; case K3bProgressInfoEvent::Canceled: emit canceled(); break; case K3bProgressInfoEvent::Finished: // we wait until the thred really finished // although this may be dangerous if some thread // emits the finished signal although it has not finished yet // but makes a lot stuff easier. kdDebug() << "(K3bThreadJob) waiting for the thread to finish." << endl; m_thread->wait(); kdDebug() << "(K3bThreadJob) thread finished." << endl; cleanupJob( be->firstValue() ); m_running = false; jobFinished( be->firstValue() ); break; case K3bProgressInfoEvent::NewTask: emit newTask( be->firstString() ); break; case K3bProgressInfoEvent::NewSubTask: emit newSubTask( be->firstString() ); break; case K3bProgressInfoEvent::DebuggingOutput: emit debuggingOutput( be->firstString(), be->secondString() ); break; case K3bProgressInfoEvent::NextTrack: emit nextTrack( be->firstValue(), be->secondValue() ); break; } } }
void K3b::VcdJob::slotParseVcdxBuildOutput( const QString& line ) { QDomDocument xml_doc; QDomElement xml_root; QString str = line.trimmed(); emit debuggingOutput( "vcdxbuild", str ); xml_doc.setContent( QString( "<?xml version='1.0'?><vcdxbuild>" ) + str + "</vcdxbuild>" ); xml_root = xml_doc.documentElement(); // There should be only one... but ... for ( QDomNode node = xml_root.firstChild(); !node.isNull(); node = node.nextSibling() ) { QDomElement el = node.toElement(); if ( el.isNull() ) continue; const QString tagName = el.tagName().toLower(); if ( tagName == "progress" ) { const QString oper = el.attribute( "operation" ).toLower(); const unsigned long long pos = el.attribute( "position" ).toLong(); const long long size = el.attribute( "size" ).toLong(); if ( oper == "scan" ) { // Scan Video Files if ( m_stage == stageUnknown || pos < m_bytesFinished ) { const uint index = el.attribute( "id" ).remove( QRegExp( "sequence-" ) ).toUInt(); m_currentWrittenTrack = m_doc->at( m_currentWrittenTrackNumber ); emit newSubTask( i18n( "Scanning video file %1 of %2 (%3)" , index + 1 , doc() ->numOfTracks() , m_currentWrittenTrack->fileName() ) ); m_bytesFinished = 0; if ( !firstTrack ) { m_bytesFinishedTracks += m_doc->at( m_currentWrittenTrackNumber ) ->size(); m_currentWrittenTrackNumber++; } else firstTrack = false; } emit subPercent( ( int ) ( 100.0 * ( double ) pos / ( double ) size ) ); emit processedSubSize( pos / 1024 / 1024, size / 1024 / 1024 ); // this is the first of three processes. double relOverallWritten = ( ( double ) m_bytesFinishedTracks + ( double ) pos ) / ( double ) doc() ->size(); emit percent( ( int ) ( m_createimageonlypercent * relOverallWritten ) ); m_bytesFinished = pos; m_stage = stageScan; } else if ( oper == "write" ) { emit subPercent( ( int ) ( 100.0 * ( double ) pos / ( double ) size ) ); emit processedSubSize( ( pos * 2048 ) / 1024 / 1024, ( size * 2048 ) / 1024 / 1024 ); emit percent( ( int ) ( m_createimageonlypercent + ( m_createimageonlypercent * ( double ) pos / ( double ) size ) ) ); m_stage = stageWrite; } else { return ; } } else if ( tagName == "log" ) { QDomText tel = el.firstChild().toText(); const QString level = el.attribute( "level" ).toLower(); if ( tel.isText() ) { const QString text = tel.data(); if ( m_stage == stageWrite && level == "information" ) qDebug() << QString( "(K3b::VcdJob) VcdxBuild information, %1" ).arg( text ); if ( ( text ).startsWith( "writing track" ) ) emit newSubTask( i18n( "Creating Image for track %1" , ( text ).mid( 14 ) ) ); else { if ( level != "error" ) { qDebug() << QString( "(K3b::VcdJob) vcdxbuild warning, %1" ).arg( text ); parseInformation( text ); } else { qDebug() << QString( "(K3b::VcdJob) vcdxbuild error, %1" ).arg( text ); emit infoMessage( text, K3b::Job::MessageError ); } } } } } }