00001 #ifndef PLAYLIST_H_
00002 #define PLAYLIST_H_
00003
00004 #include <QList>
00005 #include <QMap>
00006
00007 #include "metadata.h"
00008 #include "musicplayer.h"
00009
00010 class PlaylistContainer;
00011 class Playlist;
00012 class MythSystem;
00013
00014 enum InsertPLOption
00015 {
00016 PL_REPLACE = 1,
00017 PL_INSERTATBEGINNING,
00018 PL_INSERTATEND,
00019 PL_INSERTAFTERCURRENT
00020 };
00021
00022 enum PlayPLOption
00023 {
00024 PL_FIRST = 1,
00025 PL_FIRSTNEW,
00026 PL_CURRENT
00027 };
00028
00029 struct PlaylistOptions
00030 {
00031 InsertPLOption insertPLOption;
00032 PlayPLOption playPLOption;
00033 };
00034
00035 typedef QList<Metadata*> SongList;
00036
00037 class Playlist : public QObject
00038 {
00039 Q_OBJECT
00040
00041 public:
00042 Playlist(void);
00043 ~Playlist();
00044
00045 void setParent(PlaylistContainer *myparent) { m_parent = myparent; }
00046
00047 void loadPlaylist(QString a_name, QString a_host);
00048 void loadPlaylistByID(int id, QString a_host);
00049
00050 void savePlaylist(QString a_name, QString a_host);
00051
00052 void shuffleTracks(MusicPlayer::ShuffleMode mode);
00053
00054 void describeYourself(void) const;
00055
00056 void fillSongsFromCD();
00057 void fillSongsFromSonglist(QString songList);
00058 void fillSonglistFromQuery(QString whereClause,
00059 bool removeDuplicates = false,
00060 InsertPLOption insertOption = PL_REPLACE,
00061 int currentTrackID = 0);
00062 void fillSonglistFromSmartPlaylist(QString category, QString name,
00063 bool removeDuplicates = false,
00064 InsertPLOption insertOption = PL_REPLACE,
00065 int currentTrackID = 0);
00066 void fillSonglistFromList(const QList<int> &songList,
00067 bool removeDuplicates,
00068 InsertPLOption insertOption,
00069 int currentTrackID);
00070 QString toRawSonglist(bool shuffled = false);
00071
00072 const SongList &getSongs(void) { return m_shuffledSongs; }
00073 Metadata* getSongAt(int pos);
00074
00075 int getCount(void) { return m_songs.count(); }
00076
00077 void moveTrackUpDown(bool flag, int where_its_at);
00078 void moveTrackUpDown(bool flag, Metadata *the_track);
00079
00080 bool checkTrack(int a_track_id) const;
00081
00082 void addTrack(int trackID, bool update_display);
00083 void addTrack(Metadata *mdata, bool update_display);
00084
00085 void removeTrack(int the_track_id);
00086 void removeAllTracks(void);
00087
00088 void copyTracks(Playlist *to_ptr, bool update_display) const;
00089
00090 bool hasChanged(void) { return m_changed; }
00091 void Changed(void) { m_changed = true; }
00092
00093 QString getName(void) { return m_name; }
00094 void setName(QString a_name) { m_name = a_name; }
00095
00096 int getID(void) { return m_playlistid; }
00097 void setID(int x) { m_playlistid = x; }
00098
00099 void getStats(uint *trackCount, uint *totalLength, uint currentTrack = 0, uint *playedLength = NULL) const;
00100
00101 void computeSize(double &size_in_MB, double &size_in_sec);
00102 int CreateCDMP3(void);
00103 int CreateCDAudio(void);
00104
00105 private slots:
00106 void mkisofsData(int fd);
00107 void cdrecordData(int fd);
00108 void processExit(uint retval = 0);
00109
00110 private:
00111
00112 QString removeDuplicateTracks(const QString &orig_songlist, const QString &new_songlist);
00113
00114 int m_playlistid;
00115 QString m_name;
00116 SongList m_songs;
00117 SongList m_shuffledSongs;
00118 QMap<int, Metadata*> m_songMap;
00119 PlaylistContainer *m_parent;
00120 bool m_changed;
00121 MythProgressDialog *m_progress;
00122 MythSystem *m_proc;
00123 uint m_procExitVal;
00124 };
00125
00126 #endif