File indexing completed on 2025-01-05 04:25:50
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 0005 * it under the terms of the GNU General Public License as published by 0006 * the Free Software Foundation; either version 2 of the License, or 0007 * (at your option) any later version. 0008 * 0009 * This program is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0012 * GNU General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU General Public License 0015 * along with this program; if not, write to the Free Software 0016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0017 */ 0018 0019 #ifndef AGGREGATECOLLECTION_H 0020 #define AGGREGATECOLLECTION_H 0021 0022 #include "core/collections/Collection.h" 0023 #include "core-impl/collections/support/CollectionManager.h" 0024 #include "core/meta/forward_declarations.h" 0025 #include "core/meta/support/MetaKeys.h" 0026 0027 #include <QString> 0028 #include <QHash> 0029 #include <QReadWriteLock> 0030 #include <KLocalizedString> 0031 0032 namespace Meta { 0033 class AggreagateYear; 0034 class AggregateTrack; 0035 class AggregateArtist; 0036 class AggregateAlbum; 0037 class AggregateGenre; 0038 class AggregateComposer; 0039 class AggregateLabel; 0040 } 0041 0042 namespace Collections { 0043 0044 class AMAROK_EXPORT AggregateCollection : public Collections::Collection 0045 { 0046 Q_OBJECT 0047 public: 0048 AggregateCollection(); 0049 ~AggregateCollection() override; 0050 0051 // Collections::Collection methods 0052 0053 QString prettyName() const override; 0054 QIcon icon() const override; 0055 0056 bool possiblyContainsTrack( const QUrl &url ) const override; 0057 Meta::TrackPtr trackForUrl( const QUrl &url ) override; 0058 0059 QueryMaker* queryMaker() override; 0060 0061 QString collectionId() const override; 0062 0063 // AggregateCollection methods 0064 0065 void removeTrack( const Meta::TrackKey &key ); 0066 Meta::AggregateTrack* getTrack( const Meta::TrackPtr &track ); 0067 void setTrack( Meta::AggregateTrack *track ); 0068 bool hasTrack( const Meta::TrackKey &key ); 0069 0070 void removeAlbum( const QString &album, const QString &albumArtist ); 0071 Meta::AggregateAlbum* getAlbum( const Meta::AlbumPtr &album ); 0072 void setAlbum( Meta::AggregateAlbum *album ); 0073 bool hasAlbum( const QString &album, const QString &albumArtist ); 0074 0075 void removeArtist( const QString &artist ); 0076 Meta::AggregateArtist* getArtist( Meta::ArtistPtr artist ); 0077 void setArtist( Meta::AggregateArtist *artist ); 0078 bool hasArtist( const QString &artist ); 0079 0080 void removeGenre( const QString &genre ); 0081 Meta::AggregateGenre* getGenre( Meta::GenrePtr genre ); 0082 void setGenre( Meta::AggregateGenre *genre ); 0083 bool hasGenre( const QString &genre ); 0084 0085 void removeComposer( const QString &name ); 0086 Meta::AggregateComposer* getComposer( Meta::ComposerPtr composer ); 0087 void setComposer( Meta::AggregateComposer *composer ); 0088 bool hasComposer( const QString &name ); 0089 0090 bool hasYear( const QString &name ); 0091 void removeYear( const QString &name ); 0092 Meta::AggreagateYear* getYear( Meta::YearPtr year ); 0093 void setYear( Meta::AggreagateYear *year ); 0094 0095 bool hasLabel( const QString &name ); 0096 void removeLabel( const QString &name ); 0097 Meta::AggregateLabel* getLabel( Meta::LabelPtr label ); 0098 void setLabel( Meta::AggregateLabel *label ); 0099 0100 public Q_SLOTS: 0101 void removeCollectionById( const QString &collectionId ); 0102 void removeCollection( Collections::Collection *collection ); 0103 void addCollection( Collections::Collection *collection, CollectionManager::CollectionStatus status ); 0104 void slotUpdated(); 0105 0106 private Q_SLOTS: 0107 void emptyCache(); 0108 0109 private: 0110 QHash<QString, Collections::Collection*> m_idCollectionMap; 0111 0112 QHash<QString, AmarokSharedPointer<Meta::AggreagateYear> > m_yearMap; 0113 QHash<QString, AmarokSharedPointer<Meta::AggregateGenre> > m_genreMap; 0114 QHash<QString, AmarokSharedPointer<Meta::AggregateComposer> > m_composerMap; 0115 QHash<QString, AmarokSharedPointer<Meta::AggregateArtist> > m_artistMap; 0116 QHash<Meta::AlbumKey, AmarokSharedPointer<Meta::AggregateAlbum> > m_albumMap; 0117 QHash<Meta::TrackKey, AmarokSharedPointer<Meta::AggregateTrack> > m_trackMap; 0118 QHash<QString, AmarokSharedPointer<Meta::AggregateLabel> > m_labelMap; 0119 0120 QReadWriteLock m_yearLock; 0121 QReadWriteLock m_genreLock; 0122 QReadWriteLock m_composerLock; 0123 QReadWriteLock m_artistLock; 0124 QReadWriteLock m_albumLock; 0125 QReadWriteLock m_trackLock; 0126 QReadWriteLock m_labelLock; 0127 }; 0128 0129 } //namespace Collections 0130 0131 #endif