本文整理汇总了C++中meta::TrackPtr::inCollection方法的典型用法代码示例。如果您正苦于以下问题:C++ TrackPtr::inCollection方法的具体用法?C++ TrackPtr::inCollection怎么用?C++ TrackPtr::inCollection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meta::TrackPtr
的用法示例。
在下文中一共展示了TrackPtr::inCollection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: trackAdded
void
ITunesImporterWorker::readTrackElement()
{
QString title, artist, album, url;
int year = -1, bpm = -1, playcount = -1, rating = -1;
QDateTime lastplayed;
while( !( isEndElement() && name() == "dict" ) )
{
readNext();
QString text = readElementText();
if( name() == "key" && text == "Name" )
{
readNext(); // skip past the </key> and to the data tag
QString text = readElementText();
title = text;
} else if( name() == "key" && text == "Artist" )
{
readNext(); // skip past the </key> and to the data tag
artist = readElementText();
} else if( isStartElement() && name() == "key" && text == "Album" )
{
readNext(); // skip past the </key> and to the data tag
album = readElementText();
} else if( name() == "key" && text == "Year" )
{
readNext(); // skip past the </key> and to the data tag
year = readElementText().toInt();
} else if( name() == "key" && text == "BPM" )
{
readNext(); // skip past the </key> and to the data tag
bpm = readElementText().toInt();
} else if( name() == "key" && text == "Play Count" )
{
readNext(); // skip past the </key> and to the data tag
playcount = readElementText().toInt();
} else if( name() == "key" && text == "Rating" )
{
readNext(); // skip past the </key> and to the data tag
rating = readElementText().toInt() / 10; // itunes rates 0-100
} else if( name() == "key" && text == "Play Date" )
{
readNext(); // skip past the </key> and to the data tag
lastplayed = QDateTime::fromTime_t(readElementText().toInt());
} else if( name() == "key" && text == "Location" )
{
readNext(); // skip past the </key> and to the data tag
url = readElementText();
}
}
//split the file://localhost/path/to/track to just file:///path/to/track
if( url.indexOf( "file://localhost" ) == 0 )
url = url.remove( 7, 9 );
debug() << "got track info:" << title << artist << album << year << bpm << url;
Meta::TrackPtr track = CollectionManager::instance()->trackForUrl( KUrl( url ) );
if( track )
{
QScopedPointer<Capabilities::StatisticsCapability> ec( track->create<Capabilities::StatisticsCapability>() );
if( ec )
{
ec->beginStatisticsUpdate();
if( rating != -1 )
ec->setRating( rating );
if( lastplayed.isValid() )
ec->setLastPlayed( lastplayed );
if( playcount != -1 )
ec->setPlayCount( playcount );
ec->endStatisticsUpdate();
if( !track->inCollection() )
{
m_tracksForInsert.insert( track, track->playableUrl().url() );
debug() << " inserting track:" << track->playableUrl();
}
else {
Collections::Collection* collection = track->collection();
if (collection)
debug() << "track in collection (" << collection->location()->prettyLocation() << "):" << track->playableUrl();
}
emit trackAdded( track );
}
}
}