File indexing completed on 2024-05-19 04:49:30

0001 /****************************************************************************************
0002  * Copyright (c) 2007 Bart Cerneels <bart.cerneels@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 AMAROK_PLAYLISTPROVIDER_H
0018 #define AMAROK_PLAYLISTPROVIDER_H
0019 
0020 #include "core/amarokcore_export.h"
0021 #include "core/playlists/Playlist.h"
0022 
0023 class QIcon;
0024 
0025 namespace Playlists {
0026 
0027 class AMAROKCORE_EXPORT PlaylistProvider : public QObject
0028 {
0029     Q_OBJECT
0030 
0031     public:
0032         explicit PlaylistProvider( QObject *parent = nullptr );
0033 
0034         /**
0035          * A translated string to identify this Provider.
0036          */
0037         virtual QString prettyName() const = 0;
0038 
0039         /**
0040          * A nice icon for this playlist provider.
0041          */
0042         virtual QIcon icon() const = 0;
0043 
0044         /**
0045          * @returns An unique integer that identifies the category of the offered playlists.
0046          * Use the PlaylistManager::PlaylistCategory enum.
0047          */
0048         virtual int category() const = 0;
0049 
0050         /**
0051          * @returns the number of playlists this provider has or a negative value if it
0052          * can not determine that before loading them all.
0053          *
0054          * Default implementation returns -1.
0055          */
0056         virtual int playlistCount() const { return -1; }
0057 
0058         /**
0059          * Return a list of playlists of this provider. If playlistCount() is negative,
0060          * this list may be incomplete.
0061          */
0062         virtual PlaylistList playlists() = 0;
0063 
0064         virtual QActionList providerActions();
0065         virtual QActionList playlistActions( const PlaylistList &playlists );
0066         virtual QActionList trackActions( const QMultiHash<PlaylistPtr, int> &playlistTracks );
0067 
0068         /**
0069          * Return true if this providers supports modification made by the user.
0070          *
0071          * I.e. whether addPlaylist(), renamePlaylist(), deletePlaylists() make sense
0072          * to be triggered by user action.
0073          *
0074          * Default implementation returns false.
0075          */
0076         virtual bool isWritable();
0077 
0078         /**
0079          * Copy a playlist to the provider.
0080          */
0081         virtual PlaylistPtr addPlaylist( PlaylistPtr playlist );
0082 
0083         /**
0084          * Rename a playlist of this provider.
0085          */
0086         virtual void renamePlaylist( PlaylistPtr playlist, const QString &newName );
0087 
0088         /**
0089          * Deletes a list of playlists. Returns true of successful, false otherwise.
0090          *
0091          * Default implementation does nothing and returns false.
0092          */
0093         virtual bool deletePlaylists( const PlaylistList &playlistlist );
0094 
0095         /**
0096          * Copy a track directly to a playlist provider without being in a playlist.
0097          * It's up to the implementation to decide what to do but could for instance allow the
0098          * creation of a new playlist from scratch.
0099          */
0100         virtual Meta::TrackPtr addTrack( const Meta::TrackPtr &track );
0101 
0102     Q_SIGNALS:
0103         void updated();
0104         void playlistAdded( const Playlists::PlaylistPtr &playlist );
0105         void playlistRemoved( const Playlists::PlaylistPtr &playlist );
0106 };
0107 
0108 } //namespace Playlists
0109 
0110 Q_DECLARE_METATYPE( Playlists::PlaylistProvider * )
0111 
0112 #endif // AMAROK_PLAYLISTPROVIDER_H