Ejemplo n.º 1
0
void
AlbumInfoWidget::load( const album_ptr& album )
{
    m_album = album;
    m_title = album->name();
    m_description = album->artist()->name();
    ui->albumsLabel->setText( tr( "Other Albums by %1" ).arg( album->artist()->name() ) );

    m_tracksModel->addTracks( album, QModelIndex() );

    DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums();
    cmd->setArtist( album->artist() );

    connect( cmd, SIGNAL( albums( QList<Tomahawk::album_ptr>, QVariant ) ),
                    SLOT( gotAlbums( QList<Tomahawk::album_ptr> ) ) );

    Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );

    Tomahawk::InfoSystem::InfoCriteriaHash trackInfo;
    trackInfo["artist"] = album->artist()->name();
    trackInfo["album"] = album->name();

    Tomahawk::InfoSystem::InfoRequestData requestData;
    requestData.caller = s_aiInfoIdentifier;
    requestData.type = Tomahawk::InfoSystem::InfoAlbumCoverArt;
    requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo );
    requestData.customData = QVariantMap();

    Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
}
Ejemplo n.º 2
0
QList<album_ptr>
Artist::albums( ModelMode mode, const Tomahawk::collection_ptr& collection ) const
{
    artist_ptr artist = m_ownRef.toStrongRef();

    bool dbLoaded = m_albumsLoaded.value( DatabaseMode );
    const bool infoLoaded = m_albumsLoaded.value( InfoSystemMode );
    if ( !collection.isNull() )
        dbLoaded = false;

    m_uuid = uuid();
    tDebug() << Q_FUNC_INFO << mode;

    if ( ( mode == DatabaseMode || mode == Mixed ) && !dbLoaded )
    {
        DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( collection, artist );
        cmd->setData( QVariant( collection.isNull() ) );

        connect( cmd, SIGNAL( albums( QList<Tomahawk::album_ptr>, QVariant ) ),
                        SLOT( onAlbumsFound( QList<Tomahawk::album_ptr>, QVariant ) ) );

        Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
    }

    if ( ( mode == InfoSystemMode || mode == Mixed ) && !infoLoaded )
    {
        Tomahawk::InfoSystem::InfoStringHash artistInfo;
        artistInfo["artist"] = name();

        Tomahawk::InfoSystem::InfoRequestData requestData;
        requestData.caller = m_uuid;
        requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( artistInfo );
        requestData.type = Tomahawk::InfoSystem::InfoArtistReleases;

        connect( Tomahawk::InfoSystem::InfoSystem::instance(),
                 SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
                 SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ), Qt::UniqueConnection );

        connect( Tomahawk::InfoSystem::InfoSystem::instance(),
                 SIGNAL( finished( QString ) ),
                 SLOT( infoSystemFinished( QString ) ), Qt::UniqueConnection );

        m_infoJobs++;
        Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
    }

    if ( !collection.isNull() )
        return QList<album_ptr>();

    switch ( mode )
    {
        case DatabaseMode:
            return m_databaseAlbums;
        case InfoSystemMode:
            return m_officialAlbums;
        default:
            return m_databaseAlbums + m_officialAlbums;
    }
}
Ejemplo n.º 3
0
void
TreeProxyModel::onRowsInserted( const QModelIndex& parent, int /* start */, int /* end */ )
{
    if ( m_filter.isEmpty() )
        return;
    if ( sender() != m_model )
        return;

    TreeModelItem* pi = m_model->itemFromIndex( m_model->index( parent.row(), 0, parent.parent() ) );
    if ( pi->artist().isNull() )
        return;

    DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( m_model->collection() );
    cmd->setArtist( pi->artist() );
    cmd->setFilter( m_filter );

    connect( cmd, SIGNAL( albums( QList<Tomahawk::album_ptr>, QVariant ) ),
                    SLOT( onFilterAlbums( QList<Tomahawk::album_ptr> ) ) );

    Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
}
Ejemplo n.º 4
0
void
TreeProxyModel::onFilterArtists( const QList<Tomahawk::artist_ptr>& artists )
{
    bool finished = true;
    m_artistsFilter = artists;
    m_artistsFilterCmd = 0;

    foreach ( const Tomahawk::artist_ptr& artist, artists )
    {
        QModelIndex idx = m_model->indexFromArtist( artist );
        if ( m_model->rowCount( idx ) )
        {
            finished = false;

            DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( m_model->collection() );
            cmd->setArtist( artist );
            cmd->setFilter( m_filter );

            connect( cmd, SIGNAL( albums( QList<Tomahawk::album_ptr>, QVariant ) ),
                            SLOT( onFilterAlbums( QList<Tomahawk::album_ptr> ) ) );

            Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
        }
    }