MythTV  master
playlistcontainer.h
Go to the documentation of this file.
1 #ifndef PLAYLIST_CONTAINER_H
2 #define PLAYLIST_CONTAINER_H
3 
4 // qt
5 #include <QCoreApplication>
6 
7 // MythTV
8 #include "mthread.h"
9 
10 
11 #define DEFAULT_PLAYLIST_NAME "default_playlist_storage"
12 #define DEFAULT_STREAMLIST_NAME "stream_playlist"
13 
14 class PlaylistContainer;
15 class Playlist;
16 class AllMusic;
17 
19 {
20  public:
22  AllMusic *all_music_ptr)
23  : MThread("PlaylistLoading"), m_parent(parent_ptr),
24  m_allMusic(all_music_ptr) {}
25 
26  void run() override; // MThread
27 
28  private:
30  AllMusic *m_allMusic {nullptr};
31 };
32 
34 {
36 
37  public:
38  explicit PlaylistContainer(AllMusic *all_music);
39  PlaylistContainer(const PlaylistContainer &rhs) = delete;
42 
43  void load();
44  void resync(void);
45  void describeYourself(void) const; // debugging
46 
47  Playlist* getActive(void) { return m_activePlaylist; }
48  Playlist* getPlaylist(int id);
49  Playlist* getPlaylist(const QString &name);
51 
52  void save();
53 
54  void createNewPlaylist(const QString &name);
55  void copyNewPlaylist(const QString &name);
56  void copyToActive(int index);
57 
58  QString getPlaylistName(int index, bool &reference);
59 
60  void deletePlaylist(int kill_me);
61  void renamePlaylist(int index, QString new_name);
62 
63  bool nameIsUnique(const QString& a_name, int which_id);
64 
65  void clearActive();
66 
67  bool doneLoading() const{return m_doneLoading;}
68 
69  bool cleanOutThreads();
70 
71  void FillIntelliWeights(int &rating, int &playcount,
72  int &lastplay, int &random) const;
73  QList<Playlist*> *getPlaylists(void) { return m_allPlaylists; }
74  QStringList getPlaylistNames(void);
75 
76  private:
79  QList<Playlist*> *m_allPlaylists {nullptr};
80 
82  bool m_doneLoading {false};
83  QString m_myHost;
84 
85  int m_ratingWeight {2};
88  int m_randomWeight {2};
89 };
90 
91 #endif // PLAYLIST_CONTAINER_H
PlaylistContainer::~PlaylistContainer
~PlaylistContainer()
Definition: playlistcontainer.cpp:41
PlaylistContainer::m_playCountWeight
int m_playCountWeight
Definition: playlistcontainer.h:86
PlaylistContainer::getPlaylistName
QString getPlaylistName(int index, bool &reference)
Definition: playlistcontainer.cpp:252
AllMusic
Definition: musicmetadata.h:418
PlaylistContainer::PlaylistContainer
PlaylistContainer(AllMusic *all_music)
Definition: playlistcontainer.cpp:29
PlaylistLoadingThread::m_parent
PlaylistContainer * m_parent
Definition: playlistcontainer.h:29
PlaylistContainer::createNewPlaylist
void createNewPlaylist(const QString &name)
Definition: playlistcontainer.cpp:182
Playlist
Definition: playlist.h:46
PlaylistContainer::deletePlaylist
void deletePlaylist(int kill_me)
Definition: playlistcontainer.cpp:228
PlaylistContainer::copyNewPlaylist
void copyNewPlaylist(const QString &name)
Definition: playlistcontainer.cpp:193
PlaylistContainer::describeYourself
void describeYourself(void) const
Definition: playlistcontainer.cpp:126
PlaylistContainer::getPlaylistNames
QStringList getPlaylistNames(void)
Definition: playlistcontainer.cpp:286
PlaylistLoadingThread
Definition: playlistcontainer.h:19
PlaylistContainer::m_ratingWeight
int m_ratingWeight
Definition: playlistcontainer.h:85
PlaylistContainer::getActive
Playlist * getActive(void)
Definition: playlistcontainer.h:47
PlaylistContainer::operator=
PlaylistContainer & operator=(const PlaylistContainer &rhs)=delete
PlaylistContainer::FillIntelliWeights
void FillIntelliWeights(int &rating, int &playcount, int &lastplay, int &random) const
Definition: playlistcontainer.cpp:60
PlaylistContainer::Q_DECLARE_TR_FUNCTIONS
Q_DECLARE_TR_FUNCTIONS(PlaylistContainer)
hardwareprofile.scan.rating
def rating(profile, smoonURL, gate)
Definition: scan.py:39
PlaylistContainer::getStreamPlaylist
Playlist * getStreamPlaylist(void)
Definition: playlistcontainer.h:50
PlaylistContainer::m_streamPlaylist
Playlist * m_streamPlaylist
Definition: playlistcontainer.h:78
PlaylistContainer::getPlaylist
Playlist * getPlaylist(int id)
Definition: playlistcontainer.cpp:134
PlaylistContainer::nameIsUnique
bool nameIsUnique(const QString &a_name, int which_id)
Definition: playlistcontainer.cpp:275
PlaylistContainer::resync
void resync(void)
Definition: playlistcontainer.cpp:117
PlaylistContainer::m_playlistsLoader
PlaylistLoadingThread * m_playlistsLoader
Definition: playlistcontainer.h:81
PlaylistContainer::load
void load()
Definition: playlistcontainer.cpp:69
PlaylistContainer::cleanOutThreads
bool cleanOutThreads()
Definition: playlistcontainer.cpp:298
PlaylistLoadingThread::m_allMusic
AllMusic * m_allMusic
Definition: playlistcontainer.h:30
PlaylistContainer::m_myHost
QString m_myHost
Definition: playlistcontainer.h:83
PlaylistLoadingThread::PlaylistLoadingThread
PlaylistLoadingThread(PlaylistContainer *parent_ptr, AllMusic *all_music_ptr)
Definition: playlistcontainer.h:21
PlaylistContainer::save
void save()
Definition: playlistcontainer.cpp:169
random
static long int random(void)
Definition: compat.h:150
PlaylistContainer::PlaylistContainer
PlaylistContainer(const PlaylistContainer &rhs)=delete
PlaylistContainer::m_doneLoading
bool m_doneLoading
Definition: playlistcontainer.h:82
PlaylistContainer::m_allPlaylists
QList< Playlist * > * m_allPlaylists
Definition: playlistcontainer.h:79
MThread
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:49
mthread.h
PlaylistContainer::m_activePlaylist
Playlist * m_activePlaylist
Definition: playlistcontainer.h:77
PlaylistContainer::m_lastPlayWeight
int m_lastPlayWeight
Definition: playlistcontainer.h:87
PlaylistContainer::clearActive
void clearActive()
Definition: playlistcontainer.cpp:308
PlaylistContainer::copyToActive
void copyToActive(int index)
Definition: playlistcontainer.cpp:205
PlaylistContainer::doneLoading
bool doneLoading() const
Definition: playlistcontainer.h:67
PlaylistContainer::getPlaylists
QList< Playlist * > * getPlaylists(void)
Definition: playlistcontainer.h:73
PlaylistContainer::renamePlaylist
void renamePlaylist(int index, QString new_name)
Definition: playlistcontainer.cpp:218
PlaylistLoadingThread::run
void run() override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
Definition: playlistcontainer.cpp:14
PlaylistContainer
Definition: playlistcontainer.h:34
PlaylistContainer::m_randomWeight
int m_randomWeight
Definition: playlistcontainer.h:88