示例#1
0
void BrowserView::jump_to_media(MEDIA::MediaPtr media)
{
    VIEW::Id mode;

    if(!media)
      return;
    
    if(media->type() == TYPE_ARTIST)
      mode = VIEW::ViewArtist;
    else if(media->type() == TYPE_ALBUM)
      mode = VIEW::ViewAlbum;
    else if(media->type() == TYPE_TRACK)
      mode = VIEW::ViewTrack;
    else return;  
      
    CentralToolBar::instance()->setExplorerFilterText("");
    m_scenes[VIEW::ViewArtist]->setFilter("");
    m_scenes[VIEW::ViewTuneIn]->setFilter("");
    m_scenes[VIEW::ViewFileSystem]->setFilter("");
      
    active_view(mode,"", QVariant());

    /* localise item */
    QPoint p = static_cast<LocalScene*>(m_scenes[mode])->get_item_position(media);

    if(!p.isNull()) 
      this->verticalScrollBar()->setSliderPosition( p.y() - 40 );
}
示例#2
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;
}
示例#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;
}
示例#4
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;
}