本文整理汇总了C++中meta::TrackPtr::statistics方法的典型用法代码示例。如果您正苦于以下问题:C++ TrackPtr::statistics方法的具体用法?C++ TrackPtr::statistics怎么用?C++ TrackPtr::statistics使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meta::TrackPtr
的用法示例。
在下文中一共展示了TrackPtr::statistics方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: foreach
bool
ProxyBase::rowMatch( int sourceModelRow, const QString &searchTerms, int searchFields ) const
{
if ( !m_belowModel )
return false;
Meta::TrackPtr track = m_belowModel->trackAt( sourceModelRow );
QStringList searchList = searchTerms.split(" ", QString::SkipEmptyParts);
foreach( const QString& searchTerm, searchList )
{
bool match = false;
if ( searchFields & MatchTrack &&
track->prettyName().contains( searchTerm, Qt::CaseInsensitive )
)
match = true;
if ( searchFields & MatchArtist &&
track->artist() &&
track->artist()->prettyName().contains( searchTerm, Qt::CaseInsensitive )
)
match = true;
if ( searchFields & MatchAlbum &&
track->album() &&
track->album()->prettyName().contains( searchTerm, Qt::CaseInsensitive )
)
match = true;
if ( searchFields & MatchGenre &&
track->genre() &&
track->genre()->prettyName().contains( searchTerm, Qt::CaseInsensitive )
)
match = true;
if ( searchFields & MatchComposer &&
track->composer() &&
track->composer()->prettyName().contains( searchTerm, Qt::CaseInsensitive )
)
match = true;
if ( searchFields & MatchYear &&
track->year() &&
track->year()->prettyName().contains( searchTerm, Qt::CaseInsensitive )
)
match = true;
if( searchFields & MatchRating )
{
bool ok;
int rating = QString( searchTerm ).remove( "rating:" ).toInt( &ok );
if( ok && ( track->statistics()->rating() == rating ) )
match = true;
}
if( !match )
return false;
}
示例2:
void
CurrentTrack::trackRatingChanged( int rating )
{
Meta::TrackPtr track = The::engineController()->currentTrack();
if( !track )
return;
track->statistics()->setRating( rating );
}
示例3: buildDestination
QString TrackOrganizer::buildDestination(const QString& format, const Meta::TrackPtr& track) const
{
// get hold of the shared pointers
Meta::AlbumPtr album = track->album();
Meta::ArtistPtr artist = track->artist();
Meta::ComposerPtr composer = track->composer();
Meta::ArtistPtr albumArtist = album ? album->albumArtist() : Meta::ArtistPtr();
Meta::GenrePtr genre = track->genre();
Meta::YearPtr year = track->year();
bool isCompilation = album && album->isCompilation();
QMap<QString, QString> args;
QString strArtist = artist ? artist->name() : QString();
QString strAlbumArtist = isCompilation ? i18n( "Various Artists" ) :
( albumArtist ? albumArtist->name() : strArtist );
args["theartist"] = strArtist;
args["thealbumartist"] = strAlbumArtist;
if( m_postfixThe )
{
Amarok::manipulateThe( strArtist, true );
Amarok::manipulateThe( strAlbumArtist, true );
}
if ( track->trackNumber() )
{
QString trackNum = QString("%1").arg( track->trackNumber(), 2, 10, QChar('0') );
args["track"] = trackNum;
}
args["title"] = track->name();
args["artist"] = strArtist;
args["composer"] = composer ? composer->name() : QString();
// if year == 0 then we don't want include it
QString strYear = year ? year->name() : QString();
args["year"] = strYear.localeAwareCompare( "0" ) == 0 ? QString() : strYear;
args["album"] = track->album() ? track->album()->name() : QString();
args["albumartist"] = strAlbumArtist;
args["comment"] = track->comment();
args["genre"] = genre ? genre->name() : QString();
if( m_targetFileExtension.isEmpty() )
args["filetype"] = track->type();
else
args["filetype"] = m_targetFileExtension;
QString strFolder = QFileInfo( track->playableUrl().toLocalFile() ).path();
strFolder = strFolder.mid( commonPrefixLength( m_folderPrefix, strFolder ) );
args["folder"] = strFolder;
args["initial"] = strAlbumArtist.mid( 0, 1 ).toUpper(); //artists starting with The are already handled above
if( track->discNumber() )
args["discnumber"] = QString::number( track->discNumber() );
args["collectionroot"] = m_folderPrefix;
// some additional properties not supported by organize dialog.
args["rating"] = track->statistics()->rating();
args["filesize"] = track->filesize();
args["length"] = track->length() / 1000;
// Fill up default empty values for StringX formater
// TODO make this values changeable by user
args["default_album"] = i18n( "Unknown album" );
args["default_albumartist"] = i18n( "Unknown artist" );
args["default_artist"] = args["albumartist"];
args["default_thealbumartist"] = args["albumartist"];
args["default_theartist"] = args["albumartist"];
args["default_comment"] = i18n( "No comments" );
args["default_composer"] = i18n( "Unknown composer" );
args["default_discnumber"] = i18n( "Unknown disc number" );
args["default_genre"] = i18n( "Unknown genre" );
args["default_title"] = i18n( "Unknown title" );
args["default_year"] = i18n( "Unknown year" );
foreach( const QString &key, args.keys() )
if( key != "collectionroot" && key != "folder" )
args[key] = args[key].replace( '/', '-' );
Amarok::QStringx formatx( format );
QString result = formatx.namedOptArgs( args );
return cleanPath( result );
}
示例4: rx
void Playlist::PrettyItemDelegate::setModelData( QWidget * editor, QAbstractItemModel * model, const QModelIndex &index ) const
{
Q_UNUSED( model )
InlineEditorWidget * inlineEditor = qobject_cast<InlineEditorWidget *>( editor );
if( !inlineEditor )
return;
QMap<int, QString> changeMap = inlineEditor->changedValues();
debug() << "got inline editor!!";
debug() << "changed values map: " << changeMap;
//ok, now get the track, figure out if it is editable and if so, apply new values.
//It's as simple as that! :-)
Meta::TrackPtr track = index.data( TrackRole ).value<Meta::TrackPtr>();
if( !track )
return;
// this does not require TrackEditor
if( changeMap.contains( Rating ) )
{
int rating = changeMap.value( Rating ).toInt();
track->statistics()->setRating( rating );
changeMap.remove( Rating );
}
Meta::TrackEditorPtr ec = track->editor();
if( !ec )
return;
QList<int> columns = changeMap.keys();
foreach( int column, columns )
{
QString value = changeMap.value( column );
switch( column )
{
case Album:
ec->setAlbum( value );
break;
case Artist:
ec->setArtist( value );
break;
case Comment:
ec->setComment( value );
break;
case Composer:
ec->setComposer( value );
break;
case DiscNumber:
{
int discNumber = value.toInt();
ec->setDiscNumber( discNumber );
break;
}
case Genre:
ec->setGenre( value );
break;
case Rating:
break; // we've already set the rating, this even shouldn't be here
case Title:
ec->setTitle( value );
break;
case TitleWithTrackNum:
{
debug() << "parse TitleWithTrackNum";
//we need to parse out the track number and the track name (and check
//if the string is even valid...)
//QRegExp rx("(\\d+)\\s-\\s(.*))");
QRegExp rx("(\\d+)(\\s-\\s)(.*)");
if ( rx.indexIn( value ) != -1) {
int trackNumber = rx.cap( 1 ).toInt();
QString trackName = rx.cap( 3 );
debug() << "split TitleWithTrackNum into " << trackNumber << " and " << trackName;
ec->setTrackNumber( trackNumber );
ec->setTitle( trackName );
}
break;
}
case TrackNumber:
{
int TrackNumber = value.toInt();
ec->setTrackNumber( TrackNumber );
break;
}
case Year:
ec->setYear( value.toInt() );
break;
case Bpm:
ec->setBpm( value.toFloat() );
break;
}
}
示例5: 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 )
{
Meta::StatisticsPtr statistics = track->statistics();
statistics->beginUpdate();
if( rating != -1 )
statistics->setRating( rating );
if( lastplayed.isValid() )
statistics->setLastPlayed( lastplayed );
if( playcount != -1 )
statistics->setPlayCount( playcount );
statistics->endUpdate();
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 );
}
}
示例6: valueForField
QVariant Meta::valueForField( qint64 field, Meta::TrackPtr track )
{
if( !track )
return QVariant();
switch( field )
{
case 0:
{
// that is the simple search for MetaQueryWidget
QSet<QString> allInfos;
allInfos += track->playableUrl().path()
+= track->name()
+= track->comment();
if( track->artist() )
allInfos += track->artist()->name();
if( track->album() )
allInfos += track->album()->name();
if( track->genre() )
allInfos += track->genre()->name();
return QVariant( allInfos.toList() );
}
case Meta::valUrl: return track->playableUrl().path();
case Meta::valTitle: return track->name();
case Meta::valArtist: return track->artist() ?
QVariant(track->artist()->name()) : QVariant();
case Meta::valAlbum: return track->album() ?
QVariant(track->album()->name()) : QVariant();
case Meta::valGenre: return track->genre() ?
QVariant(track->genre()->name()) : QVariant();
case Meta::valComposer: return track->composer() ?
QVariant(track->composer()->name()) : QVariant();
case Meta::valYear: return track->year() ?
QVariant(track->year()->name().toInt()) : QVariant();
case Meta::valComment: return track->comment();
case Meta::valTrackNr: return track->trackNumber();
case Meta::valDiscNr: return track->discNumber();
case Meta::valBpm: return track->bpm();
case Meta::valLength: return track->length();
case Meta::valBitrate: return track->bitrate();
case Meta::valSamplerate: return track->sampleRate();
case Meta::valFilesize: return track->filesize();
case Meta::valFormat: return int(Amarok::FileTypeSupport::fileType(track->type()));
case Meta::valCreateDate: return track->createDate();
case Meta::valScore: return track->statistics()->score();
case Meta::valRating: return track->statistics()->rating();
case Meta::valFirstPlayed: return track->statistics()->firstPlayed();
case Meta::valLastPlayed: return track->statistics()->lastPlayed();
case Meta::valPlaycount: return track->statistics()->playCount();
case Meta::valUniqueId: return track->uidUrl();
// todo
case Meta::valTrackGain: return "track gain";
case Meta::valTrackGainPeak: return "track gain peak";
case Meta::valAlbumGain: return "album gain";
case Meta::valAlbumGainPeak: return "album gain peak";
case Meta::valAlbumArtist: return (track->album() && track->album()->albumArtist()) ?
QVariant(track->album()->albumArtist()->name()) : QVariant();
case Meta::valLabel:
{
Meta::LabelList labels = track->labels();
QStringList strLabels;
foreach( Meta::LabelPtr label, labels )
strLabels.append( label->name() );
return QVariant( strLabels );
}
case Meta::valModified: return track->modifyDate();
default: return QVariant();
}
}