File indexing completed on 2024-05-05 04:49:15

0001 /****************************************************************************************
0002  * Copyright (c) 2007 Nikolaj Hald Nielsen <nhn@kde.org>                                *
0003  * Copyright (c) 2007 Adam Pigg <adam@piggz.co.uk>                                      *
0004  *                                                                                      *
0005  * This program is free software; you can redistribute it and/or modify it under        *
0006  * the terms of the GNU General Public License as published by the Free Software        *
0007  * Foundation; either version 2 of the License, or (at your option) any later           *
0008  * version.                                                                             *
0009  *                                                                                      *
0010  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0011  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0012  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0013  *                                                                                      *
0014  * You should have received a copy of the GNU General Public License along with         *
0015  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0016  ****************************************************************************************/
0017 
0018 #include "DynamicServiceQueryMaker.h"
0019 
0020 #include "core/support/Debug.h"
0021 #include "ServiceCollection.h"
0022 
0023 using namespace Collections;
0024 
0025 DynamicServiceQueryMaker::DynamicServiceQueryMaker( )
0026  : QueryMaker()
0027 {
0028 }
0029 
0030 QueryMaker * DynamicServiceQueryMaker::addReturnValue(qint64 value)
0031 {
0032     Q_UNUSED( value );
0033     return this;
0034 }
0035 
0036 QueryMaker* DynamicServiceQueryMaker::addReturnFunction( ReturnFunction function, qint64 value )
0037 {
0038     AMAROK_NOTIMPLEMENTED
0039     Q_UNUSED( value )
0040     Q_UNUSED( function )
0041     return this;
0042 }
0043 
0044 QueryMaker * DynamicServiceQueryMaker::orderBy(qint64 value, bool descending)
0045 {
0046     Q_UNUSED( value );
0047     Q_UNUSED( descending );
0048     return this;
0049 }
0050 
0051 QueryMaker * DynamicServiceQueryMaker::addMatch(const Meta::TrackPtr & track)
0052 {
0053     DEBUG_BLOCK
0054     Q_UNUSED( track );
0055     return this;
0056 }
0057 
0058 QueryMaker * DynamicServiceQueryMaker::addMatch(const Meta::ArtistPtr & artist, QueryMaker::ArtistMatchBehaviour behaviour )
0059 {
0060     DEBUG_BLOCK
0061     Q_UNUSED( artist );
0062     Q_UNUSED( behaviour );
0063     return this;
0064 }
0065 
0066 QueryMaker * DynamicServiceQueryMaker::addMatch(const Meta::AlbumPtr & album)
0067 {
0068     DEBUG_BLOCK
0069     Q_UNUSED( album );
0070     return this;
0071 }
0072 
0073 QueryMaker * DynamicServiceQueryMaker::addMatch(const Meta::GenrePtr & genre)
0074 {
0075     DEBUG_BLOCK
0076     Q_UNUSED( genre );
0077     return this;
0078 }
0079 
0080 QueryMaker * DynamicServiceQueryMaker::addMatch(const Meta::ComposerPtr & composer)
0081 {
0082     DEBUG_BLOCK
0083     Q_UNUSED( composer );
0084     return this;
0085 }
0086 
0087 QueryMaker * DynamicServiceQueryMaker::addMatch(const Meta::YearPtr & year)
0088 {
0089     DEBUG_BLOCK
0090     Q_UNUSED( year );
0091     return this;
0092 }
0093 
0094 QueryMaker * DynamicServiceQueryMaker::addMatch(const Meta::LabelPtr & label)
0095 {
0096     DEBUG_BLOCK
0097     Q_UNUSED( label );
0098     return this;
0099 }
0100 
0101 QueryMaker * DynamicServiceQueryMaker::addFilter(qint64 value, const QString & filter, bool matchBegin, bool matchEnd)
0102 {
0103     Q_UNUSED( value );
0104     Q_UNUSED( filter );
0105     Q_UNUSED( matchBegin );
0106     Q_UNUSED( matchEnd );
0107     return this;
0108 }
0109 
0110 QueryMaker * DynamicServiceQueryMaker::excludeFilter(qint64 value, const QString & filter, bool matchBegin, bool matchEnd)
0111 {
0112     Q_UNUSED( value );
0113     Q_UNUSED( filter );
0114     Q_UNUSED( matchBegin );
0115     Q_UNUSED( matchEnd );
0116     return this;
0117 }
0118 
0119 QueryMaker* DynamicServiceQueryMaker::addNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare )
0120 {
0121     AMAROK_NOTIMPLEMENTED
0122     Q_UNUSED( value )
0123     Q_UNUSED( filter )
0124     Q_UNUSED( compare )
0125     return this;
0126 }
0127 
0128 QueryMaker* DynamicServiceQueryMaker::excludeNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare )
0129 {
0130     AMAROK_NOTIMPLEMENTED
0131     Q_UNUSED( value )
0132     Q_UNUSED( filter )
0133     Q_UNUSED( compare )
0134     return this;
0135 }
0136 
0137 QueryMaker * DynamicServiceQueryMaker::limitMaxResultSize(int size)
0138 {
0139     Q_UNUSED( size );
0140     return this;
0141 }
0142 
0143 Meta::AlbumList
0144 DynamicServiceQueryMaker::matchAlbums( ServiceCollection *coll, const Meta::ArtistPtr &artist )
0145 {
0146     if( !artist || !coll )
0147         return Meta::AlbumList();
0148     ArtistMap artistMap = coll->artistMap();
0149     if ( artist && artistMap.contains( artist->name() ) )
0150     {
0151         Meta::ArtistPtr artist2 = artistMap.value( artist->name() );
0152 
0153         Meta::AlbumList matchingAlbums;
0154         Meta::AlbumList albums = coll->albumMap().values();
0155 
0156         foreach( Meta::AlbumPtr albumPtr, albums ) {
0157 
0158             if ( albumPtr->albumArtist() == artist2 )
0159                 matchingAlbums.push_back( albumPtr );
0160         }
0161 
0162         return matchingAlbums;
0163     }
0164     else
0165         return Meta::AlbumList();
0166 }
0167 
0168 
0169