Пример #1
0
void K3b::InfFileWriter::setTrackCdText( const K3b::Device::TrackCdText& cdtext )
{
    setTrackTitle( cdtext.title() );
    setTrackPerformer( cdtext.performer() );
    setTrackSongwriter( cdtext.songwriter() );
    setTrackComposer( cdtext.composer() );
    setTrackArranger( cdtext.arranger() );
    setTrackMessage( cdtext.message() );
}
void PhononItem::metaStateChanged(Phonon::State newState, Phonon::State oldState) {
    Q_UNUSED(oldState);
  //  static QObjectWriter writer(this, false);

    if (newState == Phonon::ErrorState) {
        qDebug() << "PhononItem: Error Opening File: " << fileName();

        emit fetched(false);
        return;
    }

    if (m_metaMedia->currentSource().type() == Phonon::MediaSource::Invalid) {

        emit fetched(false);
        qDebug() << "Invalid metadata: " << fileName();
        return;
    }

    QMap<QString, QString> metaData = m_metaMedia->metaData();

    setArtist(metaData.value("ARTIST"));
    setTrackTitle(metaData.value("TITLE"));
    setAlbumTitle(metaData.value("ALBUM"));
    setGenre(metaData.value("GENRE"));
    QString tn = metaData.value("TRACK-NUMBER");
    if (tn == QString()) tn = metaData.value("TRACKNUMBER");
    setTrackNumber(tn);
    extendedComment = QString();
    QString comment =  metaData.value("COMMENT");
    setComment(comment);
    
    // http://www.freedesktop.org/wiki/Specifications/free-media-player-specs
    QString fmpsRating = metaData.value("FMPS_Rating");
    // ??? Why does this not work?
    if (fmpsRating.toDouble() > 0 ) {
        int stars = fmpsRating.toDouble() * 10;
        Preference fmpsPref(stars);
        qDebug() << "FMPS Rating: " << stars;
        setPreference(fmpsPref);
    }

    // Preference can be obtained from various ways.
    else setPreference(comment);

    // Check for MusicMatch preference
    if ((preference().intValue() == 0) && metaData.contains("EXTENDED-COMMENT")) {
        extendedComment = metaData.value("EXTENDED-COMMENT");
        int eqidx = extendedComment.indexOf("=");
        if (eqidx > 0)
            extendedComment=extendedComment.mid(eqidx+1);
        Preference p(extendedComment);
        if (p.intValue() > 0) {
            setPreference(p);
            setComment(p.toString());
        }
    }

//start id="notify"
    m_loaded = true;
    if (m_timeSet) {
        emit fetched();
    }
//end

}