File indexing completed on 2024-05-19 04:50:25
0001 /**************************************************************************************** 0002 * Copyright (c) 2007-2009 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 DYNAMICSCRIPTABLESERVICEMETA_H 0018 #define DYNAMICSCRIPTABLESERVICEMETA_H 0019 0020 #include "../ServiceMetaBase.h" 0021 #include "../ServiceAlbumCoverDownloader.h" 0022 0023 /** 0024 Meta types for use in the dynamic scriptable service. Nearly identical to 0025 the ServiceMetaBse types, except for a field for storing data to 0026 pass to the script to fetch child items for Genres, Artists and Albums 0027 and a level specifier 0028 0029 @author Nikolaj Hald Nielsen <nhn@kde.org> 0030 */ 0031 0032 0033 namespace Meta 0034 { 0035 0036 class ScriptableServiceMetaItem 0037 { 0038 public: 0039 explicit ScriptableServiceMetaItem( int level ); 0040 0041 void setCallbackString( const QString &callbackString ); 0042 QString callbackString() const; 0043 int level() const; 0044 0045 void setServiceName( const QString &name ); 0046 void setServiceDescription( const QString &description ); 0047 void setServiceEmblem( const QPixmap &emblem ); 0048 void setServiceScalableEmblem( const QString &emblemPath ); 0049 0050 protected: 0051 /* 0052 * This is arbitrary string data to pass back to the script. This can be whatever 0053 * information the script needs to fetch the children of this item... 0054 */ 0055 QString m_callbackString; 0056 int m_level; 0057 QString m_serviceName; 0058 QString m_serviceDescription; 0059 QPixmap m_serviceEmblem; 0060 QString m_serviceScalableEmblem; 0061 0062 }; 0063 0064 class ScriptableServiceTrack : public Meta::ServiceTrack, public ScriptableServiceMetaItem 0065 { 0066 public: 0067 explicit ScriptableServiceTrack( const QString &name ); 0068 explicit ScriptableServiceTrack( const QStringList &resultRow ); 0069 0070 QString sourceName() override; 0071 QString sourceDescription() override; 0072 QPixmap emblem() override; 0073 QString scalableEmblem() override; 0074 0075 void setAlbumName( const QString &newAlbum ); 0076 void setArtistName( const QString &newArtist ); 0077 void setGenreName( const QString &newGenre ); 0078 void setComposerName( const QString &newComposer ); 0079 void setYearNumber( int newYear ); 0080 0081 void setCustomAlbumCoverUrl( const QString &coverurl ); 0082 0083 QString collectionName() const override { return m_serviceName; } 0084 void setUidUrl( const QString &url ) override; 0085 0086 /** 0087 * If this track is in fact a remote playlist, return Meta::MultiTrack that wraps 0088 * it here, else return pointer to self. 0089 */ 0090 Meta::TrackPtr playableTrack() const; 0091 0092 private: 0093 Meta::TrackPtr m_playableTrack; 0094 }; 0095 0096 class ScriptableServiceAlbum : public Meta::ServiceAlbumWithCover, public ScriptableServiceMetaItem 0097 { 0098 public: 0099 explicit ScriptableServiceAlbum( const QString &name ); 0100 explicit ScriptableServiceAlbum( const QStringList &resultRow ); 0101 0102 QString downloadPrefix() const override { return QStringLiteral("script"); } 0103 void setCoverUrl( const QString &coverUrl ) override { m_coverUrl = coverUrl; } 0104 QString coverUrl() const override { return m_coverUrl; } 0105 0106 QUrl imageLocation( int size = 1 ) override { Q_UNUSED( size ); return QUrl( coverUrl() ); } 0107 0108 QString sourceName() override; 0109 QString sourceDescription() override; 0110 QPixmap emblem() override; 0111 QString scalableEmblem() override; 0112 0113 bool isBookmarkable() const override; 0114 QString collectionName() const override { return m_serviceName; } 0115 bool simpleFiltering() const override { return true; } 0116 0117 private: 0118 QString m_coverUrl; 0119 0120 }; 0121 0122 class ScriptableServiceArtist : public Meta::ServiceArtist, public ScriptableServiceMetaItem 0123 { 0124 public: 0125 explicit ScriptableServiceArtist( const QString &name ); 0126 explicit ScriptableServiceArtist( const QStringList &resultRow ); 0127 0128 void setGenreId( int artistId ); 0129 int genreId() const; 0130 0131 QString sourceName() override; 0132 QString sourceDescription() override; 0133 QPixmap emblem() override; 0134 QString scalableEmblem() override; 0135 0136 bool isBookmarkable() const override; 0137 QString collectionName() const override { return m_serviceName; } 0138 bool simpleFiltering() const override { return true; } 0139 0140 private: 0141 int m_genreId; 0142 }; 0143 0144 0145 class ScriptableServiceGenre : public Meta::ServiceGenre, public ScriptableServiceMetaItem 0146 { 0147 public: 0148 explicit ScriptableServiceGenre( const QString &name ); 0149 explicit ScriptableServiceGenre( const QStringList &resultRow ); 0150 0151 void setDescription( const QString &description ); 0152 QString description(); 0153 0154 QString sourceName() override; 0155 QString sourceDescription() override; 0156 QPixmap emblem() override; 0157 QString scalableEmblem() override; 0158 0159 private: 0160 QString m_description; 0161 }; 0162 0163 } 0164 0165 #endif