Warning, file /multimedia/amarok/src/playlistmanager/file/PlaylistFileProvider.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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 PLAYLISTFILEPROVIDER_H 0018 #define PLAYLISTFILEPROVIDER_H 0019 0020 #include "core/playlists/PlaylistFormat.h" 0021 #include "core/playlists/PlaylistProvider.h" 0022 #include "core-impl/playlists/providers/user/UserPlaylistProvider.h" 0023 #include "core-impl/playlists/types/file/PlaylistFileSupport.h" 0024 0025 #include <KConfigGroup> 0026 0027 class QTimer; 0028 0029 namespace Playlists { 0030 /** 0031 @author Bart Cerneels <bart.cerneels@kde.org> 0032 */ 0033 class PlaylistFileProvider : public Playlists::UserPlaylistProvider 0034 { 0035 Q_OBJECT 0036 0037 public: 0038 PlaylistFileProvider(); 0039 ~PlaylistFileProvider() override; 0040 0041 QString prettyName() const override; 0042 QIcon icon() const override; 0043 0044 int category() const override { return Playlists::UserPlaylist; } 0045 0046 int playlistCount() const override; 0047 Playlists::PlaylistList playlists() override; 0048 0049 /** 0050 * Returns a Playlists::PlaylistPtr to the new playlist, NULL if something failed. 0051 * @param tracks Tracks being added to that new playlist. 0052 * @param name File name of the new playlist. If no extension is being given we 0053 * default to xspf. '/' and '\' are being replaced by '-'. 0054 */ 0055 Playlists::PlaylistPtr save( const Meta::TrackList &tracks, 0056 const QString &name = QString() ) override; 0057 0058 virtual bool import( const QUrl &path ); 0059 0060 bool isWritable() override { return true; } 0061 void renamePlaylist(Playlists::PlaylistPtr playlist, const QString &newName ) override; 0062 bool deletePlaylists( const Playlists::PlaylistList &playlists ) override; 0063 0064 /* PlaylistFileProvider methods */ 0065 /** Schedules a PlaylistFile to be saved on the next iteration of the mainloop. 0066 * Each playlist will be scheduled and saved only once. 0067 */ 0068 void saveLater( Playlists::PlaylistFilePtr playlist ); 0069 0070 private Q_SLOTS: 0071 void loadPlaylists(); 0072 void slotSaveLater(); 0073 0074 private: 0075 bool deletePlaylistFiles( Playlists::PlaylistFileList playlistFiles ); 0076 KConfigGroup loadedPlaylistsConfig() const; 0077 0078 bool m_playlistsLoaded; 0079 QList<QUrl> m_urlsToLoad; 0080 Playlists::PlaylistFileList m_playlists; 0081 QMultiMap<QString, Playlists::PlaylistPtr> m_groupMap; 0082 0083 QTimer *m_saveLaterTimer; 0084 QList<Playlists::PlaylistFilePtr> m_saveLaterPlaylists; 0085 }; 0086 0087 } //namespace Playlists 0088 0089 #endif