示例#1
0
void
TrackInfoWidget::load( const query_ptr& query )
{
    m_query = query;
    m_artist = Artist::get( m_query->artist() );
    m_title = QString( "%1 - %2" ).arg( query->artist() ).arg( query->track() );

    if ( !m_query.isNull() )
    {
        disconnect( m_query.data(), SIGNAL( statsLoaded() ), this, SLOT( onStatsLoaded() ) );
        disconnect( m_query.data(), SIGNAL( updated() ), this, SLOT( onCoverUpdated() ) );
        disconnect( m_artist.data(), SIGNAL( statsLoaded() ), this, SLOT( onStatsLoaded() ) );
        disconnect( m_artist.data(), SIGNAL( similarArtistsLoaded() ), this, SLOT( onSimilarArtistsLoaded() ) );
    }

    connect( m_artist.data(), SIGNAL( similarArtistsLoaded() ), SLOT( onSimilarArtistsLoaded() ) );
    connect( m_artist.data(), SIGNAL( statsLoaded() ), SLOT( onStatsLoaded() ) );
    connect( m_query.data(), SIGNAL( similarTracksLoaded() ), SLOT( onSimilarTracksLoaded() ) );
    connect( m_query.data(), SIGNAL( updated() ), SLOT( onCoverUpdated() ) );
    connect( m_query.data(), SIGNAL( statsLoaded() ), SLOT( onStatsLoaded() ) );

    m_artist->loadStats();
    m_query->loadStats();
    onCoverUpdated();

    ui->trackLabel->setText( query->track() );
    ui->artistLabel->setText( query->artist() );
    ui->albumLabel->setText( query->album() );
    ui->fromLabel->setVisible( !query->album().isEmpty() );

    m_query->similarTracks();
    m_albumsModel->addArtists( m_artist->similarArtists() );
    m_albumsModel->clear();
}
QList<Tomahawk::query_ptr>
PlaylistInterface::filterTracks( const QList<Tomahawk::query_ptr>& queries )
{
    QList<Tomahawk::query_ptr> result;

    for ( int i = 0; i < queries.count(); i++ )
    {
        bool picked = true;
        const query_ptr q1 = queries.at( i );

        for ( int j = 0; j < result.count(); j++ )
        {
            if ( !picked )
                break;

            const query_ptr& q2 = result.at( j );

            if ( q1->track() == q2->track() )
            {
                picked = false;
            }
        }

        if ( picked )
        {
            query_ptr q = Query::get( q1->artist(), q1->track(), q1->album(), uuid(), false );
            q->setAlbumPos( q1->results().first()->albumpos() );
            q->setDiscNumber( q1->discnumber() );
            result << q;
        }
    }

    Pipeline::instance()->resolve( result );
    return result;
}
示例#3
0
QUrl
GlobalActionManager::openLinkFromQuery( const query_ptr& query ) const
{
    QString title, artist, album;

    if( !query->results().isEmpty() && !query->results().first().isNull() )
    {
        title = query->results().first()->track();
        artist = query->results().first()->artist().isNull() ? QString() : query->results().first()->artist()->name();
        album = query->results().first()->album().isNull() ? QString() : query->results().first()->album()->name();
    } else
    {
        title = query->track();
        artist = query->artist();
        album = query->album();
    }

    return openLink( title, artist, album );
}