1
/***************************************************************************
2
 *   Copyright (c) 2008  Nikolaj Hald Nielsen <nhnFreespirit@gmail.com>    *
3
 *                                                                         *
4
 *   This program is free software; you can redistribute it and/or modify  *
5
 *   it under the terms of the GNU General Public License as published by  *
6
 *   the Free Software Foundation; either version 2 of the License, or     *
7
 *   (at your option) any later version.                                   *
8
 *                                                                         *
9
 *   This program is distributed in the hope that it will be useful,       *
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12
 *   GNU General Public License for more details.                          *
13
 *                                                                         *
14
 *   You should have received a copy of the GNU General Public License     *
15
 *   along with this program; if not, write to the                         *
16
 *   Free Software Foundation, Inc.,                                       *
17
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
18
 ***************************************************************************/
19
 
20
#include "GlobalCollectionActions.h"
21
#include "Meta.h"
22
23
24
namespace The {
25
    static GlobalCollectionActions* s_GlobalCollectionActions_instance = 0;
26
27
    GlobalCollectionActions* globalCollectionActions()
28
    {
29
        if( !s_GlobalCollectionActions_instance )
30
            s_GlobalCollectionActions_instance = new GlobalCollectionActions();
31
32
        return s_GlobalCollectionActions_instance;
33
    }
34
}
35
36
GlobalCollectionActions::GlobalCollectionActions()
37
{
38
}
39
40
41
GlobalCollectionActions::~GlobalCollectionActions()
42
{
43
}
44
45
void
46
GlobalCollectionActions::addGenreAction( GlobalCollectionGenreAction * action )
47
{
48
    m_genreActions.append( action );
49
}
50
51
void
52
GlobalCollectionActions::addArtistAction( GlobalCollectionArtistAction * action )
53
{
54
    m_artistActions.append( action );
55
}
56
57
void
58
GlobalCollectionActions::addAlbumAction( GlobalCollectionAlbumAction * action )
59
{
60
    m_albumActions.append( action );
61
}
62
63
void
64
GlobalCollectionActions::addTrackAction( GlobalCollectionTrackAction * action )
65
{
66
    m_trackActions.append( action );
67
}
68
69
void
70
GlobalCollectionActions::addYearAction( GlobalCollectionYearAction * action )
71
{
72
    m_yearActions.append( action );
73
}
74
75
void
76
GlobalCollectionActions::addComposerAction( GlobalCollectionComposerAction * action )
77
{
78
    m_composerActions.append( action );
79
}
80
81
QList< PopupDropperAction * > GlobalCollectionActions::actionsFor( Meta::DataPtr item )
82
{
83
84
    Meta::GenrePtr genrePtr = Meta::GenrePtr::dynamicCast( item );
85
    if ( genrePtr )
86
        return actionsFor( genrePtr );
87
88
    Meta::ArtistPtr artistPtr = Meta::ArtistPtr::dynamicCast( item );
89
    if ( artistPtr )
90
        return actionsFor( artistPtr );
91
92
    Meta::AlbumPtr albumPtr = Meta::AlbumPtr::dynamicCast( item );
93
    if ( albumPtr )
94
        return actionsFor( albumPtr );
95
96
    Meta::TrackPtr trackPtr = Meta::TrackPtr::dynamicCast( item );
97
    if ( trackPtr )
98
        return actionsFor( trackPtr );
99
100
    Meta::YearPtr yearPtr = Meta::YearPtr::dynamicCast( item );
101
    if ( yearPtr )
102
        return actionsFor( yearPtr );
103
104
    Meta::ComposerPtr composerPtr = Meta::ComposerPtr::dynamicCast( item );
105
    if ( composerPtr )
106
        return actionsFor( composerPtr );
107
108
    QList< PopupDropperAction * > emptyList;
109
    return emptyList;
110
}
111
112
113
QList< PopupDropperAction * >
114
GlobalCollectionActions::actionsFor( Meta::GenrePtr genre )
115
{
116
    QList< PopupDropperAction * > returnList;
117
    foreach( GlobalCollectionGenreAction * genreAction, m_genreActions )
118
    {
119
        genreAction->setGenre( genre );
120
        returnList.append( genreAction );
121
    }
122
123
    return returnList;
124
}
125
126
QList< PopupDropperAction * >
127
GlobalCollectionActions::actionsFor( Meta::ArtistPtr artist )
128
{
129
    QList< PopupDropperAction * > returnList;
130
    foreach( GlobalCollectionArtistAction * artistAction, m_artistActions )
131
    {
132
        artistAction->setArtist( artist );
133
        returnList.append( artistAction );
134
    }
135
136
    return returnList;
137
}
138
139
QList< PopupDropperAction * >
140
GlobalCollectionActions::actionsFor( Meta::AlbumPtr album )
141
{
142
    QList< PopupDropperAction * > returnList;
143
    foreach( GlobalCollectionAlbumAction * albumAction, m_albumActions )
144
    {
145
        albumAction->setAlbum( album );
146
        returnList.append( albumAction );
147
    }
148
149
    return returnList;
150
}
151
152
QList< PopupDropperAction * >
153
GlobalCollectionActions::actionsFor( Meta::TrackPtr track )
154
{
155
    QList< PopupDropperAction * > returnList;
156
    foreach( GlobalCollectionTrackAction * trackAction, m_trackActions )
157
    {
158
        trackAction->setTrack( track );
159
        returnList.append( trackAction );
160
    }
161
162
    return returnList;
163
}
164
165
QList< PopupDropperAction * >
166
GlobalCollectionActions::actionsFor( Meta::YearPtr year )
167
{
168
    QList< PopupDropperAction * > returnList;
169
    foreach( GlobalCollectionYearAction * yearAction, m_yearActions )
170
    {
171
        yearAction->setYear( year );
172
        returnList.append( yearAction );
173
    }
174
175
    return returnList;
176
}
177
178
QList< PopupDropperAction * >
179
GlobalCollectionActions::actionsFor( Meta::ComposerPtr composer )
180
{
181
    QList< PopupDropperAction * > returnList;
182
    foreach( GlobalCollectionComposerAction * composerAction, m_composerActions )
183
    {
184
        composerAction->setComposer( composer );
185
        returnList.append( composerAction );
186
    }
187
188
    return returnList;
189
}
190
191
GlobalCollectionAction::GlobalCollectionAction( const QString &text, QObject * parent )
192
    : PopupDropperAction( text, parent )
193
{
194
}
195
196
GlobalCollectionGenreAction::GlobalCollectionGenreAction( const QString &text, QObject * parent )
197
    : GlobalCollectionAction( text, parent )
198
{
199
}
200
201
void GlobalCollectionGenreAction::setGenre( Meta::GenrePtr genre )
202
{
203
    m_currentGenre = genre;
204
}
205
206
Meta::GenrePtr GlobalCollectionGenreAction::genre()
207
{
208
    return m_currentGenre;
209
}
210
211
GlobalCollectionArtistAction::GlobalCollectionArtistAction( const QString &text, QObject * parent )
212
    : GlobalCollectionAction( text, parent )
213
{
214
}
215
216
void GlobalCollectionArtistAction::setArtist( Meta::ArtistPtr artist )
217
{
218
    m_currentArtist = artist;
219
}
220
221
Meta::ArtistPtr GlobalCollectionArtistAction::artist()
222
{
223
    return m_currentArtist;
224
}
225
226
GlobalCollectionAlbumAction::GlobalCollectionAlbumAction( const QString &text, QObject * parent )
227
    : GlobalCollectionAction( text, parent )
228
{
229
}
230
231
void GlobalCollectionAlbumAction::setAlbum( Meta::AlbumPtr album )
232
{
233
    m_currentAlbum = album;
234
}
235
236
Meta::AlbumPtr GlobalCollectionAlbumAction::album()
237
{
238
    return m_currentAlbum;
239
}
240
241
GlobalCollectionTrackAction::GlobalCollectionTrackAction( const QString &text, QObject * parent )
242
    : GlobalCollectionAction( text, parent )
243
{
244
}
245
246
void GlobalCollectionTrackAction::setTrack( Meta::TrackPtr track )
247
{
248
    m_currentTrack = track;
249
}
250
251
Meta::TrackPtr GlobalCollectionTrackAction::track()
252
{
253
    return m_currentTrack;
254
}
255
256
GlobalCollectionYearAction::GlobalCollectionYearAction( const QString &text, QObject * parent )
257
    : GlobalCollectionAction( text, parent )
258
{
259
}
260
261
void GlobalCollectionYearAction::setYear( Meta::YearPtr year )
262
{
263
    m_currentYear = year;
264
}
265
266
Meta::YearPtr GlobalCollectionYearAction::year()
267
{
268
    return m_currentYear;
269
}
270
271
GlobalCollectionComposerAction::GlobalCollectionComposerAction( const QString &text, QObject * parent )
272
    : GlobalCollectionAction( text, parent )
273
{
274
}
275
276
void GlobalCollectionComposerAction::setComposer(Meta::ComposerPtr composer)
277
{
278
    m_currentComposer = composer;
279
}
280
281
Meta::ComposerPtr GlobalCollectionComposerAction::composer()
282
{
283
    return m_currentComposer;
284
}