MythTV  master
playlist.h
Go to the documentation of this file.
1 #ifndef PLAYLIST_H_
2 #define PLAYLIST_H_
3 
4 // qt
5 #include <QList>
6 #include <QMap>
7 
8 // libmythmetadata
9 #include <musicmetadata.h>
10 
11 // mythmusic
12 #include "playlistcontainer.h"
13 #include "musicplayer.h"
14 
15 class PlaylistContainer;
16 class Playlist;
17 class MythSystemLegacy;
18 
20 {
25 };
26 
28 {
29  PL_FIRST = 1,
32 };
33 
35 {
38 };
39 
40 typedef QList<MusicMetadata::IdType> SongList;
41 
42 class Playlist : public QObject
43 {
44  Q_OBJECT
45 
46  public:
47  Playlist(void);
48  ~Playlist();
49 
50  void setParent(PlaylistContainer *myparent) { m_parent = myparent; }
51 
52  void loadPlaylist(const QString& a_name, const QString& a_host);
53  void loadPlaylistByID(int id, const QString& a_host);
54 
55  void savePlaylist(const QString& a_name, const QString& a_host);
56 
58 
59  void describeYourself(void) const; // debugging
60 
61  void fillSongsFromSonglist(const QString& songList);
62  void fillSonglistFromQuery(const QString& whereClause,
63  bool removeDuplicates = false,
64  InsertPLOption insertOption = PL_REPLACE,
65  int currentTrackID = 0);
66  void fillSonglistFromSmartPlaylist(const QString& category, const QString& name,
67  bool removeDuplicates = false,
68  InsertPLOption insertOption = PL_REPLACE,
69  int currentTrackID = 0);
70  void fillSonglistFromList(const QList<int> &songList,
71  bool removeDuplicates,
72  InsertPLOption insertOption,
73  int currentTrackID);
74  QString toRawSonglist(bool shuffled = false, bool tracksOnly = false);
75 
76 
77  MusicMetadata* getSongAt(int pos) const;
78 
79  int getTrackCount(void) { return m_songs.count(); }
80 
81  void moveTrackUpDown(bool flag, int where_its_at);
82 
83  bool checkTrack(MusicMetadata::IdType trackID) const;
84 
85  void addTrack(MusicMetadata::IdType trackID, bool update_display);
86 
87  int getTrackPosition(MusicMetadata::IdType trackID) { return m_shuffledSongs.indexOf(trackID); }
88 
89  void removeTrack(MusicMetadata::IdType trackID);
90  void removeAllTracks(void);
91  void removeAllCDTracks(void);
92 
93  void copyTracks(Playlist *to_ptr, bool update_display);
94 
95  bool hasChanged(void) { return m_changed; }
96  void changed(void);
97 
99  void disableSaves(void) { m_doSave = false; }
100  void enableSaves(void) { m_doSave = true; }
101  bool doSaves(void) { return m_doSave; }
102 
103  QString getName(void) { return m_name; }
104  void setName(QString a_name) { m_name = a_name; }
105 
107 
108  int getID(void) { return m_playlistid; }
109  void setID(int x) { m_playlistid = x; }
110 
111  void getStats(uint *trackCount, uint *totalLength, uint currentTrack = 0, uint *playedLength = nullptr) const;
112 
113  void resync(void);
114 
115 #ifdef CD_WRTITING_FIXED
116  void computeSize(double &size_in_MB, double &size_in_sec);
117  int CreateCDMP3(void);
118  int CreateCDAudio(void);
119 
120  private slots:
121  void mkisofsData(int fd);
122  void cdrecordData(int fd);
123  void processExit(uint retval = 0);
124 #endif
125 
126  private:
127  MusicMetadata* getRawSongAt(int pos) const;
128  static QString removeDuplicateTracks(const QString &orig_songlist, const QString &new_songlist);
129 
130  int m_playlistid {0};
131  QString m_name;
132 
135 
137  bool m_changed {false};
138  bool m_doSave {true};
139 #ifdef CD_WRTITING_FIXED
140  MythProgressDialog *m_progress {nullptr};
141  MythSystemLegacy *m_proc {nullptr};
142  uint m_procExitVal {0};
143 #endif
144 };
145 
146 #endif
#define DEFAULT_PLAYLIST_NAME
MusicMetadata * getSongAt(int pos) const
Definition: playlist.cpp:1084
void shuffleTracks(MusicPlayer::ShuffleMode mode)
Definition: playlist.cpp:155
QList< MusicMetadata::IdType > SongList
Definition: playlist.h:40
unsigned int slots[4]
Definition: element.c:38
int m_playlistid
Definition: playlist.h:130
MusicMetadata * getRawSongAt(int pos) const
Definition: playlist.cpp:1102
void loadPlaylistByID(int id, const QString &a_host)
Definition: playlist.cpp:589
void setParent(PlaylistContainer *myparent)
Definition: playlist.h:50
PlayPLOption playPLOption
Definition: playlist.h:37
void removeAllCDTracks(void)
Definition: playlist.cpp:95
unsigned int uint
Definition: compat.h:140
void enableSaves(void)
Definition: playlist.h:100
QString getName(void)
Definition: playlist.h:103
SongList m_shuffledSongs
Definition: playlist.h:134
void resync(void)
make sure all tracks are still valid after a scan
Definition: playlist.cpp:617
void fillSonglistFromSmartPlaylist(const QString &category, const QString &name, bool removeDuplicates=false, InsertPLOption insertOption=PL_REPLACE, int currentTrackID=0)
Definition: playlist.cpp:897
bool hasChanged(void)
Definition: playlist.h:95
void setName(QString a_name)
Definition: playlist.h:104
Playlist(void)
Definition: playlist.cpp:144
void removeTrack(MusicMetadata::IdType trackID)
Definition: playlist.cpp:117
QString toRawSonglist(bool shuffled=false, bool tracksOnly=false)
Definition: playlist.cpp:858
bool checkTrack(MusicMetadata::IdType trackID) const
Definition: playlist.cpp:38
static QString removeDuplicateTracks(const QString &orig_songlist, const QString &new_songlist)
Definition: playlist.cpp:1068
int getTrackCount(void)
Definition: playlist.h:79
void fillSonglistFromQuery(const QString &whereClause, bool removeDuplicates=false, InsertPLOption insertOption=PL_REPLACE, int currentTrackID=0)
Definition: playlist.cpp:691
bool doSaves(void)
Definition: playlist.h:101
void moveTrackUpDown(bool flag, int where_its_at)
Definition: playlist.cpp:128
void changed(void)
Definition: playlist.cpp:987
void disableSaves(void)
whether any changes should be saved to the DB
Definition: playlist.h:99
QString m_name
Definition: playlist.h:131
int getID(void)
Definition: playlist.h:108
const char * name
Definition: ParseText.cpp:328
void loadPlaylist(const QString &a_name, const QString &a_host)
Definition: playlist.cpp:532
void addTrack(MusicMetadata::IdType trackID, bool update_display)
Given a tracks ID, add that track to this playlist.
Definition: playlist.cpp:63
PlayPLOption
Definition: playlist.h:27
bool isActivePlaylist(void)
Definition: playlist.h:106
void copyTracks(Playlist *to_ptr, bool update_display)
Definition: playlist.cpp:43
bool m_doSave
Definition: playlist.h:138
SongList m_songs
Definition: playlist.h:133
void savePlaylist(const QString &a_name, const QString &a_host)
Definition: playlist.cpp:995
PlaylistContainer * m_parent
Definition: playlist.h:136
void fillSongsFromSonglist(const QString &songList)
Definition: playlist.cpp:645
InsertPLOption
Definition: playlist.h:19
void getStats(uint *trackCount, uint *totalLength, uint currentTrack=0, uint *playedLength=nullptr) const
Definition: playlist.cpp:506
InsertPLOption insertPLOption
Definition: playlist.h:36
int getTrackPosition(MusicMetadata::IdType trackID)
Definition: playlist.h:87
void fillSonglistFromList(const QList< int > &songList, bool removeDuplicates, InsertPLOption insertOption, int currentTrackID)
Definition: playlist.cpp:788
void setID(int x)
Definition: playlist.h:109
void describeYourself(void) const
Definition: playlist.cpp:486
void removeAllTracks(void)
Definition: playlist.cpp:87
bool m_changed
Definition: playlist.h:137
uint32_t IdType
Definition: musicmetadata.h:84