Пример #1
0
void
TestMemoryQueryMaker::testFilterTitle()
{
    Meta::TrackList tracks;

    // -- just get all the tracks
    Collections::MemoryQueryMaker *qm = new Collections::MemoryQueryMaker( m_mc.toWeakRef(), "test" );
    tracks = executeQueryMaker( qm );
    QCOMPARE( tracks.count(), 3 );

    // -- filter for title
    qm = new Collections::MemoryQueryMaker( m_mc.toWeakRef(), "test" );
    qm->addFilter( Meta::valTitle, "Skater", true, false );
    tracks = executeQueryMaker( qm );
    QCOMPARE( tracks.count(), 1 );
    QCOMPARE( tracks.first()->name(), QString("Skater Boy" ) );

    // -- filter for album
    qm = new Collections::MemoryQueryMaker( m_mc.toWeakRef(), "test" );
    qm->addFilter( Meta::valAlbum, "S", false, false );
    tracks = executeQueryMaker( qm );
    QCOMPARE( tracks.count(), 1 );
    QCOMPARE( tracks.first()->name(), QString("Substitute" ) );

    // -- filter for artist
    qm = new Collections::MemoryQueryMaker( m_mc.toWeakRef(), "test" );
    qm->addFilter( Meta::valArtist, "Lavigne", false, true );
    tracks = executeQueryMaker( qm );
    QCOMPARE( tracks.count(), 1 );
    QCOMPARE( tracks.first()->name(), QString("Skater Boy" ) );
}
Пример #2
0
void
AlbumItem::update()
{
    if( !m_album )
        return;

    Meta::TrackList tracks = m_album->tracks();
    if( !tracks.isEmpty() )
    {
        Meta::TrackPtr first = tracks.first();
        Meta::YearPtr year = first->year();
        if( year )
            setData( year->year(), AlbumYearRole );
    }

    QString albumName = m_album->name();
    albumName = albumName.isEmpty() ? i18n("Unknown") : albumName;
    QString name = ( m_showArtist && m_album->hasAlbumArtist() )
                 ? QString( "%1 - %2" ).arg( m_album->albumArtist()->name(), albumName )
                 : albumName;
    setData( name, NameRole );

    qint64 totalTime = 0;
    foreach( Meta::TrackPtr item, tracks )
        totalTime += item->length();

    QString trackCount = i18np( "%1 track", "%1 tracks", tracks.size() );
    QString lengthText = QString( "%1, %2" ).arg( trackCount, Meta::msToPrettyTime( totalTime ) );
    setData( lengthText, AlbumLengthRole );

    QPixmap cover = The::svgHandler()->imageWithBorder( m_album, m_iconSize, 3 );
    setIcon( QIcon( cover ) );
}
Пример #3
0
void
TestMemoryQueryMaker::testFilterAnd()
{
    Meta::TrackList tracks;
    Collections::MemoryQueryMaker *qm = 0;

    qm = new Collections::MemoryQueryMaker( m_mc.toWeakRef(), "test" );
    qm->beginAnd();
    qm->addNumberFilter( Meta::valTrackNr, 1, Collections::QueryMaker::Equals );
    qm->addFilter( Meta::valAlbum, "o", false, false );
    qm->endAndOr();
    tracks = executeQueryMaker( qm );
    QCOMPARE( tracks.count(), 1 );
    QCOMPARE( tracks.first()->album()->name(), QString("Rodeo Radio" ) );
}
Пример #4
0
void
TestMemoryQueryMaker::testFilterRating()
{
    Meta::TrackList tracks;
    Collections::MemoryQueryMaker *qm = 0;

    // -- filter for Rating
    qm = new Collections::MemoryQueryMaker( m_mc.toWeakRef(), "test" );
    qm->addNumberFilter( Meta::valRating, 3, Collections::QueryMaker::Equals );
    tracks = executeQueryMaker( qm );
    QCOMPARE( tracks.count(), 1 );
    QCOMPARE( tracks.first()->name(), QString("Skater Boy" ) );

    // -- filter for Rating
    qm = new Collections::MemoryQueryMaker( m_mc.toWeakRef(), "test" );
    qm->addNumberFilter( Meta::valRating, 4, Collections::QueryMaker::LessThan );
    tracks = executeQueryMaker( qm );
    QCOMPARE( tracks.count(), 2 );
}