File indexing completed on 2024-05-05 04:51:42

0001 /*
0002     SPDX-FileCopyrightText: 2003-2008 Sebastian Trueg <trueg@k3b.org>
0003     SPDX-FileCopyrightText: 2009 Arthur Mello <arthur@mandriva.com>
0004     SPDX-FileCopyrightText: 2009 Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
0005     SPDX-FileCopyrightText: 2009-2010 Michal Malek <michalm@jabster.pl>
0006     SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 
0011 #include "k3baudioviewimpl.h"
0012 
0013 #include "k3baction.h"
0014 #include "k3baudiodatasourceeditwidget.h"
0015 #include "k3baudiodecoder.h"
0016 #include "k3baudiodoc.h"
0017 #include "k3baudiofile.h"
0018 #include "k3baudioprojectdelegate.h"
0019 #include "k3baudioprojectmodel.h"
0020 #include "k3baudiotrack.h"
0021 #include "k3baudiotrackaddingdialog.h"
0022 #include "k3baudiotrackdialog.h"
0023 #include "k3baudiotracksplitdialog.h"
0024 #include "k3baudiotracktrmlookupdialog.h"
0025 #include "k3baudiozerodata.h"
0026 #include "k3bmsfedit.h"
0027 #include "k3bview.h"
0028 #include "k3bviewcolumnadjuster.h"
0029 // this is not here because of base_*.ui troubles
0030 #include "../rip/k3baudioprojectconvertingdialog.h"
0031 
0032 #include "config-k3b.h"
0033 #ifdef ENABLE_AUDIO_PLAYER
0034 #include "k3baudiotrackplayer.h"
0035 #endif // ENABLE_AUDIO_PLAYER
0036 
0037 #include <KLocalizedString>
0038 #include <KMessageBox>
0039 #include <KActionCollection>
0040 
0041 #include <QAction>
0042 #include <QDialog>
0043 #include <QDialogButtonBox>
0044 #include <QHeaderView>
0045 #include <QScrollBar>
0046 #include <QTreeView>
0047 
0048 
0049 K3b::AudioViewImpl::AudioViewImpl( View* view, AudioDoc* doc, KActionCollection* actionCollection )
0050 :
0051     QObject( view ),
0052     m_view( view ),
0053     m_doc( doc ),
0054     m_model( new AudioProjectModel( doc, view ) ),
0055     m_trackView( new QTreeView( view ) ),
0056     m_delegate( new AudioProjectDelegate( *m_trackView, this ) ),
0057 #ifdef ENABLE_AUDIO_PLAYER
0058     m_player( new AudioTrackPlayer( doc, actionCollection, this ) ),
0059 #else
0060     m_player( 0 ),
0061 #endif // ENABLE_AUDIO_PLAYER
0062     m_columnAdjuster( new ViewColumnAdjuster( this ) ),
0063     m_updatingColumnWidths( false )
0064 {
0065     m_trackView->setModel( m_model );
0066     m_trackView->setItemDelegate( m_delegate );
0067     m_trackView->setAcceptDrops( true );
0068     m_trackView->setDragEnabled( true );
0069     m_trackView->setDragDropMode( QTreeView::DragDrop );
0070     m_trackView->setItemsExpandable( false );
0071     m_trackView->setRootIsDecorated( false );
0072     m_trackView->setSelectionMode( QTreeView::ExtendedSelection );
0073     m_trackView->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
0074 
0075     m_columnAdjuster->setView( m_trackView );
0076 
0077     m_actionAddSilence = createAction( m_view, i18n("Add Silence..."), 0, 0, this, SLOT(slotAddSilence()),
0078                                        actionCollection, "track_add_silence" );
0079     m_actionMergeTracks = createAction( m_view, i18n("Merge Tracks"), 0, 0, this, SLOT(slotMergeTracks()),
0080                                         actionCollection, "track_merge" );
0081     m_actionSplitSource = createAction( m_view, i18n("Source to Track"), 0, 0, this, SLOT(slotSplitSource()),
0082                                         actionCollection, "source_split" );
0083     m_actionSplitTrack = createAction( m_view, i18n("Split Track..."), 0, 0, this, SLOT(slotSplitTrack()),
0084                                        actionCollection, "track_split" );
0085     m_actionEditSource = createAction( m_view, i18n("Edit Source..."), 0, 0, this, SLOT(slotEditSource()),
0086                                        actionCollection, "edit_source" );
0087     m_actionPlayTrack = createAction( m_view, i18n("Play Track"), "media-playback-start", 0, this, SLOT(slotPlayTrack()),
0088                                       actionCollection, "track_play" );
0089     m_actionQueryMusicBrainz = createAction( m_view, i18n("Musicbrainz Lookup"), "musicbrainz", 0, this, SLOT(slotQueryMusicBrainz()),
0090                                         actionCollection, "project_audio_musicbrainz");
0091     m_actionQueryMusicBrainz->setToolTip( i18n("Try to determine meta information over the Internet") );
0092     m_actionQueryMusicBrainzTrack = createAction( m_view, i18n("Musicbrainz Lookup"), "musicbrainz", 0, this, SLOT(slotQueryMusicBrainzTrack()),
0093                                         actionCollection, "project_audio_musicbrainz_track");
0094     m_actionQueryMusicBrainzTrack->setToolTip( i18n("Try to determine meta information over the Internet") );
0095     m_actionProperties = createAction( m_view, i18n("Properties"), "document-properties", 0, this, SLOT(slotTrackProperties()),
0096                                        actionCollection, "track_properties" );
0097     m_actionRemove = createAction( m_trackView, i18n("Remove"), "edit-delete", Qt::Key_Delete, this, SLOT(slotRemove()),
0098                                    actionCollection, "track_remove" );
0099     m_actionRemove->setShortcutContext( Qt::WidgetShortcut );
0100     m_conversionAction = createAction( m_view, i18n("Convert Tracks"), "edit-redo", 0, this, SLOT(slotAudioConversion()),
0101                                        actionCollection, "project_audio_convert" );
0102 
0103     connect( m_columnAdjuster, SIGNAL(columnsNeedAjusting()),
0104              this, SLOT(slotAdjustColumns()) );
0105     connect( m_trackView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
0106              this, SLOT(slotSelectionChanged()) );
0107 #ifdef ENABLE_AUDIO_PLAYER
0108     connect( m_player, SIGNAL(playingTrack(K3b::AudioTrack)),
0109              this, SLOT(slotPlayingTrack(K3b::AudioTrack)) );
0110     connect( m_player, SIGNAL(stateChanged()),
0111              this, SLOT(slotPlayerStateChanged()) );
0112 #endif // ENABLE_AUDIO_PLAYER
0113 
0114     // Create audio context menu
0115     QAction* separator = new QAction( this );
0116     separator->setSeparator( true );
0117     m_trackView->setContextMenuPolicy( Qt::ActionsContextMenu );
0118     m_trackView->addAction( m_actionPlayTrack );
0119     m_trackView->addAction( separator );
0120     m_trackView->addAction( m_actionRemove );
0121     m_trackView->addAction( m_actionAddSilence );
0122     m_trackView->addAction( separator );
0123     m_trackView->addAction( m_actionSplitSource );
0124     m_trackView->addAction( m_actionSplitTrack );
0125     m_trackView->addAction( m_actionEditSource );
0126     m_trackView->addAction( m_actionMergeTracks );
0127     m_trackView->addAction( m_actionProperties );
0128     m_trackView->addAction( separator );
0129     m_trackView->addAction( m_actionQueryMusicBrainzTrack );
0130     m_trackView->addAction( separator );
0131     m_trackView->addAction( actionCollection->action("project_burn") );
0132 
0133 #ifndef ENABLE_MUSICBRAINZ
0134     m_actionQueryMusicBrainz->setEnabled( false );
0135     m_actionQueryMusicBrainz->setVisible( false );
0136     m_actionQueryMusicBrainzTrack->setEnabled( false );
0137     m_actionQueryMusicBrainzTrack->setVisible( false );
0138 #endif
0139 }
0140 
0141 
0142 void K3b::AudioViewImpl::addUrls( const QList<QUrl>& urls )
0143 {
0144     AudioTrackAddingDialog::addUrls( urls, m_doc, 0, 0, 0, m_view );
0145 }
0146 
0147 
0148 void K3b::AudioViewImpl::slotRemove()
0149 {
0150     const QModelIndexList indexes = m_trackView->selectionModel()->selectedRows();
0151     QList<AudioTrack*> tracks;
0152     QList<AudioDataSource*> sources;
0153     tracksForIndexes( tracks, indexes );
0154     sourcesForIndexes( sources, indexes );
0155 
0156     //
0157     // remove all sources which belong to one of the selected tracks since they will be
0158     // deleted along with their tracks
0159     //
0160     QList<AudioDataSource*>::iterator srcIt = sources.begin();
0161     while( srcIt != sources.end() ) {
0162         if( tracks.contains( ( *srcIt )->track() ) )
0163             srcIt = sources.erase( srcIt );
0164         else
0165             ++srcIt;
0166     }
0167 
0168     //
0169     // Now delete all the tracks
0170     //
0171     qDeleteAll( tracks );
0172 
0173     //
0174     // Now delete all the sources
0175     //
0176     qDeleteAll( sources );
0177 }
0178 
0179 
0180 void K3b::AudioViewImpl::slotAddSilence()
0181 {
0182     const QModelIndexList indexes = m_trackView->selectionModel()->selectedRows();
0183     QList<AudioTrack*> tracks;
0184     QList<AudioDataSource*> sources;
0185     tracksForIndexes( tracks, indexes );
0186     sourcesForIndexes( sources, indexes );
0187 
0188     if( !sources.isEmpty() || !tracks.isEmpty() ) {
0189         //
0190         // create a simple dialog for asking the length of the silence
0191         //
0192         QDialog dlg( m_view );
0193         dlg.setWindowTitle(i18n("Add Silence"));
0194 
0195         QHBoxLayout* dlgLayout = new QHBoxLayout( &dlg );
0196         dlgLayout->setContentsMargins( 0, 0, 0, 0 );
0197         QLabel* label = new QLabel( i18n("Length of silence:"), &dlg );
0198         MsfEdit* msfEdit = new MsfEdit( &dlg );
0199         msfEdit->setValue( 150 ); // 2 seconds default
0200         msfEdit->setFocus();
0201 
0202         QDialogButtonBox* buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, &dlg );
0203         connect( buttonBox, SIGNAL(accepted()), &dlg, SLOT(accept()) );
0204         connect( buttonBox, SIGNAL(rejected()), &dlg, SLOT(reject()) );
0205 
0206         dlgLayout->addWidget( label );
0207         dlgLayout->addWidget( msfEdit );
0208         dlgLayout->addWidget( buttonBox );
0209 
0210         if( dlg.exec() == QDialog::Accepted ) {
0211             AudioZeroData* zero = new AudioZeroData( msfEdit->value() );
0212             if ( !tracks.isEmpty() )
0213                 tracks.first()->addSource( zero );
0214             else
0215                 zero->moveAfter( sources.first() );
0216         }
0217     }
0218 }
0219 
0220 
0221 void K3b::AudioViewImpl::slotMergeTracks()
0222 {
0223     const QModelIndexList indexes = m_trackView->selectionModel()->selectedRows();
0224     QList<AudioTrack*> tracks;
0225     tracksForIndexes( tracks, indexes );
0226 
0227     // we simply merge the selected tracks ignoring any eventually selected sources
0228     if ( !tracks.isEmpty() ) {
0229         AudioTrack* firstTrack = tracks.takeFirst();
0230         while( !tracks.isEmpty() ) {
0231             firstTrack->merge( tracks.takeFirst(), firstTrack->lastSource() );
0232         }
0233     }
0234 }
0235 
0236 
0237 void K3b::AudioViewImpl::slotSplitSource()
0238 {
0239     const QModelIndexList indexes = m_trackView->selectionModel()->selectedRows();
0240     QList<AudioDataSource*> sources;
0241     sourcesForIndexes( sources, indexes );
0242 
0243     if( !sources.isEmpty() ) {
0244         AudioDataSource* source = sources.first();
0245         // create a new track
0246         AudioTrack* track = new AudioTrack( m_doc );
0247         AudioTrack* trackAfter = source->track();
0248         if( trackAfter->numberSources() == 1 )
0249             trackAfter = trackAfter->prev();
0250         track->addSource( source->take() );
0251         track->moveAfter( trackAfter );
0252 
0253         // let's see if it's a file because in that case we can reuse the metainfo :)
0254         // TODO: maybe add meta data to sources
0255         if( AudioFile* file = dynamic_cast<AudioFile*>( track->firstSource() ) ) {
0256             track->setArtist( file->decoder()->metaInfo( AudioDecoder::META_ARTIST ) );
0257             track->setTitle( file->decoder()->metaInfo( AudioDecoder::META_TITLE ) );
0258             track->setSongwriter( file->decoder()->metaInfo( AudioDecoder::META_SONGWRITER ) );
0259             track->setComposer( file->decoder()->metaInfo( AudioDecoder::META_COMPOSER ) );
0260             track->setCdTextMessage( file->decoder()->metaInfo( AudioDecoder::META_COMMENT ) );
0261         }
0262     }
0263 }
0264 
0265 
0266 void K3b::AudioViewImpl::slotSplitTrack()
0267 {
0268     const QModelIndexList indexes = m_trackView->selectionModel()->selectedRows();
0269     QList<AudioTrack*> tracks;
0270     tracksForIndexes( tracks, indexes );
0271 
0272     if( !tracks.isEmpty() ) {
0273         AudioTrackSplitDialog::splitTrack( tracks.first(), m_view );
0274     }
0275 }
0276 
0277 
0278 void K3b::AudioViewImpl::slotEditSource()
0279 {
0280     const QModelIndexList indexes = m_trackView->selectionModel()->selectedRows();
0281     QList<AudioTrack*> tracks;
0282     QList<AudioDataSource*> sources;
0283     tracksForIndexes( tracks, indexes );
0284     sourcesForIndexes( sources, indexes );
0285 
0286     AudioDataSource* source = 0;
0287     if( !sources.isEmpty() && tracks.isEmpty() )
0288         source = sources.first();
0289     else if( !tracks.isEmpty() && sources.isEmpty() )
0290         source = tracks.first()->firstSource();
0291 
0292     if( source ) {
0293         QDialog dlg( m_view );
0294         dlg.setWindowTitle( i18n("Edit Audio Track Source") );
0295 
0296         AudioDataSourceEditWidget* editW = new AudioDataSourceEditWidget( &dlg );
0297         editW->loadSource( source );
0298 
0299         QDialogButtonBox* buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, &dlg );
0300         connect( buttonBox, SIGNAL(accepted()), &dlg, SLOT(accept()) );
0301         connect( buttonBox, SIGNAL(rejected()), &dlg, SLOT(reject()) );
0302 
0303         QVBoxLayout* layout = new QVBoxLayout( &dlg );
0304         layout->addWidget( editW );
0305         layout->addWidget( buttonBox );
0306 
0307         if( dlg.exec() == QDialog::Accepted ) {
0308             editW->saveSource();
0309         }
0310     }
0311 }
0312 
0313 
0314 void K3b::AudioViewImpl::slotTrackProperties()
0315 {
0316     const QModelIndexList indexes = m_trackView->selectionModel()->selectedRows();
0317     QList<AudioTrack*> tracks;
0318     tracksForIndexes( tracks, indexes );
0319 
0320     // TODO: add tracks from sources to tracks
0321 
0322     if( !tracks.isEmpty() ) {
0323         AudioTrackDialog d( tracks, m_view );
0324         d.exec();
0325     }
0326     else {
0327         m_view->slotProperties();
0328     }
0329 }
0330 
0331 
0332 void K3b::AudioViewImpl::slotPlayTrack()
0333 {
0334     const QModelIndexList indexes = m_trackView->selectionModel()->selectedRows();
0335     QList<AudioTrack*> tracks;
0336     tracksForIndexes( tracks, indexes );
0337 
0338 #ifdef ENABLE_AUDIO_PLAYER
0339     if( !tracks.empty() && tracks.first() != 0 )
0340         m_player->playTrack( *tracks.first() );
0341 #endif // ENABLE_AUDIO_PLAYER
0342 }
0343 
0344 
0345 void K3b::AudioViewImpl::slotQueryMusicBrainz()
0346 {
0347 #ifdef ENABLE_MUSICBRAINZ
0348     QList<AudioTrack*> tracks;
0349     for( int i = 1; i <= m_doc->numOfTracks(); ++i ) {
0350         tracks.push_back( m_doc->getTrack( i ) );
0351     }
0352 
0353     if( tracks.isEmpty() ) {
0354         KMessageBox::error( m_view, i18n("Please add an audio track.") );
0355         return;
0356     }
0357 
0358     // only one may use the tracks at the same time
0359 //     if( m_currentlyPlayingTrack &&
0360 //         tracks.containsRef( m_currentlyPlayingTrack ) )
0361 //         m_player->stop();
0362 
0363     // now do the lookup on the files.
0364     AudioTrackTRMLookupDialog dlg( m_view );
0365     dlg.lookup( tracks );
0366 #endif
0367 }
0368 
0369 
0370 void K3b::AudioViewImpl::slotQueryMusicBrainzTrack()
0371 {
0372 #ifdef ENABLE_MUSICBRAINZ
0373     const QModelIndexList indexes = m_trackView->selectionModel()->selectedRows();
0374     QList<AudioTrack*> tracks;
0375     tracksForIndexes( tracks, indexes );
0376 
0377     if( tracks.isEmpty() ) {
0378         KMessageBox::error( m_view, i18n("Please select an audio track.") );
0379         return;
0380     }
0381 
0382     // only one may use the tracks at the same time
0383 //     if( m_currentlyPlayingTrack &&
0384 //         tracks.containsRef( m_currentlyPlayingTrack ) )
0385 //         m_player->stop();
0386 
0387     // now do the lookup on the files.
0388     AudioTrackTRMLookupDialog dlg( m_view );
0389     dlg.lookup( tracks );
0390 #endif
0391 }
0392 
0393 
0394 void K3b::AudioViewImpl::slotSelectionChanged()
0395 {
0396     if( m_trackView->hasFocus() ) {
0397         QModelIndexList indexes = m_trackView->selectionModel()->selectedRows();
0398 
0399         QList<K3b::AudioTrack*> tracks;
0400         QList<K3b::AudioDataSource*> sources;
0401         tracksForIndexes( tracks, indexes );
0402         sourcesForIndexes( sources, indexes );
0403 
0404         int numTracks = tracks.count();
0405         int numSources = sources.count();
0406 
0407         if( m_actionPlayTrack != 0 ) {
0408             m_actionPlayTrack->setVisible( numTracks >= 1 );
0409         }
0410         m_actionRemove->setVisible( numTracks + numSources );
0411         m_actionAddSilence->setVisible( numSources + numTracks == 1 );
0412 
0413         if( numSources == 1 && numTracks == 0 ) {
0414             m_actionSplitSource->setVisible( true );
0415             m_actionSplitTrack->setVisible( false );
0416             m_actionEditSource->setVisible( true );
0417             m_actionMergeTracks->setVisible( false );
0418         }
0419         else if( numTracks == 1 && numSources == 0 ) {
0420             m_actionSplitSource->setVisible( false );
0421             m_actionSplitTrack->setVisible( tracks.first()->length().lba() > 60 );
0422             m_actionEditSource->setVisible( true );
0423             m_actionMergeTracks->setVisible( false );
0424         }
0425         else {
0426             m_actionSplitSource->setVisible( false );
0427             m_actionSplitTrack->setVisible( false );
0428             m_actionEditSource->setVisible( false );
0429             m_actionMergeTracks->setVisible( numTracks > 1 );
0430         }
0431     }
0432 }
0433 
0434 
0435 void K3b::AudioViewImpl::slotAudioConversion()
0436 {
0437     if( m_doc->numOfTracks() > 0 ) {
0438         AudioProjectConvertingDialog dlg( m_doc, m_view );
0439         dlg.exec();
0440     }
0441     else {
0442         KMessageBox::information( m_view, i18n("Please add files to your project first."),
0443                                   i18n("No tracks to convert") );
0444     }
0445 }
0446 
0447 
0448 void K3b::AudioViewImpl::slotAdjustColumns()
0449 {
0450     qDebug();
0451 
0452     if( m_updatingColumnWidths ) {
0453         qDebug() << "already updating column widths.";
0454         return;
0455     }
0456 
0457     m_updatingColumnWidths = true;
0458 
0459     // now properly resize the columns
0460     // minimal width for type, length, pregap
0461     // fixed for filename
0462     // expand for cd-text
0463     int titleWidth = m_columnAdjuster->columnSizeHint( AudioProjectModel::TitleColumn );
0464     int artistWidth = m_columnAdjuster->columnSizeHint( AudioProjectModel::ArtistColumn );
0465     int typeWidth = m_columnAdjuster->columnSizeHint( AudioProjectModel::TypeColumn );
0466     int lengthWidth = m_columnAdjuster->columnSizeHint( AudioProjectModel::LengthColumn );
0467     int filenameWidth = m_columnAdjuster->columnSizeHint( AudioProjectModel::FilenameColumn );
0468 
0469     // add a margin
0470     typeWidth += 10;
0471     lengthWidth += 10;
0472 
0473     // these always need to be completely visible
0474     m_trackView->setColumnWidth( AudioProjectModel::TrackNumberColumn, m_columnAdjuster->columnSizeHint( AudioProjectModel::TrackNumberColumn ) );
0475     m_trackView->setColumnWidth( AudioProjectModel::TypeColumn, typeWidth );
0476     m_trackView->setColumnWidth( AudioProjectModel::LengthColumn, lengthWidth );
0477 
0478     int remaining = m_trackView->viewport()->contentsRect().width() - typeWidth - lengthWidth - m_trackView->columnWidth(0);
0479 
0480     // now let's see if there is enough space for all
0481     if( remaining >= artistWidth + titleWidth + filenameWidth ) {
0482         remaining -= filenameWidth;
0483         remaining -= (titleWidth + artistWidth);
0484         m_trackView->setColumnWidth( AudioProjectModel::ArtistColumn, artistWidth + remaining/2 );
0485         m_trackView->setColumnWidth( AudioProjectModel::TitleColumn, titleWidth + remaining/2 );
0486         m_trackView->setColumnWidth( AudioProjectModel::FilenameColumn, filenameWidth );
0487     }
0488     else if( remaining >= artistWidth + titleWidth + 20 ) {
0489         m_trackView->setColumnWidth( AudioProjectModel::ArtistColumn, artistWidth );
0490         m_trackView->setColumnWidth( AudioProjectModel::TitleColumn, titleWidth );
0491         m_trackView->setColumnWidth( AudioProjectModel::FilenameColumn, remaining - artistWidth - titleWidth );
0492     }
0493     else {
0494         m_trackView->setColumnWidth( AudioProjectModel::ArtistColumn, remaining/3 );
0495         m_trackView->setColumnWidth( AudioProjectModel::TitleColumn, remaining/3 );
0496         m_trackView->setColumnWidth( AudioProjectModel::FilenameColumn, remaining/3 );
0497     }
0498 
0499     m_updatingColumnWidths = false;
0500 }
0501 
0502 
0503 void K3b::AudioViewImpl::slotPlayingTrack( const K3b::AudioTrack& track )
0504 {
0505     QModelIndex index = m_model->indexForTrack( &track );
0506     m_trackView->scrollTo( index );
0507     m_delegate->setPlayingTrack( index );
0508 }
0509 
0510 
0511 void K3b::AudioViewImpl::slotPlayerStateChanged()
0512 {
0513 #ifdef ENABLE_AUDIO_PLAYER
0514     if( m_player->state() == AudioTrackPlayer::Stopped ) {
0515         m_delegate->setPlayingTrack( QModelIndex() );
0516     }
0517 #endif // ENABLE_AUDIO_PLAYER
0518 }
0519 
0520 
0521 void K3b::AudioViewImpl::tracksForIndexes( QList<AudioTrack*>& tracks,
0522                                            const QModelIndexList& indexes ) const
0523 {
0524     tracks.clear();
0525 
0526     foreach( const QModelIndex& index, indexes ) {
0527         if ( AudioTrack* track = m_model->trackForIndex( index ) ) {
0528             tracks << track;
0529         }
0530     }
0531 }
0532 
0533 
0534 void K3b::AudioViewImpl::sourcesForIndexes( QList<AudioDataSource*>& sources,
0535                                             const QModelIndexList& indexes ) const
0536 {
0537     sources.clear();
0538 
0539     foreach( const QModelIndex& index, indexes ) {
0540         if ( AudioDataSource* source = m_model->sourceForIndex( index ) ) {
0541 #ifdef __GNUC__
0542 #warning Do not select hidden sources once the hiding of sources works again
0543 #endif
0544             // do not select hidden source items or unfinished source files
0545             if( source->isValid() && source->length() != 0 ) {
0546                 sources << source;
0547             }
0548         }
0549     }
0550 }
0551 
0552 #include "moc_k3baudioviewimpl.cpp"