1 /**************************************************************************************** 2 * Copyright (c) 2012 Tatjana Gornak <t.gornak@gmail.com> * 3 * * 4 * This program is free software; you can redistribute it and/or modify it under * 5 * the terms of the GNU General Public License as published by the Free Software * 6 * Foundation; either version 2 of the License, or (at your option) any later * 7 * version. * 8 * * 9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 * * 13 * You should have received a copy of the GNU General Public License along with * 14 * this program. If not, see <http://www.gnu.org/licenses/>. * 15 ****************************************************************************************/ 16 17 #ifndef AMAROK_PLAYLISTRESTORER_H 18 #define AMAROK_PLAYLISTRESTORER_H 19 20 #include "core-impl/playlists/types/file/PlaylistFile.h" 21 22 namespace Playlist 23 { 24 25 /** 26 * Implements loading of default playlist or default track 27 * in case if no playlist was saved (e.g. first run of Amarok) 28 */ 29 class Restorer: public QObject, public Playlists::PlaylistObserver 30 { 31 Q_OBJECT 32 33 public: 34 Restorer(); 35 36 /** 37 * Initiate restoring procedure. 38 * @param path path to the playlist to restore 39 */ 40 void restore( const QUrl &path ); 41 42 // PlaylistObserver methods: 43 void tracksLoaded( Playlists::PlaylistPtr) override; 44 45 Q_SIGNALS: 46 void restoreFinished(); 47 48 private: 49 /** 50 * Runs default tune if there is no playlist to restore 51 */ 52 void runJingle(); 53 54 /** 55 * Processes so far loaded tracks. 56 * If track is a playlist, then its loading is triggered 57 */ 58 void processTracks(); 59 60 Playlists::PlaylistFilePtr m_playlistToRestore; 61 Meta::TrackList m_tracks; 62 /// tracks last processed track position 63 QMutableListIterator<Meta::TrackPtr> m_position; 64 }; 65 } 66 67 #endif 68