本文整理汇总了C++中meta::TrackPtr类的典型用法代码示例。如果您正苦于以下问题:C++ TrackPtr类的具体用法?C++ TrackPtr怎么用?C++ TrackPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TrackPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeAllData
bool
SimilarArtistsEngine::update( bool force )
{
QString newArtist;
Meta::TrackPtr track = The::engineController()->currentTrack();
if( track )
{
if( Meta::ArtistPtr artistPtr = track->artist() )
newArtist = artistPtr->name();
}
if( newArtist.isEmpty() )
{
m_artist.clear();
removeAllData( "similarArtists" );
return false;
}
else //valid artist
{
// wee make a request only if the artist is different
if( force || (newArtist != m_artist) )
{
// if the artist has changed
m_artist = newArtist;
similarArtistsRequest( m_artist );
return true;
}
}
return false;
}
示例2: setData
void
AlbumItem::update()
{
if( !m_album )
return;
Meta::TrackList tracks = m_album->tracks();
if( !tracks.isEmpty() )
{
Meta::TrackPtr first = tracks.first();
Meta::YearPtr year = first->year();
if( year )
setData( year->year(), AlbumYearRole );
}
QString albumName = m_album->name();
albumName = albumName.isEmpty() ? i18n("Unknown") : albumName;
QString name = ( m_showArtist && m_album->hasAlbumArtist() )
? QString( "%1 - %2" ).arg( m_album->albumArtist()->name(), albumName )
: albumName;
setData( name, NameRole );
qint64 totalTime = 0;
foreach( Meta::TrackPtr item, tracks )
totalTime += item->length();
QString trackCount = i18np( "%1 track", "%1 tracks", tracks.size() );
QString lengthText = QString( "%1, %2" ).arg( trackCount, Meta::msToPrettyTime( totalTime ) );
setData( lengthText, AlbumLengthRole );
QPixmap cover = The::svgHandler()->imageWithBorder( m_album, m_iconSize, 3 );
setIcon( QIcon( cover ) );
}
示例3: locker
bool
Dynamic::EchoNestBias::trackMatches( int position,
const Meta::TrackList& playlist,
int contextCount ) const
{
Q_UNUSED( contextCount );
// collect the artist
QStringList artists = currentArtists( position, playlist );
if( artists.isEmpty() )
return true;
// the artist of this track
if( position < 0 || position >= playlist.count() )
return false;
Meta::TrackPtr track = playlist[position];
Meta::ArtistPtr artist = track->artist();
if( !artist || artist->name().isEmpty() )
return false;
{
QMutexLocker locker( &m_mutex );
QString key = artists.join("|");
if( m_similarArtistMap.contains( key ) )
return m_similarArtistMap.value( key ).contains( artist->name() );
}
warning() << "didn't have artist suggestions saved for this artist:" << artist->name();
return false;
}
示例4: update
void
PhotosEngine::metadataChanged( Meta::TrackPtr track )
{
const bool hasChanged = !track->artist() || track->artist()->name() != m_artist;
if ( hasChanged )
update();
}
示例5: ratingChanged
void
OSDWidget::ratingChanged( const QString& path, int rating )
{
Meta::TrackPtr track = The::engineController()->currentTrack();
if( !track )
return;
if( track->playableUrl().isLocalFile() && track->playableUrl().path() == path )
ratingChanged( rating );
}
示例6:
void
CurrentTrack::trackRatingChanged( int rating )
{
Meta::TrackPtr track = The::engineController()->currentTrack();
if( !track )
return;
track->statistics()->setRating( rating );
}
示例7: onTrackMetadataChanged
void LyricsEngine::onTrackMetadataChanged( Meta::TrackPtr track )
{
DEBUG_BLOCK
// Only update if the lyrics have changed.
QString artist = track->artist() ? track->artist()->name() : QString();
if( m_prevLyrics.artist != artist ||
m_prevLyrics.title != track->name() ||
m_prevLyrics.text != track->cachedLyrics() )
update();
}
示例8: TrackSet
Dynamic::TrackSet
Dynamic::AlbumPlayBias::matchingTracks( const Meta::TrackList& playlist,
int contextCount, int finalCount,
Dynamic::TrackCollectionPtr universe ) const
{
Q_UNUSED( contextCount );
Q_UNUSED( finalCount );
if( playlist.isEmpty() ) // no track means we can't find any tracks in the same album
return Dynamic::TrackSet( universe, false );
Meta::TrackPtr track = playlist.last();
Meta::AlbumPtr album = track->album();
if( !album ) // no album means we can't find any tracks in the same album
return Dynamic::TrackSet( universe, false );
Meta::TrackList albumTracks = album->tracks();
if( ( albumTracks.count() <= 1 ) || // the album has only one track (or even less) so there can't be any other tracks in the same album
( m_follow != DontCare && sameTrack( track, albumTracks.last() ) ) ) // track is the last one and we want to find a later one.
return Dynamic::TrackSet( universe, false );
// we assume that the album tracks are sorted by cd and track number which
// is at least true for the SqlCollection
TrackSet result( universe, false );
if( m_follow == DirectlyFollow )
{
for( int i = 1; i < albumTracks.count(); i++ )
if( sameTrack( albumTracks[i-1], track ) )
result.unite( albumTracks[i] );
}
else if( m_follow == Follow )
{
bool found = false;
for( int i = 0; i < albumTracks.count(); i++ )
{
if( found )
result.unite( albumTracks[i] );
if( sameTrack( albumTracks[i], track ) )
found = true;
}
}
else if( m_follow == DontCare )
{
for( int i = 0; i < albumTracks.count(); i++ )
{
if( !sameTrack( albumTracks[i], track ) )
result.unite( albumTracks[i] );
}
}
return result;
}
示例9: TrackSet
Dynamic::TrackSet
Dynamic::AlbumPlayBias::matchingTracks( int position,
const Meta::TrackList& playlist, int contextCount,
Dynamic::TrackCollectionPtr universe ) const
{
Q_UNUSED( contextCount );
if( position < 1 || position >= playlist.count() )
return Dynamic::TrackSet( universe, false );
Meta::TrackPtr track = playlist[position-1];
Meta::AlbumPtr album = track->album();
if( !album )
return Dynamic::TrackSet( universe, false );
Meta::TrackList albumTracks = album->tracks();
if( albumTracks.count() == 1 ||
(track == albumTracks.last() && m_follow != DontCare) )
return Dynamic::TrackSet( universe, false );
// we assume that the album tracks are sorted by cd and track number which
// is at least true for the SqlCollection
TrackSet result( universe, false );
if( m_follow == DirectlyFollow )
{
for( int i = 1; i < albumTracks.count(); i++ )
if( albumTracks[i-1] == track )
result.unite( albumTracks[i] );
}
else if( m_follow == Follow )
{
bool found = false;
for( int i = 0; i < albumTracks.count(); i++ )
{
if( found )
result.unite( albumTracks[i] );
if( albumTracks[i] == track )
found = true;
}
}
else if( m_follow == DontCare )
{
for( int i = 0; i < albumTracks.count(); i++ )
{
if( albumTracks[i] != track )
result.unite( albumTracks[i] );
}
}
return result;
}
示例10: connect
void
IpodCopyTracksJob::slotStartDuplicateTrackSearch( const Meta::TrackPtr &track )
{
Collections::QueryMaker *qm = m_coll.data()->queryMaker();
qm->setQueryType( Collections::QueryMaker::Track );
// we cannot qm->addMatch( track ) - it matches by uidUrl()
qm->addFilter( Meta::valTitle, track->name(), true, true );
qm->addMatch( track->album() );
qm->setArtistQueryMode( Collections::QueryMaker::TrackArtists );
qm->addMatch( track->artist() );
qm->addMatch( track->composer() );
qm->addMatch( track->genre() );
qm->addMatch( track->year() );
qm->addNumberFilter( Meta::valTrackNr, track->trackNumber(), Collections::QueryMaker::Equals );
qm->addNumberFilter( Meta::valDiscNr, track->discNumber(), Collections::QueryMaker::Equals );
// we don't want to match by filesize, track length, filetype etc - these change during
// transcoding. We don't match album artist because handling of it is inconsistent
connect( qm, SIGNAL(newResultReady(Meta::TrackList)),
SLOT(slotDuplicateTrackSearchNewResult(Meta::TrackList)) );
connect( qm, SIGNAL(queryDone()), SLOT(slotDuplicateTrackSearchQueryDone()) );
qm->setAutoDelete( true );
m_duplicateTrack = Meta::TrackPtr(); // reset duplicate track from previous query
qm->run();
}
示例11: it
void
OrganizeCollectionDialog::previewNextBatch() //private slot
{
const int batchSize = 10;
QMap<Meta::TrackPtr, QString> dests = m_trackOrganizer->getDestinations( batchSize );
QMapIterator<Meta::TrackPtr, QString> it( dests );
while( it.hasNext() )
{
it.next();
Meta::TrackPtr track = it.key();
QString originalPath = track->prettyUrl();
QString newPath = it.value();
int newRow = ui->previewTableWidget->rowCount();
ui->previewTableWidget->insertRow( newRow );
//new path preview in the 1st column
QPalette p = ui->previewTableWidget->palette();
QTableWidgetItem *item = new QTableWidgetItem( newPath );
KColorScheme::adjustBackground( p, KColorScheme::NegativeBackground );
if( QFileInfo( newPath ).exists() )
{
item->setBackgroundColor( p.color( QPalette::Base ) );
m_conflict = true;
}
ui->previewTableWidget->setItem( newRow, 0, item );
//original in the second column
item = new QTableWidgetItem( originalPath );
ui->previewTableWidget->setItem( newRow, 1, item );
}
if( m_conflict )
{
if( ui->overwriteCheck->isChecked() )
ui->conflictLabel->setText( i18n( "There is a filename conflict, existing files will be overwritten." ) );
else
ui->conflictLabel->setText( i18n( "There is a filename conflict, existing files will not be changed." ) );
}
else
ui->conflictLabel->setText(""); // we clear the text instead of hiding it to retain the layout spacing
//non-blocking way of updating the preview table.
if( dests.count() == batchSize )
QTimer::singleShot( 10, this, SLOT(previewNextBatch()) );
else
unsetCursor(); // finished
}
示例12: QCOMPARE
void
TestSqlTrack::testRemoveLabelFromTrack()
{
Meta::TrackPtr track = m_collection->registry()->getTrack( "/IDoNotExist.mp3" );
Meta::LabelPtr label = m_collection->registry()->getLabel( "A" );
track->addLabel( label );
QCOMPARE( track->labels().count(), 1 );
track->removeLabel( label );
QCOMPARE( track->labels().count(), 0 );
QStringList urlsLabelsCount = m_storage->query( "SELECT COUNT(*) FROM urls_labels;" );
QCOMPARE( urlsLabelsCount.first().toInt(), 0 );
}
示例13: getInfo
void LastfmInfoParser::getInfo(Meta::TrackPtr track)
{
DEBUG_BLOCK
QMap<QString, QString> query;
query[ "method" ] = "track.getInfo";
query[ "track" ] = track->name();
query[ "album" ] = track->album() ? track->album()->name() : QString();
query[ "artist" ] = track->artist() ? track->artist()->name() : QString();
query[ "apikey" ] = Amarok::lastfmApiKey();
m_jobs[ "getTrackInfo" ] = lastfm::ws::post( query );
connect( m_jobs[ "getTrackInfo" ], SIGNAL( finished() ), SLOT( onGetTrackInfo() ) );
}
示例14: sameTrack
bool
Dynamic::AlbumPlayBias::trackMatches( int position,
const Meta::TrackList& playlist,
int contextCount ) const
{
Q_UNUSED( contextCount );
if( position <= 0 || playlist.count() <= position )
return true;
Meta::TrackPtr track = playlist[position-1];
Meta::AlbumPtr album = track->album();
Meta::TrackPtr currentTrack = playlist[position];
Meta::AlbumPtr currentAlbum = currentTrack->album();
if( !album || album->tracks().isEmpty() )
return false;
Meta::TrackList albumTracks = album->tracks();
if( sameTrack( track, albumTracks.last() ) && m_follow != DontCare )
return false;
// we assume that the album tracks are sorted by cd and track number which
// is at least true for the SqlCollection
if( m_follow == DirectlyFollow )
{
for( int i = 1; i < albumTracks.count(); i++ )
if( sameTrack( albumTracks[i-1], track ) )
return sameTrack( albumTracks[i], currentTrack );
return false;
}
else if( m_follow == Follow )
{
bool found = false;
for( int i = 0; i < albumTracks.count(); i++ )
{
if( found && sameTrack( albumTracks[i], currentTrack ) )
return true;
if( sameTrack( albumTracks[i], track ) )
found = true;
}
return false;
}
else if( m_follow == DontCare )
{
return album == currentAlbum;
}
return false;
}
示例15: QString
void
TrackItem::metadataChanged( Meta::TrackPtr track )
{
int trackNumber = track->trackNumber();
QString trackName = track->prettyName();
QString text;
if( trackNumber > 0 )
text = QString( "%1\t%2" ).arg( QString::number( trackNumber ), trackName );
else
text = QString( "\t%1" ).arg( trackName );
setText( text );
}