File indexing completed on 2024-04-21 04:47:50

0001 /****************************************************************************************
0002  * Copyright (c) 2008 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 GLOBALCOLLECTIONACTIONS_H
0018 #define GLOBALCOLLECTIONACTIONS_H
0019 
0020 #include "amarok_export.h"
0021 #include "core/meta/forward_declarations.h"
0022 
0023 #include <QAction>
0024 
0025 
0026 class AMAROK_EXPORT GlobalCollectionAction : public QAction
0027 {
0028     public:
0029         GlobalCollectionAction( const QString &text, QObject * parent );
0030 };
0031 
0032 
0033 class AMAROK_EXPORT GlobalCollectionGenreAction : public GlobalCollectionAction
0034 {
0035     public:
0036 
0037         GlobalCollectionGenreAction( const QString &text, QObject * parent );
0038         void setGenre( const Meta::GenrePtr &genre );
0039 
0040     protected:
0041         Meta::GenrePtr genre();
0042 
0043     private:
0044         Meta::GenrePtr m_currentGenre;
0045 };
0046 
0047 
0048 class AMAROK_EXPORT GlobalCollectionArtistAction : public GlobalCollectionAction
0049 {
0050     public:
0051 
0052         GlobalCollectionArtistAction( const QString &text, QObject * parent );
0053         void setArtist( const Meta::ArtistPtr &artist );
0054         
0055     protected:
0056         Meta::ArtistPtr artist();
0057 
0058     private:
0059         Meta::ArtistPtr m_currentArtist;
0060 };
0061 
0062 
0063 class AMAROK_EXPORT GlobalCollectionAlbumAction : public GlobalCollectionAction
0064 {
0065     public:
0066 
0067         GlobalCollectionAlbumAction( const QString &text, QObject * parent );
0068         void setAlbum( const Meta::AlbumPtr &album );
0069 
0070     protected:
0071         Meta::AlbumPtr album();
0072 
0073     private:
0074         Meta::AlbumPtr m_currentAlbum;
0075 };
0076 
0077 
0078 class AMAROK_EXPORT GlobalCollectionTrackAction : public GlobalCollectionAction
0079 {
0080     public:
0081 
0082         GlobalCollectionTrackAction( const QString &text, QObject * parent );
0083         void setTrack( const Meta::TrackPtr &track );
0084         
0085     protected:
0086         Meta::TrackPtr track();
0087         
0088     private:
0089         Meta::TrackPtr m_currentTrack;
0090 
0091 };
0092 
0093 class AMAROK_EXPORT GlobalCollectionYearAction : public GlobalCollectionAction
0094 {
0095     public:
0096 
0097         GlobalCollectionYearAction( const QString &text, QObject * parent );
0098         void setYear( const Meta::YearPtr &year );
0099 
0100     protected:
0101         Meta::YearPtr year();
0102 
0103     private:
0104         Meta::YearPtr m_currentYear;
0105 
0106 };
0107 
0108 class GlobalCollectionComposerAction : public GlobalCollectionAction
0109 {
0110     public:
0111 
0112         GlobalCollectionComposerAction( const QString &text, QObject * parent );
0113         void setComposer( const Meta::ComposerPtr &composer );
0114 
0115     protected:
0116         Meta::ComposerPtr composer();
0117 
0118     private:
0119         Meta::ComposerPtr m_currentComposer;
0120 };
0121 
0122 
0123 class GlobalCollectionActions;
0124 
0125 namespace The {
0126     AMAROK_EXPORT GlobalCollectionActions* globalCollectionActions();
0127 }
0128 
0129 /**
0130   This class keeps track of global context actions that should be added to all genre, artists or another meta type in all collections.
0131 */
0132 class AMAROK_EXPORT GlobalCollectionActions : public QObject
0133 {
0134     Q_OBJECT
0135 
0136     friend GlobalCollectionActions* The::globalCollectionActions();
0137 
0138 public:
0139     QList<QAction *> actionsFor( const Meta::DataPtr &item );
0140 
0141     void addGenreAction( GlobalCollectionGenreAction * action );
0142     void addArtistAction( GlobalCollectionArtistAction * action );
0143     void addAlbumAction( GlobalCollectionAlbumAction * action );
0144     void addTrackAction( GlobalCollectionTrackAction * action );
0145     void addYearAction( GlobalCollectionYearAction * action );
0146     void addComposerAction( GlobalCollectionComposerAction * action );
0147     
0148 private:
0149     GlobalCollectionActions();
0150     ~GlobalCollectionActions() override;
0151 
0152     QList<QAction *> actionsFor( const Meta::GenrePtr &genre );
0153     QList<QAction *> actionsFor( const Meta::ArtistPtr &artist );
0154     QList<QAction *> actionsFor( const Meta::AlbumPtr &album );
0155     QList<QAction *> actionsFor( const Meta::TrackPtr &track );
0156     QList<QAction *> actionsFor( const Meta::YearPtr &year );
0157     QList<QAction *> actionsFor( const Meta::ComposerPtr &composer );
0158 
0159     QList<GlobalCollectionGenreAction*> m_genreActions;
0160     QList<GlobalCollectionArtistAction*> m_artistActions;
0161     QList<GlobalCollectionAlbumAction*> m_albumActions;
0162     QList<GlobalCollectionTrackAction*> m_trackActions;
0163     QList<GlobalCollectionYearAction*> m_yearActions;
0164     QList<GlobalCollectionComposerAction*> m_composerActions;
0165 };
0166 
0167 #endif