Пример #1
0
/*******************************************************************************
    album part
*******************************************************************************/
void LocalScene::populateMostPlayedAlbum(int YPos)
{
    int albumRow  = 0;
    int Column    = 0;
    item_count    = (parentView()->width()/160 > 2) ? parentView()->width()/160 : 2;
    int maxPlaycount = 0;

    int char_entry = 0;

    CategorieGraphicItem *category = new CategorieGraphicItem(qobject_cast<QGraphicsView*> (parentView())->viewport());
    category->m_name = QString(tr("Most played albums"));
    category->setPos(0 ,YPos);
    addItem(category);

    //! get Album List from LocalTrackModel
    QList<MEDIA::AlbumPtr> albums = m_localTrackModel->albumItemList;

    //! sort
    qSort(albums.begin(), albums.end(), MEDIA::compareAlbumItemPlaycount);

    //! loop over album MediaItem
    foreach(MEDIA::AlbumPtr album, albums)
    {
      if(album->playcount == 0 || char_entry == MAX_CHART_ENTRY) break;

      if(maxPlaycount == 0)
        maxPlaycount = album->playcount;

      if( !m_localTrackModel->isMediaMatch(album) ) continue;

      AlbumGraphicItem_v3 *album_item = new AlbumGraphicItem_v3();
      album_item->media = album;
      album_item->setPos(4+160*Column, YPos + 35 + albumRow*190);

      addItem(album_item);
      char_entry++;

      if(Column < (item_count-1)) {
        Column++;
      }
      else {
        Column = 0;
        albumRow++;
      }
    }

    //! si liste vide --> message
    if(char_entry==0) {
      InfoGraphicItem *info = new InfoGraphicItem(qobject_cast<QGraphicsView*> (parentView())->viewport());
      info->_text = tr("No entry found");
      info->setPos( 0 , YPos + 50);
      addItem(info);
    }
}
Пример #2
0
/*******************************************************************************
    slot_on_directory_loaded
*******************************************************************************/
void FileScene::slot_on_directory_loaded()
{
    loading_directory = true;
    Debug::debug() << "   [FileScene] slot_on_directory_loaded";

    /* clear the scene FIRST */
    clear();
    m_infosize = 0;
    
    QStringList urls;
    
    /* populate scene */
    int folderRow     = 0;
    int trackRow      = 0;
    int Column        = 0;
    int categorieRow  = 0;
    
    item_count = (parentView()->width()/140 > 2) ? parentView()->width()/140 : 2;


    
    //! header item
    HeaderItem* header = new HeaderItem(qobject_cast<QGraphicsView*> (parentView())->viewport());
    header->setText( tr("Directories") );
    header->setPos(0, 5);
    addItem(header);    

    categorieRow++;
    
    CategorieGraphicItem *cat = new CategorieGraphicItem(qobject_cast<QGraphicsView*> (parentView())->viewport());
    cat->m_name = m_model->rootPath();
    cat->setPos( 0 ,10 + categorieRow*50);
    categorieRow++;
    addItem(cat);


    
    QModelIndex root_idx = m_model->index(m_current_path);
    
    
    for(int childRow = 0; childRow < m_model->rowCount(root_idx); ++childRow) 
    {
        QModelIndex childIndex = root_idx.child(childRow, 0);

        QFileInfo fileInfo = m_model->fileInfo ( childIndex );

        const QString path = fileInfo.canonicalFilePath();

        if(!m_filter.isEmpty() && !path.contains(m_filter,Qt::CaseInsensitive)) continue;

        if(fileInfo.isDir()) {
          DirectoryGraphicItem *item = new DirectoryGraphicItem();
          item->setPath(fileInfo.canonicalFilePath());
          item->setDirname(QDir(fileInfo.canonicalFilePath()).dirName());
          item->setPixmap(m_folder_pixmap);
          item->setPos(4+140*Column, 10 + folderRow*150 + categorieRow*50);
          addItem(item);
          //Debug::debug() << "FileScene::PopulateScene add item : " << item->path();
          m_infosize++;
        } // isDir
        else
        {
          urls << path;
          continue;
        }

        if(Column < (item_count-1)) {
          Column++;
        }
        else {
          Column = 0;
          folderRow++;
        }
    }  

    if(Column > 0)
      folderRow++;
    
    foreach (QString url, urls) 
    {    
        TrackGraphicItem_v4 *track_item = new TrackGraphicItem_v4();
      
        MEDIA::TrackPtr track = MEDIA::FromDataBase(url);
  
        //Debug::debug() << "FileScene try find url : " << url;
        if(!track) 
        {
          track = MEDIA::TrackPtr(new MEDIA::Track());

          track->id           =  -1;
          track->url          =  url;
          track->isPlaying    =  false;
          track->isBroken     =  false;
          track->isPlayed     =  false;
          track->isStopAfter  =  false;
  
          map_graphic_items[url] = track_item;
          QtConcurrent::run(this, &FileScene::async_load_item, track, url);
        }


        track_item->media = track;
        track_item->setPos(30,  10 + folderRow*150 + categorieRow*50 + trackRow*20);
        track_item->_width = parentView()->width()-30-20;
        addItem(track_item);
        trackRow++; 
        m_infosize++;


    }
Пример #3
0
void LocalScene::populateTopRatedArtist(int YPos)
{
    int artistRow  = 0;
    int Column     = 0;
    item_count = (parentView()->width()/160 > 2) ? parentView()->width()/160 : 2;
    int char_entry = 0;

    CategorieGraphicItem *category = new CategorieGraphicItem(qobject_cast<QGraphicsView*> (parentView())->viewport());
    category->m_name = QString(tr("Top rated artists"));
    category->setPos(0 ,YPos);
    addItem(category);

    //! get artists List from LocalTrackModel
    QList<MEDIA::ArtistPtr> artists;
    for (int i=0 ; i < m_localTrackModel->rootItem()->childCount(); i++ ) {
       artists << MEDIA::ArtistPtr::staticCast(m_localTrackModel->rootItem()->child(i));
     }

    //! sort
    qSort(artists.begin(), artists.end(), MEDIA::compareArtistItemRating);

    //! loop over artist MediaItem
    foreach(MEDIA::ArtistPtr artist, artists)
    {
      if(artist->rating == 0.0 || char_entry == MAX_CHART_ENTRY) break;

      if( !m_localTrackModel->isMediaMatch(artist) ) continue;

      ArtistGraphicItem_v3 *artist_item = new ArtistGraphicItem_v3();
      artist_item->media = artist;
      artist_item->setPos(4+160*Column, YPos + 35 + artistRow*190);

      addItem(artist_item);
      char_entry++;

      /* ALBUM COVER LOOP */
        artist_item->albums_covers.clear();
        for(int j = artist->childCount()-1 ; j >= 0; j--) {
          if(!m_localTrackModel->isMediaMatch(artist->child(j)) ) continue;
          MEDIA::AlbumPtr album = MEDIA::AlbumPtr::staticCast(artist->child(j));

          artist_item->albums_covers.prepend(album);

          /* WARNING limite de l'affichage à 6 cover max */
          if(artist_item->albums_covers.size() >=6) break;
        }

      if(Column < (item_count-1)) {
        Column++;
      }
      else {
        Column = 0;
        artistRow++;
      }
    }

    //! si liste vide --> message
    if(char_entry==0) {
      InfoGraphicItem *info = new InfoGraphicItem(qobject_cast<QGraphicsView*> (parentView())->viewport());
      info->_text = tr("No entry found");
      info->setPos( 0 , YPos + 50);
      addItem(info);
    }
}