Beispiel #1
0
CoverManager::CoverManager( QWidget *parent )
        : KDialog( parent )
        , m_currentView( AllAlbums )
        , m_timer( new QTimer( this ) )    //search filter timer
        , m_fetchingCovers( false )
        , m_coversFetched( 0 )
        , m_coverErrors( 0 )
        , m_isLoadingCancelled( false )
{
    DEBUG_BLOCK

    setObjectName( "TheCoverManager" );

    s_instance = this;

    // Sets caption and icon correctly (needed e.g. for GNOME)
    kapp->setTopWidget( this );
    setButtons( 0 );
    setCaption( i18n("Cover Manager") );
    setAttribute( Qt::WA_DeleteOnClose );

    connect( this, SIGNAL(hidden()), SLOT(delayedDestruct()) );
    connect( this, SIGNAL(closeClicked()), SLOT(delayedDestruct()) );

    m_splitter = new QSplitter( this );
    setMainWidget( m_splitter );

    //artist listview
    m_artistView = new QTreeWidget( m_splitter );
    m_artistView->setHeaderLabel( i18n( "Albums By" ) );
    m_artistView->setSortingEnabled( false );
    m_artistView->setTextElideMode( Qt::ElideRight );
    m_artistView->setMinimumWidth( 200 );
    m_artistView->setColumnCount( 1 );
    m_artistView->setAlternatingRowColors( true );
    m_artistView->setUniformRowHeights( true );
    m_artistView->setSelectionMode( QAbstractItemView::ExtendedSelection );

    ArtistItem *item = 0;
    item = new ArtistItem( i18n( "All Artists" ) );
    item->setIcon(0, SmallIcon( "media-optical-audio-amarok" ) );
    m_items.append( item );

    Collections::Collection *coll = CollectionManager::instance()->primaryCollection();
    Collections::QueryMaker *qm = coll->queryMaker();
    qm->setAutoDelete( true );
    qm->setQueryType( Collections::QueryMaker::Artist );
    qm->setAlbumQueryMode( Collections::QueryMaker::OnlyNormalAlbums );
    qm->orderBy( Meta::valArtist );

    connect( qm, SIGNAL(newResultReady(Meta::ArtistList)),
             this, SLOT(slotArtistQueryResult(Meta::ArtistList)) );

    connect( qm, SIGNAL(queryDone()), this, SLOT(slotContinueConstruction()) );

    qm->run();
}
Beispiel #2
0
void
CurrentEngine::update( Meta::AlbumPtr album )
{
    if( !m_requested.value( QLatin1String("albums") ) )
        return;

    DEBUG_BLOCK
    m_lastQueryMaker = 0;
    Meta::TrackPtr track = The::engineController()->currentTrack();

    if( !album )
        return;

    Meta::ArtistPtr artist = track->artist();

    // Prefer track artist to album artist BUG: 266682
    if( !artist )
        artist = album->albumArtist();
    
    if( artist && !artist->name().isEmpty() )
    {
        m_albums.clear();
        m_albumData.clear();
        m_albumData[ QLatin1String("currentTrack") ] = qVariantFromValue( track );
        m_albumData[ QLatin1String("headerText") ] = QVariant( i18n( "Albums by %1", artist->name() ) );

        // -- search the collection for albums with the same artist
        Collections::QueryMaker *qm = CollectionManager::instance()->queryMaker();
        qm->setAutoDelete( true );
        qm->addFilter( Meta::valArtist, artist->name(), true, true );
        qm->setAlbumQueryMode( Collections::QueryMaker::AllAlbums );
        qm->setQueryType( Collections::QueryMaker::Album );

        connect( qm, SIGNAL(newResultReady( Meta::AlbumList)),
                 SLOT(resultReady( Meta::AlbumList)), Qt::QueuedConnection );
        connect( qm, SIGNAL(queryDone()), SLOT(setupAlbumsData()) );

        m_lastQueryMaker = qm;
        qm->run();
    }
    else
    {
        removeAllData( QLatin1String("albums") );
        setData( QLatin1String("albums"), QLatin1String("headerText"),
                 i18nc( "Header text for current album applet", "Albums" ) );
    }
}