void K3b::AudioBurnDialog::showEvent( QShowEvent* e )
{
    // we only show the audio ripping options when there are audio cd track sources
    bool showRipOptions = false;
    if( m_doc->firstTrack() ) {
        K3b::AudioTrack* track = m_doc->firstTrack();
        K3b::AudioDataSource* source = track->firstSource();

        while( source ) {

            if( dynamic_cast<K3b::AudioCdTrackSource*>(source) ) {
                showRipOptions = true;
                break;
            }

            // next source
            source = source->next();
            if( !source ) {
                track = track->next();
                if( track )
                    source = track->firstSource();
            }
        }
    }

    m_audioRippingGroup->setVisible( showRipOptions );

    K3b::ProjectBurnDialog::showEvent(e);
}
Exemple #2
0
void K3b::MusicBrainzJob::slotMbJobFinished( bool success )
{
    if( hasBeenCanceled() ) {
        emit canceled();
        jobFinished(false);
    }
    else {
        K3b::AudioTrack* currentTrack = d->tracks.at( d->currentTrackIndex );

        if( success ) {
            // found entries
            QStringList resultStrings, resultStringsUnique;
            for( int i = 0; i < d->mbTrackLookupJob->results(); ++i )
                resultStrings.append( d->mbTrackLookupJob->artist(i) + " - " + d->mbTrackLookupJob->title(i) );

            // since we are only using the title and the artist a lot of entries are alike to us
            // so to not let the user have to choose between two equal entries we trim the list down
            for( QStringList::const_iterator it = resultStrings.constBegin();
                 it != resultStrings.constEnd(); ++it )
                if( !resultStringsUnique.contains( *it ) )
                    resultStringsUnique.append( *it );

            QString s;
            bool ok = true;
            if( resultStringsUnique.count() > 1 )
                s = KInputDialog::getItem( i18n("MusicBrainz Query"),
                                           i18n("Found multiple matches for track %1 (%2). Please select one.",
                                                currentTrack->trackNumber(),
                                                currentTrack->firstSource()->sourceComment()),
                                           resultStringsUnique,
                                           0,
                                           false,
                                           &ok,
                                           dynamic_cast<QWidget*>(parent()) );
            else
                s = resultStringsUnique.first();

            if( ok ) {
                int i = resultStrings.lastIndexOf( s );
                currentTrack->setTitle( d->mbTrackLookupJob->title(i) );
                currentTrack->setArtist( d->mbTrackLookupJob->artist(i) );
            }
        }

        emit trackFinished( currentTrack, success );

        // query next track
        ++d->currentTrackIndex;
        if( d->currentTrackIndex < d->tracks.count() ) {
            d->mbTrackLookupJob->setAudioTrack( d->tracks.at( d->currentTrackIndex ) );
            d->mbTrackLookupJob->start();
        }
        else {
            jobFinished( true );
        }
    }
}