Go to the documentation of this file.
25 #define LOC QString("PlaylistContainer: ")
26 #define LOC_WARN QString("PlaylistContainer, Warning: ")
27 #define LOC_ERR QString("PlaylistContainer, Error: ")
33 m_ratingWeight(
gCoreContext->GetNumSetting(
"IntelliRatingWeight", 2)),
34 m_playCountWeight(
gCoreContext->GetNumSetting(
"IntelliPlayCountWeight", 2)),
35 m_lastPlayWeight(
gCoreContext->GetNumSetting(
"IntelliLastPlayWeight", 2)),
36 m_randomWeight(
gCoreContext->GetNumSetting(
"IntelliRandomWeight", 2))
61 int &lastplay,
int &random)
const
85 query.
prepare(
"SELECT playlist_id FROM music_playlists "
86 "WHERE playlist_name != :DEFAULT"
87 " AND playlist_name != :BACKUP "
88 " AND playlist_name != :STREAM "
89 " AND (hostname = '' OR hostname = :HOST) "
90 "ORDER BY playlist_name;");
92 query.
bindValue(
":BACKUP",
"backup_playlist_storage");
104 auto *temp_playlist =
new Playlist();
106 temp_playlist->setParent(
this);
107 temp_playlist->loadPlaylistByID(query.
value(0).toInt(),
m_myHost);
131 playlist->describeYourself();
144 auto idmatch = [id](
const auto & playlist)
145 {
return playlist->
getID() == id; };
150 LOG(VB_GENERAL, LOG_ERR,
151 "getPlaylistName() called with unknown index number");
159 auto namematch = [name](
const auto & playlist)
160 {
return playlist->
getName() == name; };
165 LOG(VB_GENERAL, LOG_ERR, QString(
"getPlaylistName() called with unknown name: %1").arg(name));
174 if ((*it)->hasChanged())
175 (*it)->savePlaylist((*it)->getName(),
m_myHost);
185 new_list->setParent(
this);
188 new_list->savePlaylist(name,
m_myHost);
196 new_list->setParent(
this);
199 new_list->savePlaylist(name,
m_myHost);
211 LOG(VB_GENERAL, LOG_ERR,
LOC +
"copyToActive() " +
212 QString(
"Unknown playlist: %1").arg(index));
223 list_to_rename->
setName(new_name);
233 LOG(VB_GENERAL, LOG_ERR,
LOC +
"deletePlaylist() " +
234 QString(
"Unknown playlist: %1").arg(kill_me));
242 query.
prepare(
"DELETE FROM music_playlists WHERE playlist_id = :ID ;");
261 auto indexmatch = [index](
const auto & playlist)
262 {
return playlist->getID() == index; };
265 return (*it)->getName();
268 LOG(VB_GENERAL, LOG_ERR,
LOC +
269 "getPlaylistName() called with unknown index number");
272 return tr(
"Something is Wrong");
280 auto itemfound = [a_name,which_id](
const auto & playlist)
281 {
return playlist->getName() == a_name &&
282 playlist->getID() != which_id; };
292 res.append(playlist->getName());
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
QSqlQuery wrapper that fetches a DB connection from the connection pool.
void renamePlaylist(int index, const QString &new_name)
void start(QThread::Priority p=QThread::InheritPriority)
Tell MThread to start running the thread in the near future.
QString getPlaylistName(int index, bool &reference)
void setParent(PlaylistContainer *myparent)
bool wait(std::chrono::milliseconds time=std::chrono::milliseconds::max())
Wait for the MThread to exit, with a maximum timeout.
PlaylistContainer(AllMusic *all_music)
PlaylistContainer * m_parent
void createNewPlaylist(const QString &name)
static void usleep(std::chrono::microseconds time)
QVariant value(int i) const
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
void deletePlaylist(int kill_me)
void copyNewPlaylist(const QString &name)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
void RunProlog(void)
Sets up a thread, call this if you reimplement run().
void describeYourself(void) const
QStringList getPlaylistNames(void)
static constexpr const char * DEFAULT_PLAYLIST_NAME
void FillIntelliWeights(int &rating, int &playcount, int &lastplay, int &random) const
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
static void DBError(const QString &where, const MSqlQuery &query)
def rating(profile, smoonURL, gate)
Playlist * m_streamPlaylist
void resync(void)
make sure all tracks are still valid after a scan
Playlist * getPlaylist(int id)
void setName(const QString &a_name)
void RunEpilog(void)
Cleans up a thread's resources, call this if you reimplement run().
bool nameIsUnique(const QString &a_name, int which_id)
bool isFinished(void) const
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
PlaylistLoadingThread * m_playlistsLoader
void loadPlaylist(const QString &a_name, const QString &a_host)
void copyTracks(Playlist *to_ptr, bool update_display)
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
QList< Playlist * > * m_allPlaylists
void savePlaylist(const QString &a_name, const QString &a_host)
Playlist * m_activePlaylist
static constexpr const char * DEFAULT_STREAMLIST_NAME
int numRowsAffected() const
void copyToActive(int index)
void describeYourself(void) const
void removeAllTracks(void)
void run() override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.