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)
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);
134 (*it)->describeYourself();
150 if ((*it)->getID() == id)
154 LOG(VB_GENERAL, LOG_ERR,
155 "getPlaylistName() called with unknown index number");
167 if ((*it)->getName() == name)
171 LOG(VB_GENERAL, LOG_ERR, QString(
"getPlaylistName() called with unknown name: %1").arg(name));
180 if ((*it)->hasChanged())
181 (*it)->savePlaylist((*it)->getName(),
m_myHost);
191 new_list->setParent(
this);
194 new_list->savePlaylist(name,
m_myHost);
202 new_list->setParent(
this);
205 new_list->savePlaylist(name,
m_myHost);
217 LOG(VB_GENERAL, LOG_ERR,
LOC +
"copyToActive() " +
218 QString(
"Unknown playlist: %1").arg(index));
229 list_to_rename->
setName(std::move(new_name));
239 LOG(VB_GENERAL, LOG_ERR,
LOC +
"deletePlaylist() " +
240 QString(
"Unknown playlist: %1").arg(kill_me));
248 query.
prepare(
"DELETE FROM music_playlists WHERE playlist_id = :ID ;");
270 if ((*it)->getID() == index)
271 return (*it)->getName();
275 LOG(VB_GENERAL, LOG_ERR,
LOC +
276 "getPlaylistName() called with unknown index number");
279 return tr(
"Something is Wrong");
290 if ((*it)->getName() == a_name && (*it)->getID() != which_id)
304 res.append((*it)->getName());
#define DEFAULT_PLAYLIST_NAME
void RunEpilog(void)
Cleans up a thread's resources, call this if you reimplement run().
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
void createNewPlaylist(const QString &name)
void start(QThread::Priority=QThread::InheritPriority)
Tell MThread to start running the thread in the near future.
QString getPlaylistName(int index, bool &reference)
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
PlaylistContainer(AllMusic *all_music)
void describeYourself(void) const
void deletePlaylist(int kill_me)
QStringList getPlaylistNames(void)
void copyNewPlaylist(const QString &name)
void setParent(PlaylistContainer *myparent)
QSqlQuery wrapper that fetches a DB connection from the connection pool.
bool wait(unsigned long time=ULONG_MAX)
Wait for the MThread to exit, with a maximum timeout.
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
static void msleep(unsigned long time)
Playlist * getPlaylist(int id)
void resync(void)
make sure all tracks are still valid after a scan
QVariant value(int i) const
void setName(QString a_name)
def rating(profile, smoonURL, gate)
PlaylistLoadingThread * m_playlistsLoader
bool nameIsUnique(const QString &a_name, int which_id)
static MSqlQueryInfo InitCon(ConnectionReuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Playlist * m_streamPlaylist
void run() override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
void loadPlaylist(const QString &a_name, const QString &a_host)
void copyTracks(Playlist *to_ptr, bool update_display)
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Playlist * m_activePlaylist
#define LOG(_MASK_, _LEVEL_, _STRING_)
void savePlaylist(const QString &a_name, const QString &a_host)
void copyToActive(int index)
QList< Playlist * > * m_allPlaylists
void RunProlog(void)
Sets up a thread, call this if you reimplement run().
int numRowsAffected() const
bool isFinished(void) const
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
void FillIntelliWeights(int &rating, int &playcount, int &lastplay, int &random)
static long int random(void)
static void DBError(const QString &where, const MSqlQuery &query)
void describeYourself(void) const
void removeAllTracks(void)
void renamePlaylist(int index, QString new_name)
PlaylistContainer * parent
#define DEFAULT_STREAMLIST_NAME