Esempio n. 1
0
//! ----------------------- Get tracks method ----------------------------------
QList<MEDIA::TrackPtr> LocalTrackModel::getItemChildrenTracks(const MEDIA::MediaPtr parent)
{
    //Debug::debug() << "      [LocalTrackModel] getItemChildrenTracks";

    QList<MEDIA::TrackPtr> result;
    if(!parent)
      return result;

    MEDIA::MediaPtr media = parent;

    if (media->type() == TYPE_TRACK) 
    {
      SearchEngine se;
      bool match = se.mediaMatch(
                       qvariant_cast<MediaSearch>(m_search), 
                       MEDIA::TrackPtr::staticCast(media) );
      if(match)
        result.append( MEDIA::TrackPtr::staticCast(media) );
    }
    else 
    {
      //! Recursive !!
      for (int i = 0; i < media->childCount(); i++) {
        result.append( getItemChildrenTracks(media->child(i)) );
      }
    }

    return result;
}
Esempio n. 2
0
//! ----------------------- Get rating method ----------------------------------
float LocalTrackModel::getItemAutoRating(const MEDIA::MediaPtr media)
{
    float auto_rating = 0.0;
    int   count = 0;
    if(!media) return auto_rating;

    if (media->type() == TYPE_TRACK)
    {
        //Debug::debug() << " => getItemAutoRating : return track rating = " << media->data.rating;
        return MEDIA::TrackPtr::staticCast(media)->rating;
    }
    else {
      //! Recursive !!
      for (/*count*/; count < media->childCount(); count++)
      {
        auto_rating += getItemAutoRating( media->child(count) );
      }
    }

    float result =  media->childCount()!=0 ? float(auto_rating/(media->childCount())) : 0 ;
    result = double(int(result * 5 * 2 + 0.5)) / (5 * 2);
    //Debug::debug() << " => getItemAutoRating : rating = " << result;
    return result;
}
Esempio n. 3
0
//! ------------------------- filtering method ---------------------------------
bool LocalTrackModel::isMediaMatch(MEDIA::MediaPtr media)
{
    if(m_search.isNull())
      return true;

    if (media->type() == TYPE_TRACK)
    {
      SearchEngine se;
      bool match = se.mediaMatch(
                       qvariant_cast<MediaSearch>(m_search), 
                       MEDIA::TrackPtr::staticCast(media) );
      if(match) return true;
    }
    else
    {
      for (int i = 0; i < media->childCount(); i++)
        if( isMediaMatch( media->child(i) ) )
          return true;
    }
    
    return false;
}