1 /****************************************************************************************
2 * Copyright (c) 2007 Nikolaj Hald Nielsen <nhn@kde.org> *
3 * Copyright (c) 2007 Adam Pigg <adam@piggz.co.uk> *
4 * *
5 * This program is free software; you can redistribute it and/or modify it under *
6 * the terms of the GNU General Public License as published by the Free Software *
7 * Foundation; either version 2 of the License, or (at your option) any later *
8 * version. *
9 * *
10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY *
11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A *
12 * PARTICULAR PURPOSE. See the GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License along with *
15 * this program. If not, see <http://www.gnu.org/licenses/>. *
16 ****************************************************************************************/
17
18 #include "DynamicServiceQueryMaker.h"
19
20 #include "core/support/Debug.h"
21 #include "ServiceCollection.h"
22
23 using namespace Collections;
24
DynamicServiceQueryMaker()25 DynamicServiceQueryMaker::DynamicServiceQueryMaker( )
26 : QueryMaker()
27 {
28 }
29
addReturnValue(qint64 value)30 QueryMaker * DynamicServiceQueryMaker::addReturnValue(qint64 value)
31 {
32 Q_UNUSED( value );
33 return this;
34 }
35
addReturnFunction(ReturnFunction function,qint64 value)36 QueryMaker* DynamicServiceQueryMaker::addReturnFunction( ReturnFunction function, qint64 value )
37 {
38 AMAROK_NOTIMPLEMENTED
39 Q_UNUSED( value )
40 Q_UNUSED( function )
41 return this;
42 }
43
orderBy(qint64 value,bool descending)44 QueryMaker * DynamicServiceQueryMaker::orderBy(qint64 value, bool descending)
45 {
46 Q_UNUSED( value );
47 Q_UNUSED( descending );
48 return this;
49 }
50
addMatch(const Meta::TrackPtr & track)51 QueryMaker * DynamicServiceQueryMaker::addMatch(const Meta::TrackPtr & track)
52 {
53 DEBUG_BLOCK
54 Q_UNUSED( track );
55 return this;
56 }
57
addMatch(const Meta::ArtistPtr & artist,QueryMaker::ArtistMatchBehaviour behaviour)58 QueryMaker * DynamicServiceQueryMaker::addMatch(const Meta::ArtistPtr & artist, QueryMaker::ArtistMatchBehaviour behaviour )
59 {
60 DEBUG_BLOCK
61 Q_UNUSED( artist );
62 Q_UNUSED( behaviour );
63 return this;
64 }
65
addMatch(const Meta::AlbumPtr & album)66 QueryMaker * DynamicServiceQueryMaker::addMatch(const Meta::AlbumPtr & album)
67 {
68 DEBUG_BLOCK
69 Q_UNUSED( album );
70 return this;
71 }
72
addMatch(const Meta::GenrePtr & genre)73 QueryMaker * DynamicServiceQueryMaker::addMatch(const Meta::GenrePtr & genre)
74 {
75 DEBUG_BLOCK
76 Q_UNUSED( genre );
77 return this;
78 }
79
addMatch(const Meta::ComposerPtr & composer)80 QueryMaker * DynamicServiceQueryMaker::addMatch(const Meta::ComposerPtr & composer)
81 {
82 DEBUG_BLOCK
83 Q_UNUSED( composer );
84 return this;
85 }
86
addMatch(const Meta::YearPtr & year)87 QueryMaker * DynamicServiceQueryMaker::addMatch(const Meta::YearPtr & year)
88 {
89 DEBUG_BLOCK
90 Q_UNUSED( year );
91 return this;
92 }
93
addMatch(const Meta::LabelPtr & label)94 QueryMaker * DynamicServiceQueryMaker::addMatch(const Meta::LabelPtr & label)
95 {
96 DEBUG_BLOCK
97 Q_UNUSED( label );
98 return this;
99 }
100
addFilter(qint64 value,const QString & filter,bool matchBegin,bool matchEnd)101 QueryMaker * DynamicServiceQueryMaker::addFilter(qint64 value, const QString & filter, bool matchBegin, bool matchEnd)
102 {
103 Q_UNUSED( value );
104 Q_UNUSED( filter );
105 Q_UNUSED( matchBegin );
106 Q_UNUSED( matchEnd );
107 return this;
108 }
109
excludeFilter(qint64 value,const QString & filter,bool matchBegin,bool matchEnd)110 QueryMaker * DynamicServiceQueryMaker::excludeFilter(qint64 value, const QString & filter, bool matchBegin, bool matchEnd)
111 {
112 Q_UNUSED( value );
113 Q_UNUSED( filter );
114 Q_UNUSED( matchBegin );
115 Q_UNUSED( matchEnd );
116 return this;
117 }
118
addNumberFilter(qint64 value,qint64 filter,QueryMaker::NumberComparison compare)119 QueryMaker* DynamicServiceQueryMaker::addNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare )
120 {
121 AMAROK_NOTIMPLEMENTED
122 Q_UNUSED( value )
123 Q_UNUSED( filter )
124 Q_UNUSED( compare )
125 return this;
126 }
127
excludeNumberFilter(qint64 value,qint64 filter,QueryMaker::NumberComparison compare)128 QueryMaker* DynamicServiceQueryMaker::excludeNumberFilter( qint64 value, qint64 filter, QueryMaker::NumberComparison compare )
129 {
130 AMAROK_NOTIMPLEMENTED
131 Q_UNUSED( value )
132 Q_UNUSED( filter )
133 Q_UNUSED( compare )
134 return this;
135 }
136
limitMaxResultSize(int size)137 QueryMaker * DynamicServiceQueryMaker::limitMaxResultSize(int size)
138 {
139 Q_UNUSED( size );
140 return this;
141 }
142
143 Meta::AlbumList
matchAlbums(ServiceCollection * coll,const Meta::ArtistPtr & artist)144 DynamicServiceQueryMaker::matchAlbums( ServiceCollection *coll, const Meta::ArtistPtr &artist )
145 {
146 if( !artist || !coll )
147 return Meta::AlbumList();
148 ArtistMap artistMap = coll->artistMap();
149 if ( artist && artistMap.contains( artist->name() ) )
150 {
151 Meta::ArtistPtr artist2 = artistMap.value( artist->name() );
152
153 Meta::AlbumList matchingAlbums;
154 Meta::AlbumList albums = coll->albumMap().values();
155
156 foreach( Meta::AlbumPtr albumPtr, albums ) {
157
158 if ( albumPtr->albumArtist() == artist2 )
159 matchingAlbums.push_back( albumPtr );
160 }
161
162 return matchingAlbums;
163 }
164 else
165 return Meta::AlbumList();
166 }
167
168
169
170