File indexing completed on 2024-05-19 04:50:25
0001 /**************************************************************************************** 0002 * Copyright (c) 2007 Nikolaj Hald Nielsen <nhn@kde.org> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #ifndef SCRIPTABLESERVICEQUERYMAKER_H 0018 #define SCRIPTABLESERVICEQUERYMAKER_H 0019 0020 #include "../DynamicServiceQueryMaker.h" 0021 0022 #include "core/meta/forward_declarations.h" 0023 0024 #include "ScriptableServiceCollection.h" 0025 0026 namespace Collections { 0027 0028 /** 0029 * A query maker for fetching external data from scripted services. 0030 */ 0031 class ScriptableServiceQueryMaker : public DynamicServiceQueryMaker 0032 { 0033 Q_OBJECT 0034 0035 public: 0036 ScriptableServiceQueryMaker( ScriptableServiceCollection * collection, const QString &name ); 0037 ~ScriptableServiceQueryMaker() override; 0038 0039 void run() override; 0040 void abortQuery() override; 0041 0042 QueryMaker* setQueryType( QueryType type ) override; 0043 0044 QueryMaker* addFilter( qint64 value, const QString &filter, bool matchBegin = false, bool matchEnd = false ) override; 0045 0046 using QueryMaker::addMatch; 0047 QueryMaker* addMatch( const Meta::GenrePtr &genre ) override; 0048 QueryMaker* addMatch( const Meta::ArtistPtr &artist, ArtistMatchBehaviour behaviour = TrackArtists ) override; 0049 QueryMaker* addMatch( const Meta::AlbumPtr &album ) override; 0050 0051 QueryMaker* setAlbumQueryMode( AlbumQueryMode mode ) override; 0052 0053 // ScriptableServiceQueryMaker-specific methods 0054 0055 /** 0056 * Set to true if ScriptableServiceQueryMaker should convert tracks which are in 0057 * fact playlists to Meta::MultiTrack instances to be playable. Defaults to false. 0058 */ 0059 void setConvertToMultiTracks( bool convert ); 0060 0061 protected Q_SLOTS: 0062 void slotScriptComplete( ); 0063 0064 private Q_SLOTS: 0065 void fetchGenre(); 0066 void fetchArtists(); 0067 void fetchAlbums(); 0068 void fetchTracks(); 0069 0070 protected: 0071 void handleResult( const Meta::GenreList &genres ); 0072 void handleResult( const Meta::ArtistList &artists ); 0073 void handleResult( const Meta::AlbumList &albums ); 0074 void handleResult( const Meta::TrackList &tracks ); 0075 0076 ScriptableServiceCollection * m_collection; 0077 AmarokProcIO * m_script; 0078 0079 struct Private; 0080 Private * const d; 0081 0082 QString m_sessionId; 0083 int m_parentAlbumId; 0084 int m_parentArtistId; 0085 0086 private: 0087 QString m_name; 0088 bool m_convertToMultiTracks; 0089 }; 0090 0091 } //namespace Collections 0092 0093 #endif