File indexing completed on 2024-05-19 04:49:18

0001 /****************************************************************************************
0002  * Copyright (c) 2007 Maximilian Kossick <maximilian.kossick@googlemail.com>            *
0003  * Copyright (c) 2007 Nikolaj Hald Nielsen <nhn@kde.org>                                *
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 #ifndef MEMORYQUERYMAKER_H
0019 #define MEMORYQUERYMAKER_H
0020 
0021 #include "amarok_export.h"
0022 
0023 #include "MemoryCollection.h"
0024 #include "core/collections/QueryMaker.h"
0025 
0026 #include <QWeakPointer>
0027 #include <ThreadWeaver/Job>
0028 
0029 namespace ThreadWeaver
0030 {
0031     class Job;
0032 }
0033 
0034 namespace Collections {
0035 
0036 class AMAROK_EXPORT MemoryQueryMaker : public QueryMaker
0037 {
0038     Q_OBJECT
0039     public:
0040     /**
0041       * Creates a new MemoryQueryMaker that will query a memory collection.
0042       * This class implements the QueryMaker interface and can be used as a generic
0043       * query maker for all collections that use MemoryCollection.
0044       * @param mc the MemoryCollection instance that the query should be run on.
0045       * @param collectionId the collectionid that has to be emitted by this querymaker.
0046       */
0047         MemoryQueryMaker( const QWeakPointer<MemoryCollection> &mc, const QString &collectionId );
0048         ~MemoryQueryMaker() override;
0049 
0050         void run() override;
0051         void abortQuery() override;
0052 
0053         QueryMaker* setQueryType( QueryType type ) override;
0054 
0055         QueryMaker* addReturnValue( qint64 value ) override;
0056         QueryMaker* addReturnFunction( ReturnFunction function, qint64 value ) override;
0057         QueryMaker* orderBy( qint64 value, bool descending = false ) override;
0058 
0059         QueryMaker* addMatch( const Meta::TrackPtr &track ) override;
0060         QueryMaker* addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour = TrackArtists ) override;
0061         QueryMaker* addMatch( const Meta::AlbumPtr &album ) override;
0062         QueryMaker* addMatch( const Meta::ComposerPtr &composer ) override;
0063         QueryMaker* addMatch( const Meta::GenrePtr &genre ) override;
0064         QueryMaker* addMatch( const Meta::YearPtr &year ) override;
0065         QueryMaker* addMatch( const Meta::LabelPtr &label ) override;
0066 
0067         QueryMaker* addFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) override;
0068         QueryMaker* excludeFilter( qint64 value, const QString &filter, bool matchBegin, bool matchEnd ) override;
0069 
0070         QueryMaker* addNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) override;
0071         QueryMaker* excludeNumberFilter( qint64 value, qint64 filter, NumberComparison compare ) override;
0072 
0073         QueryMaker* limitMaxResultSize( int size ) override;
0074 
0075         QueryMaker* beginAnd() override;
0076         QueryMaker* beginOr() override;
0077         QueryMaker* endAndOr() override;
0078 
0079         QueryMaker* setAlbumQueryMode( AlbumQueryMode mode ) override;
0080         QueryMaker* setLabelQueryMode( LabelQueryMode mode ) override;
0081 
0082     private Q_SLOTS:
0083         void done( ThreadWeaver::JobPointer job );
0084 
0085     protected:
0086 
0087         QWeakPointer<MemoryCollection> m_collection;
0088         struct Private;
0089         Private * const d;
0090 };
0091 
0092 } //namespace Collections
0093 
0094 #endif