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