59 for (
int i = 0; i <
__entries.size(); i++ ) {
71 if ( ret ==
nullptr ) {
75 WARNINGLOG( QString(
"update playlist %1" ).arg( pl_path ) );
79 XMLNode root = doc.firstChildElement(
"playlist" );
80 if ( root.isNull() ) {
81 ERRORLOG(
"playlist node not found" );
84 QFileInfo fileInfo = QFileInfo( pl_path );
90 QString filename = node->
read_string(
"name",
"",
false,
false );
91 if ( filename.isEmpty() ) {
92 ERRORLOG(
"Playlist has no name, abort" );
97 pPlaylist->
setFilename( fileInfo.absoluteFilePath() );
99 XMLNode songsNode = node->firstChildElement(
"songs" );
100 if ( !songsNode.isNull() ) {
101 XMLNode nextNode = songsNode.firstChildElement(
"song" );
102 while ( !nextNode.isNull() ) {
104 QString songPath = nextNode.
read_string(
"path",
"",
false,
false );
105 if ( !songPath.isEmpty() ) {
107 QFileInfo songPathInfo( fileInfo.absoluteDir(), songPath );
108 pEntry->
filePath = songPathInfo.absoluteFilePath();
109 pEntry->
fileExists = songPathInfo.isReadable();
112 pPlaylist->
add( pEntry );
115 nextNode = nextNode.nextSiblingElement(
"song" );
123bool Playlist::save_file(
const QString& pl_path,
const QString& name,
bool overwrite,
bool useRelativePaths )
125 INFOLOG( QString(
"Saving palylist to %1" ).arg( pl_path ) );
127 ERRORLOG( QString(
"palylist %1 already exists" ).arg( pl_path ) );
137 save_to( &songs, useRelativePaths );
138 return doc.
write( pl_path );
143 for (
int i = 0; i <
size(); i++ ) {
146 if ( useRelativePaths ) {
162 if ( playlist !=
nullptr ) {
185 if (
size() == 0 || songNumber >=
size() ) {
199 if (
size() == 0 || songNumber >=
size() ) {
211 if ( !
get( index )->scriptEnabled || !QFile( file ).exists() ) {
215 std::system( file.toLocal8Bit() );
224 sOutput = QString(
"%1[Playlist]\n" ).arg( sPrefix )
225 .append( QString(
"%1%2filename: %3\n" ).arg( sPrefix ).arg( s ).arg(
__filename ) )
226 .append( QString(
"%1%2m_nSelectedSongNumber: %3\n" ).arg( sPrefix ).arg( s ).arg(
m_nSelectedSongNumber ) )
227 .append( QString(
"%1%2m_nActiveSongNumber: %3\n" ).arg( sPrefix ).arg( s ).arg(
m_nActiveSongNumber ) )
228 .append( QString(
"%1%2entries:\n" ).arg( sPrefix ).arg( s ) );
231 sOutput.append( QString(
"%1%2Entry:\n" ).arg( sPrefix ).arg( s + s ) )
232 .append( QString(
"%1%2filePath: %3\n" ).arg( sPrefix ).arg( s + s + s ).arg( ii->filePath ) )
233 .append( QString(
"%1%2fileExists: %3\n" ).arg( sPrefix ).arg( s + s + s ).arg( ii->fileExists ) )
234 .append( QString(
"%1%2scriptPath: %3\n" ).arg( sPrefix ).arg( s + s + s ).arg( ii->scriptPath ) )
235 .append( QString(
"%1%2scriptEnabled: %3\n" ).arg( sPrefix ).arg( s + s + s ).arg( ii->scriptEnabled ) );
238 sOutput.append( QString(
"%1%2m_bIsModified: %3\n" ).arg( sPrefix ).arg( s ).arg(
m_bIsModified ) );
240 sOutput = QString(
"[Playlist]" )
241 .append( QString(
" filename: %1" ).arg(
__filename ) )
244 .append(
", entries: {" );
247 sOutput.append( QString(
"[filePath: %1" ).arg( ii->filePath ) )
248 .append( QString(
", fileExists: %1" ).arg( ii->fileExists ) )
249 .append( QString(
", scriptPath: %1" ).arg( ii->scriptPath ) )
250 .append( QString(
", scriptEnabled: %1] " ).arg( ii->scriptEnabled ) );
255 sOutput.append( QString(
"}, m_bIsModified: %1\n" ).arg(
m_bIsModified ) );
static QString sPrintIndention
String used to format the debugging string output of some core classes.
static EventQueue * get_instance()
Returns a pointer to the current EventQueue singleton stored in __instance.
void push_event(const EventType type, const int nValue)
Queues the next event into the EventQueue.
static QString playlist_xsd_path()
returns the path to the playlist pattern XSD (xml schema definition) file
static QString playlists_dir()
returns user playlist path
static bool file_exists(const QString &path, bool silent=false)
returns true if the given path is an existing regular file
static Playlist * load_playlist(Playlist *pl, const QString &pl_path)
load playlist from a file
static Playlist * __instance
Object holding the current Playlist singleton.
void setNextSongByNumber(int SongNumber)
std::vector< Entry * > __entries
int m_nSelectedSongNumber
void save_to(XMLNode *node, bool useRelativePaths)
static void create_instance()
If __instance equals 0, a new Playlist singleton will be created and stored in it.
void activateSong(int SongNumber)
void execScript(int index)
void setFilename(const QString &filename)
void setSelectedSongNr(int songNumber)
QString toQString(const QString &sPrefix="", bool bShort=true) const override
Formatted string version for debugging purposes.
void setActiveSongNumber(int ActiveSongNumber)
bool save_file(const QString &pl_path, const QString &name, bool overwrite, bool useRelativePaths)
static Playlist * load_from(XMLNode *root, QFileInfo &fileInfo, bool useRelativePaths)
const QString & getFilename()
static Playlist * load(const QString &filename, bool useRelativePaths)
static Playlist * load_file(const QString &pl_path, bool useRelativePaths)
bool getSongFilenameByNumber(int songNumber, QString &fileName)
XMLDoc is a subclass of QDomDocument with read and write methods.
XMLNode set_root(const QString &node_name, const QString &xmlns=nullptr)
create the xml header and root node
bool read(const QString &filepath, const QString &schemapath=nullptr, bool bSilent=false)
read the content of an xml file
bool write(const QString &filepath)
write itself into a file
XMLNode is a subclass of QDomNode with read and write values methods.
bool read_bool(const QString &node, bool default_value, bool inexistent_ok=true, bool empty_ok=true, bool bSilent=false)
reads a boolean stored into a child node
QString read_string(const QString &node, const QString &default_value, bool inexistent_ok=true, bool empty_ok=true, bool bSilent=false)
reads a string stored into a child node
XMLNode createNode(const QString &name)
create a new XMLNode that has to be appended into de XMLDoc
void write_string(const QString &node, const QString &value)
write a string into a child node
void write_bool(const QString &node, const bool value)
write a boolean into a child node
@ EVENT_PLAYLIST_LOADSONG