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