File indexing completed on 2024-04-14 04:43:07
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 #include "MetaNotificationSpy.h" 0018 0019 #include "core/meta/Meta.h" 0020 #include "core/meta/Observer.h" 0021 0022 class MetaNotificationSpyPrivate : public Meta::Observer 0023 { 0024 public: 0025 MetaNotificationSpyPrivate() 0026 : Meta::Observer() {} 0027 0028 ~MetaNotificationSpyPrivate() override {} 0029 0030 virtual void metadataChanged( Meta::TrackPtr track ) { trackNotifications << track; } 0031 virtual void metadataChanged( Meta::ArtistPtr artist ) { artistNotifications << artist; } 0032 virtual void metadataChanged( Meta::AlbumPtr album ) { albumNotifications << album; } 0033 virtual void metadataChanged( Meta::GenrePtr genre ) { genreNotifications << genre; } 0034 virtual void metadataChanged( Meta::ComposerPtr composer ) { composerNotifications << composer; } 0035 virtual void metadataChanged( Meta::YearPtr year ) { yearNotifications << year; } 0036 0037 Meta::TrackList trackNotifications; 0038 Meta::AlbumList albumNotifications; 0039 Meta::ArtistList artistNotifications; 0040 Meta::GenreList genreNotifications; 0041 Meta::ComposerList composerNotifications; 0042 Meta::YearList yearNotifications; 0043 }; 0044 0045 MetaNotificationSpy::MetaNotificationSpy() 0046 : d( new MetaNotificationSpyPrivate() ) 0047 { 0048 //nothing to do 0049 } 0050 0051 MetaNotificationSpy::MetaNotificationSpy( const Meta::TrackPtr &track ) 0052 : d( new MetaNotificationSpyPrivate() ) 0053 { 0054 d->subscribeTo( track ); 0055 } 0056 0057 MetaNotificationSpy::MetaNotificationSpy( const Meta::AlbumPtr &album ) 0058 : d( new MetaNotificationSpyPrivate() ) 0059 { 0060 d->subscribeTo( album ); 0061 } 0062 0063 MetaNotificationSpy::MetaNotificationSpy( const Meta::ArtistPtr &artist ) 0064 : d( new MetaNotificationSpyPrivate() ) 0065 { 0066 d->subscribeTo( artist ); 0067 } 0068 0069 MetaNotificationSpy::MetaNotificationSpy( const Meta::ComposerPtr &composer ) 0070 : d( new MetaNotificationSpyPrivate() ) 0071 { 0072 d->subscribeTo( composer ); 0073 } 0074 0075 MetaNotificationSpy::MetaNotificationSpy( const Meta::GenrePtr &genre ) 0076 : d( new MetaNotificationSpyPrivate() ) 0077 { 0078 d->subscribeTo( genre ); 0079 } 0080 0081 MetaNotificationSpy::MetaNotificationSpy( const Meta::YearPtr &year ) 0082 : d( new MetaNotificationSpyPrivate() ) 0083 { 0084 d->subscribeTo( year ); 0085 } 0086 0087 MetaNotificationSpy::~MetaNotificationSpy() 0088 { 0089 delete d; 0090 } 0091 0092 void 0093 MetaNotificationSpy::subscribeTo(const Meta::AlbumPtr &album) 0094 { 0095 d->subscribeTo( album ); 0096 } 0097 0098 void 0099 MetaNotificationSpy::subscribeTo(const Meta::ArtistPtr &artist) 0100 { 0101 d->subscribeTo( artist ); 0102 } 0103 0104 void 0105 MetaNotificationSpy::subscribeTo(const Meta::ComposerPtr &composer) 0106 { 0107 d->subscribeTo( composer ); 0108 } 0109 0110 void 0111 MetaNotificationSpy::subscribeTo(const Meta::GenrePtr &genre) 0112 { 0113 d->subscribeTo( genre ); 0114 } 0115 0116 void 0117 MetaNotificationSpy::subscribeTo(const Meta::TrackPtr &track) 0118 { 0119 d->subscribeTo( track ); 0120 } 0121 0122 void 0123 MetaNotificationSpy::subscribeTo(const Meta::YearPtr &year) 0124 { 0125 d->subscribeTo( year ); 0126 } 0127 0128 Meta::TrackList 0129 MetaNotificationSpy::notificationsFromTracks() const 0130 { 0131 return d->trackNotifications; 0132 } 0133 0134 Meta::AlbumList 0135 MetaNotificationSpy::notificationsFromAlbums() const 0136 { 0137 return d->albumNotifications; 0138 } 0139 0140 Meta::ArtistList 0141 MetaNotificationSpy::notificationsFromArtists() const 0142 { 0143 return d->artistNotifications; 0144 } 0145 0146 Meta::ComposerList 0147 MetaNotificationSpy::notificationsFromComposers() const 0148 { 0149 return d->composerNotifications; 0150 } 0151 0152 Meta::GenreList 0153 MetaNotificationSpy::notificationsFromGenres() const 0154 { 0155 return d->genreNotifications; 0156 } 0157 0158 Meta::YearList 0159 MetaNotificationSpy::notificationsFromYears() const 0160 { 0161 return d->yearNotifications; 0162 }