Esempio n. 1
0
void
MetaQueryWidget::makeMetaComboSelection( qint64 field )
{
    Collections::QueryMaker* qm = new Collections::MetaQueryMaker( CollectionManager::instance()->queryableCollections() );
    qm->setQueryType( Collections::QueryMaker::Custom );
    qm->addReturnValue( field );
    qm->setAutoDelete( true );
    makeGenericComboSelection( true, qm );
}
Esempio n. 2
0
void
CurrentEngine::stopped()
{
    if( m_requested.value( QLatin1String("current") ) )
    {
        removeAllData( "current" );
        setData( "current", "notrack", i18n( "No track playing") );
        m_currentTrack.clear();
    }

    if( m_requested.value( QLatin1String("albums") ) )
    {
        removeAllData( "albums" );
        m_albumData.clear();

        // Collect data for the recently added albums
        setData( "albums", "headerText", QVariant( i18n( "Recently Added Albums" ) ) );
        m_albums.clear();

        Collections::QueryMaker *qm = CollectionManager::instance()->queryMaker();
        qm->setAutoDelete( true );
        qm->setQueryType( Collections::QueryMaker::Album );
        qm->excludeFilter( Meta::valAlbum, QString(), true, true );
        qm->orderBy( Meta::valCreateDate, true );
        qm->limitMaxResultSize( Amarok::config("Albums Applet").readEntry("RecentlyAdded", 5) );

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

        m_lastQueryMaker = qm;
        qm->run();
    }
}
Esempio n. 3
0
void
CurrentTrack::queryCollection()
{
    Collections::QueryMaker *qmTracks = CollectionManager::instance()->queryMaker();
    Collections::QueryMaker *qmAlbums = CollectionManager::instance()->queryMaker();
    Collections::QueryMaker *qmArtists = CollectionManager::instance()->queryMaker();
    connect( qmTracks, SIGNAL(newResultReady(QStringList)),
             this, SLOT(tracksCounted(QStringList)) );
    connect( qmAlbums, SIGNAL(newResultReady(QStringList)),
             this, SLOT(albumsCounted(QStringList)) );
    connect( qmArtists, SIGNAL(newResultReady(QStringList)),
             this, SLOT(artistsCounted(QStringList)) );

    qmTracks->setAutoDelete( true )
      ->setQueryType( Collections::QueryMaker::Custom )
      ->addReturnFunction( Collections::QueryMaker::Count, Meta::valUrl )
      ->run();
    qmAlbums->setAutoDelete( true )
      ->setQueryType( Collections::QueryMaker::Custom )
      ->addReturnFunction( Collections::QueryMaker::Count, Meta::valAlbum )
      ->run();
    qmArtists->setAutoDelete( true )
      ->setQueryType( Collections::QueryMaker::Custom )
      ->addReturnFunction( Collections::QueryMaker::Count, Meta::valArtist )
      ->run();
}
Esempio n. 4
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();
}
Esempio n. 5
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" ) );
    }
}
Esempio n. 6
0
void
IpodCopyTracksJob::slotStartDuplicateTrackSearch( const Meta::TrackPtr &track )
{
    Collections::QueryMaker *qm = m_coll.data()->queryMaker();
    qm->setQueryType( Collections::QueryMaker::Track );

    // we cannot qm->addMatch( track ) - it matches by uidUrl()
    qm->addFilter( Meta::valTitle, track->name(), true, true );
    qm->addMatch( track->album() );
    qm->setArtistQueryMode( Collections::QueryMaker::TrackArtists );
    qm->addMatch( track->artist() );
    qm->addMatch( track->composer() );
    qm->addMatch( track->genre() );
    qm->addMatch( track->year() );
    qm->addNumberFilter( Meta::valTrackNr, track->trackNumber(), Collections::QueryMaker::Equals );
    qm->addNumberFilter( Meta::valDiscNr, track->discNumber(), Collections::QueryMaker::Equals );
    // we don't want to match by filesize, track length, filetype etc - these change during
    // transcoding. We don't match album artist because handling of it is inconsistent

    connect( qm, SIGNAL(newResultReady(Meta::TrackList)),
             SLOT(slotDuplicateTrackSearchNewResult(Meta::TrackList)) );
    connect( qm, SIGNAL(queryDone()), SLOT(slotDuplicateTrackSearchQueryDone()) );
    qm->setAutoDelete( true );
    m_duplicateTrack = Meta::TrackPtr(); // reset duplicate track from previous query
    qm->run();
}