Пример #1
0
bool
Playlists::canExpand( Meta::TrackPtr track )
{
    if( !track )
        return false;

    return Playlists::getFormat( track->uidUrl() ) != Playlists::NotPlaylist;
}
Пример #2
0
QPixmap MoodbarManager::getMoodbar( Meta::TrackPtr track, int width, int height, bool rtl )
{
    //if we have already marked this track as
    //not having a moodbar, don't even bother...
    if ( m_hasMoodMap.contains( track ) )
        if( !m_hasMoodMap.value( track ) )
            return QPixmap();
        

    //first of all... Check if rendering settings have changed. If
    //so, clear data and pixmap caches.

    if( m_lastPaintMode != AmarokConfig::moodbarPaintStyle() )
    {
        m_lastPaintMode = AmarokConfig::moodbarPaintStyle();
        m_cache->clear();
        m_moodDataMap.clear();
        emit moodbarStyleChanged();
    }


    //Do we already have this pixmap cached?
    const QString pixmapKey = QString( "mood:%1-%2x%3%4" ).arg( track->uidUrl() ).arg(width).arg(height).arg( rtl?"r":"" );
    QPixmap moodbar;
    
    if( m_cache->findPixmap( pixmapKey, &moodbar ) )
        return moodbar;
        
    //No? Ok, then create it reusing as much info as possible

    MoodbarColorList data;

    if ( m_moodDataMap.contains( track ) )
        data = m_moodDataMap.value( track );
    else
    {

        QString moodFilePath;
        if ( m_moodFileMap.contains( track ) )
            moodFilePath = m_moodFileMap.value( track );
        else
            moodFilePath = moodPath( track->playableUrl().path() );
        
        data = readMoodFile( moodFilePath );

        if ( data.size() > 10 )
            m_moodDataMap.insert( track, data );
        else
        {
            //likely a corrupt file, so mark this track as not having a moodbar
             m_hasMoodMap.insert( track, false );
        }
    }

    //assume that the readMoodFile function emits the proper error...
    if ( data.size() < 10 )
        return moodbar;

    moodbar = drawMoodbar( data, width, height, rtl );
    m_cache->insertPixmap( pixmapKey, moodbar );
    
    return moodbar;
}
Пример #3
0
PlaylistPtr
Playlists::expand( Meta::TrackPtr track )
{
   return Playlists::PlaylistPtr::dynamicCast( loadPlaylistFile( track->uidUrl() ) );
}
Пример #4
0
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();
    }
}