1 /**************************************************************************************** 2 * Copyright (c) 2007 Maximilian Kossick <maximilian.kossick@googlemail.com> * 3 * Copyright (c) 2007 Nikolaj Hald Nielsen <nhn@kde.org> * 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 #ifndef MEMORYQUERYMAKER_H 19 #define MEMORYQUERYMAKER_H 20 21 #include "amarok_export.h" 22 23 #include "MemoryCollection.h" 24 #include "core/collections/QueryMaker.h" 25 26 #include <QWeakPointer> 27 #include <ThreadWeaver/Job> 28 29 namespace ThreadWeaver 30 { 31 class Job; 32 } 33 34 namespace Collections { 35 36 class AMAROK_EXPORT MemoryQueryMaker : public QueryMaker 37 { 38 Q_OBJECT 39 public: 40 /** 41 * Creates a new MemoryQueryMaker that will query a memory collection. 42 * This class implements the QueryMaker interface and can be used as a generic 43 * query maker for all collections that use MemoryCollection. 44 * @param mc the MemoryCollection instance that the query should be run on. 45 * @param collectionId the collectionid that has to be emitted by this querymaker. 46 */ 47 MemoryQueryMaker( const QWeakPointer<MemoryCollection> &mc, const QString &collectionId ); 48 ~MemoryQueryMaker() override; 49 50 void run() override; 51 void abortQuery() override; 52 53 QueryMaker* setQueryType( QueryType type ) override; 54 55 QueryMaker* addReturnValue( qint64 value ) override; 56 QueryMaker* addReturnFunction( ReturnFunction function, qint64 value ) override; 57 QueryMaker* orderBy( qint64 value, bool descending = false ) override; 58 59 QueryMaker* addMatch( const Meta::TrackPtr &track ) override; 60 QueryMaker* addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour = TrackArtists ) override; 61 QueryMaker* addMatch( const Meta::AlbumPtr &album ) override; 62 QueryMaker* addMatch( const Meta::ComposerPtr &composer ) override; 63 QueryMaker* addMatch( const Meta::GenrePtr &genre ) override; 64 QueryMaker* addMatch( const Meta::YearPtr &year ) override; 65 QueryMaker* addMatch( const Meta::LabelPtr &label ) override; 66 67 QueryMaker* addFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) override; 68 QueryMaker* excludeFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) override; 69 70 QueryMaker* addNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) override; 71 QueryMaker* excludeNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) override; 72 73 QueryMaker* limitMaxResultSize( int size ) override; 74 75 QueryMaker* beginAnd() override; 76 QueryMaker* beginOr() override; 77 QueryMaker* endAndOr() override; 78 79 QueryMaker* setAlbumQueryMode( AlbumQueryMode mode ) override; 80 QueryMaker* setLabelQueryMode( LabelQueryMode mode ) override; 81 82 private Q_SLOTS: 83 void done( ThreadWeaver::JobPointer job ); 84 85 protected: 86 87 QWeakPointer<MemoryCollection> m_collection; 88 struct Private; 89 Private * const d; 90 }; 91 92 } //namespace Collections 93 94 #endif 95