File indexing completed on 2025-01-05 04:25:51
0001 /**************************************************************************************** 0002 * Copyright (c) 2009 Maximilian Kossick <maximilian.kossick@googlemail.com> * 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 AGGREGATEMETA_H 0018 #define AGGREGATEMETA_H 0019 0020 #include "amarok_export.h" 0021 #include "core/meta/Meta.h" 0022 #include "core/meta/Observer.h" 0023 #include "core/meta/Statistics.h" 0024 0025 #include <QList> 0026 0027 namespace Collections { 0028 class AggregateCollection; 0029 } 0030 0031 namespace Meta { 0032 0033 class AMAROK_EXPORT AggregateTrack : public Meta::Track, public Meta::Statistics, private Meta::Observer 0034 { 0035 public: 0036 AggregateTrack( Collections::AggregateCollection *coll, const Meta::TrackPtr &track ); 0037 ~AggregateTrack() override; 0038 0039 QString name() const override; 0040 QString prettyName() const override; 0041 QString sortableName() const override; 0042 0043 QUrl playableUrl() const override; 0044 QString prettyUrl() const override; 0045 QString uidUrl() const override; 0046 0047 /** 0048 * Return a comma separated list of reasons why constituent 0049 * tracks are unplayable or an empty string if any of the tracks is playable 0050 */ 0051 QString notPlayableReason() const override; 0052 0053 Meta::AlbumPtr album() const override; 0054 Meta::ArtistPtr artist() const override; 0055 Meta::ComposerPtr composer() const override; 0056 Meta::GenrePtr genre() const override; 0057 Meta::YearPtr year() const override; 0058 0059 QString comment() const override; 0060 qreal bpm() const override; 0061 0062 void finishedPlaying( double playedFraction ) override; 0063 0064 qint64 length() const override; 0065 int filesize() const override; 0066 int sampleRate() const override; 0067 int bitrate() const override; 0068 QDateTime createDate() const override; 0069 int trackNumber() const override; 0070 int discNumber() const override; 0071 QString type() const override; 0072 0073 Collections::Collection* collection() const override; 0074 0075 bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; 0076 Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; 0077 0078 void addLabel( const QString &label ) override; 0079 void addLabel( const Meta::LabelPtr &label ) override; 0080 void removeLabel( const Meta::LabelPtr &label ) override; 0081 Meta::LabelList labels() const override; 0082 0083 TrackEditorPtr editor() override; 0084 StatisticsPtr statistics() override; 0085 0086 // Meta::Statistics methods: 0087 double score() const override; 0088 void setScore( double newScore ) override; 0089 int rating() const override; 0090 void setRating( int newRating ) override; 0091 QDateTime firstPlayed() const override; 0092 void setFirstPlayed( const QDateTime &date ) override; 0093 QDateTime lastPlayed() const override; 0094 void setLastPlayed( const QDateTime &date ) override; 0095 int playCount() const override; 0096 void setPlayCount( int newPlayCount ) override; 0097 0098 void add( const Meta::TrackPtr &track ); 0099 0100 protected: 0101 using Observer::metadataChanged; 0102 void metadataChanged( const Meta::TrackPtr &track ) override; 0103 0104 private: 0105 Collections::AggregateCollection *m_collection; 0106 Meta::TrackList m_tracks; 0107 QString m_name; 0108 Meta::AlbumPtr m_album; 0109 Meta::ArtistPtr m_artist; 0110 Meta::GenrePtr m_genre; 0111 Meta::ComposerPtr m_composer; 0112 Meta::YearPtr m_year; 0113 }; 0114 0115 class AMAROK_EXPORT AggregateAlbum : public Meta::Album, private Meta::Observer 0116 { 0117 public: 0118 AggregateAlbum( Collections::AggregateCollection *coll, Meta::AlbumPtr album ); 0119 ~AggregateAlbum() override; 0120 0121 QString name() const override; 0122 QString prettyName() const override; 0123 QString sortableName() const override; 0124 0125 Meta::TrackList tracks() override; 0126 Meta::ArtistPtr albumArtist() const override; 0127 bool isCompilation() const override; 0128 bool hasAlbumArtist() const override; 0129 0130 bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; 0131 Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; 0132 0133 void add( const Meta::AlbumPtr &album ); 0134 0135 /** returns true if the album has a cover set */ 0136 bool hasImage( int size = 0 ) const override; 0137 /** returns the cover of the album */ 0138 QImage image( int size = 0 ) const override; 0139 /** returns the image location on disk */ 0140 QUrl imageLocation( int size = 0 ) override; 0141 /** returns the cover of the album with a nice border around it*/ 0142 virtual QPixmap imageWithBorder( int size = 0, int borderWidth = 5 ); 0143 /** Returns true if it is possible to update the cover of the album */ 0144 bool canUpdateImage() const override; 0145 /** updates the cover of the album */ 0146 void setImage( const QImage &image ) override; 0147 void removeImage() override; 0148 /** don't automatically fetch artwork */ 0149 void setSuppressImageAutoFetch( const bool suppress ) override; 0150 /** should automatic artwork retrieval be suppressed? */ 0151 bool suppressImageAutoFetch() const override; 0152 0153 protected: 0154 using Observer::metadataChanged; 0155 void metadataChanged(const Meta::AlbumPtr &album ) override; 0156 0157 private: 0158 Collections::AggregateCollection *m_collection; 0159 Meta::AlbumList m_albums; 0160 QString m_name; 0161 Meta::ArtistPtr m_albumArtist; 0162 }; 0163 0164 class AMAROK_EXPORT AggregateArtist : public Meta::Artist, private Meta::Observer 0165 { 0166 public: 0167 AggregateArtist( Collections::AggregateCollection *coll, const Meta::ArtistPtr &artist ); 0168 ~AggregateArtist() override; 0169 0170 QString name() const override; 0171 QString prettyName() const override; 0172 QString sortableName() const override; 0173 0174 Meta::TrackList tracks() override; 0175 0176 bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; 0177 Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; 0178 0179 void add( const Meta::ArtistPtr &artist ); 0180 0181 protected: 0182 using Observer::metadataChanged; 0183 void metadataChanged( const Meta::ArtistPtr &artist ) override; 0184 0185 private: 0186 Collections::AggregateCollection *m_collection; 0187 Meta::ArtistList m_artists; 0188 QString m_name; 0189 }; 0190 0191 class AMAROK_EXPORT AggregateGenre : public Meta::Genre, private Meta::Observer 0192 { 0193 public: 0194 AggregateGenre( Collections::AggregateCollection *coll, const Meta::GenrePtr &genre ); 0195 ~AggregateGenre() override; 0196 0197 QString name() const override; 0198 QString prettyName() const override; 0199 QString sortableName() const override; 0200 0201 Meta::TrackList tracks() override; 0202 0203 bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; 0204 Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; 0205 0206 void add( const Meta::GenrePtr &genre ); 0207 0208 protected: 0209 using Observer::metadataChanged; 0210 void metadataChanged( const Meta::GenrePtr &genre ) override; 0211 0212 private: 0213 Collections::AggregateCollection *m_collection; 0214 Meta::GenreList m_genres; 0215 QString m_name; 0216 }; 0217 0218 class AMAROK_EXPORT AggregateComposer : public Meta::Composer, private Meta::Observer 0219 { 0220 public: 0221 AggregateComposer(Collections::AggregateCollection *coll, const ComposerPtr &composer ); 0222 ~AggregateComposer() override; 0223 0224 QString name() const override; 0225 QString prettyName() const override; 0226 QString sortableName() const override; 0227 0228 Meta::TrackList tracks() override; 0229 0230 bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; 0231 Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; 0232 0233 void add( const Meta::ComposerPtr &composer ); 0234 0235 protected: 0236 using Observer::metadataChanged; 0237 void metadataChanged( const Meta::ComposerPtr &composer ) override; 0238 0239 private: 0240 Collections::AggregateCollection *m_collection; 0241 Meta::ComposerList m_composers; 0242 QString m_name; 0243 }; 0244 0245 class AMAROK_EXPORT AggreagateYear : public Meta::Year, private Meta::Observer 0246 { 0247 public: 0248 AggreagateYear( Collections::AggregateCollection * coll, const Meta::YearPtr &year ); 0249 ~AggreagateYear() override; 0250 0251 QString name() const override; 0252 QString prettyName() const override; 0253 QString sortableName() const override; 0254 0255 Meta::TrackList tracks() override; 0256 0257 bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; 0258 Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; 0259 0260 /** 0261 * adds another Meta::Year instance to be proxied. 0262 */ 0263 void add( const Meta::YearPtr &year ); 0264 0265 protected: 0266 using Observer::metadataChanged; 0267 void metadataChanged( const Meta::YearPtr &year ) override; 0268 0269 private: 0270 Collections::AggregateCollection *m_collection; 0271 Meta::YearList m_years; 0272 QString m_name; 0273 0274 }; 0275 0276 class AMAROK_EXPORT AggregateLabel : public Meta::Label 0277 { 0278 public: 0279 AggregateLabel( Collections::AggregateCollection *coll, const Meta::LabelPtr &label ); 0280 ~AggregateLabel() override; 0281 0282 QString name() const override; 0283 QString prettyName() const override; 0284 QString sortableName() const override; 0285 0286 bool hasCapabilityInterface( Capabilities::Capability::Type type ) const override; 0287 Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type ) override; 0288 0289 /** 0290 adds another Meta::Label instance to be proxied. 0291 */ 0292 void add( const Meta::LabelPtr &label ); 0293 0294 private: 0295 Collections::AggregateCollection *m_collection; 0296 Meta::LabelList m_labels; 0297 QString m_name; 0298 }; 0299 } // namespace Meta 0300 0301 #endif // AGGREGATEMETA_H