File indexing completed on 2025-02-23 04:28:33
0001 /**************************************************************************************** 0002 * Copyright (c) 2013 Anmol Ahuja <darthcodus@gmail.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 #ifndef PLAYLISTPROVIDER_EXPORTER_H 0018 #define PLAYLISTPROVIDER_EXPORTER_H 0019 0020 #include "core/meta/forward_declarations.h" 0021 #include "core/playlists/PlaylistProvider.h" 0022 0023 #include <QIcon> 0024 #include <QObject> 0025 #include <QString> 0026 #include <QPointer> 0027 0028 class QJSEngine; 0029 0030 0031 namespace Playlists 0032 { 0033 class Playlist; 0034 0035 typedef AmarokSharedPointer<Playlist> PlaylistPtr; 0036 typedef QList<PlaylistPtr> PlaylistList; 0037 } 0038 0039 class QIcon; 0040 0041 namespace AmarokScript 0042 { 0043 // SCRIPTDOX PROTOTYPE Playlists::PlaylistProvider PlaylistProvider 0044 class PlaylistProviderPrototype : public QObject 0045 { 0046 Q_OBJECT 0047 0048 /** 0049 * Return true if this provider supports modification. 0050 * i.e. whether addPlaylist(), renamePlaylist(), deletePlaylists() can 0051 * be triggered. 0052 */ 0053 Q_PROPERTY( bool isWritable READ isWritable ) 0054 0055 /** 0056 * A user presentable name for this collection. Same as its {@link #toString toString}. 0057 */ 0058 Q_PROPERTY( QString prettyName READ toString ) 0059 0060 /** 0061 * Indicates whether this provider still exists. 0062 */ 0063 Q_PROPERTY( bool isValid READ isValid ) 0064 0065 /** 0066 * A nice icon for this playlist provider. 0067 */ 0068 Q_PROPERTY( QIcon icon READ icon ) 0069 0070 /** 0071 * @returns An integer that identifies the category of the offered playlists. 0072 * Use the Amarok.PlaylistManager.PlaylistCategory enum. 0073 */ 0074 Q_PROPERTY( int category READ category ) 0075 0076 /** 0077 * @returns the number of playlists this provider has or a negative value if it 0078 * can not determine that before loading them all. 0079 */ 0080 Q_PROPERTY( int playlistCount READ playlistCount ) 0081 0082 public: 0083 static void init( QJSEngine *engine ); 0084 explicit PlaylistProviderPrototype( Playlists::PlaylistProvider *provider ); 0085 Playlists::PlaylistProvider* data() const { return m_provider.data(); } 0086 0087 Q_INVOKABLE QString toString() const; 0088 0089 /** 0090 * @returns a list of playlists of this provider. If playlistCount is negative, 0091 * this list may be incomplete. 0092 */ 0093 Q_INVOKABLE Playlists::PlaylistList playlists(); 0094 0095 /** 0096 * Copy a playlist to the provider. 0097 */ 0098 Q_INVOKABLE Playlists::PlaylistPtr addPlaylist( Playlists::PlaylistPtr playlist ); 0099 0100 /** 0101 * Rename a playlist of this provider. 0102 */ 0103 Q_INVOKABLE void renamePlaylist( Playlists::PlaylistPtr playlist, const QString &newName ); 0104 0105 /** 0106 * Deletes a list of playlists. 0107 * @returns true if successful, false otherwise. 0108 */ 0109 Q_INVOKABLE bool deletePlaylists( const Playlists::PlaylistList &playlistlist ); 0110 0111 /** 0112 * UserPlaylistProvider function 0113 */ 0114 Q_INVOKABLE Playlists::PlaylistPtr save( const Meta::TrackList &tracks, const QString &name = QString() ); 0115 0116 0117 private: 0118 QPointer<Playlists::PlaylistProvider> m_provider; 0119 0120 bool isValid() const; 0121 virtual bool isWritable() const; 0122 QIcon icon() const; 0123 int category() const; 0124 int playlistCount() const; 0125 0126 Q_SIGNALS: 0127 void updated(); 0128 void playlistAdded( Playlists::PlaylistPtr playlist ); 0129 void playlistRemoved( Playlists::PlaylistPtr playlist ); 0130 }; 0131 } 0132 0133 #endif