hydrogen 1.2.6
Playlist.h
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 * Copyright(c) 2008-2025 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
5 *
6 * http://www.hydrogen-music.org
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY, without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see https://www.gnu.org/licenses
20 *
21 */
22
23#ifndef H2C_PLAYLIST_H
24#define H2C_PLAYLIST_H
25
26#include <core/Object.h>
27
28namespace H2Core
29{
30
35class Playlist : public H2Core::Object<Playlist>
36
37{
39
40 public:
41 struct Entry
42 {
43 QString filePath;
45 QString scriptPath;
47 };
48
55 static void create_instance();
60 static Playlist* get_instance() { assert(__instance); return __instance; }
61
62 ~Playlist();
63
64 void activateSong (int SongNumber );
65
66 int size() const;
67 Entry* get( int idx );
68
69 void clear();
70 void add( Entry* entry );
71
72 void setNextSongByNumber( int SongNumber );
74 void setSelectedSongNr( int songNumber );
75
77 void setActiveSongNumber( int ActiveSongNumber );
78
79 bool getSongFilenameByNumber( int songNumber, QString& fileName);
80
81 const QString& getFilename();
82 void setFilename( const QString& filename );
83 bool getIsModified();
84 void setIsModified( bool IsModified );
85
86 static Playlist* load( const QString& filename, bool useRelativePaths );
87 static Playlist* load_file( const QString& pl_path, bool useRelativePaths );
88 bool save_file( const QString& pl_path, const QString& name, bool overwrite, bool useRelativePaths );
97 QString toQString( const QString& sPrefix = "", bool bShort = true ) const override;
98
99 private:
106 QString __filename;
107
108 std::vector<Entry*> __entries;
109
112
114
115 Playlist();
116
117 void execScript( int index );
118
119 void save_to( XMLNode* node, bool useRelativePaths );
120};
121
122inline int Playlist::size() const
123{
124 return __entries.size();
125}
126
128{
129 assert( idx >= 0 && idx < size() );
130 return __entries[ idx ];
131}
132
133inline void Playlist::add( Entry* entry )
134{
135 __entries.push_back( entry );
136}
137
139{
141}
142
143inline void Playlist::setSelectedSongNr( int songNumber )
144{
145 m_nSelectedSongNumber = songNumber;
146}
147
149{
150 return m_nActiveSongNumber;
151}
152
153inline void Playlist::setActiveSongNumber( int ActiveSongNumber )
154{
155 m_nActiveSongNumber = ActiveSongNumber ;
156}
157
158inline const QString& Playlist::getFilename()
159{
160 return __filename;
161}
162
163inline void Playlist::setFilename( const QString& filename )
164{
165 __filename = filename;
166}
167
169{
170 return m_bIsModified;
171}
172
173inline void Playlist::setIsModified( bool IsModified )
174{
175 m_bIsModified = IsModified;
176}
177
178};
179
180#endif // H2C_PLAYLIST_H
#define H2_OBJECT(name)
Definition Object.h:227
Drumkit info.
Definition Playlist.h:37
void add(Entry *entry)
Definition Playlist.h:133
static Playlist * __instance
Object holding the current Playlist singleton.
Definition Playlist.h:105
void setNextSongByNumber(int SongNumber)
Definition Playlist.cpp:207
std::vector< Entry * > __entries
Definition Playlist.h:108
void setIsModified(bool IsModified)
Definition Playlist.h:173
int getActiveSongNumber()
Definition Playlist.h:148
int m_nSelectedSongNumber
Definition Playlist.h:110
int m_nActiveSongNumber
Definition Playlist.h:111
int getSelectedSongNr()
Definition Playlist.h:138
void save_to(XMLNode *node, bool useRelativePaths)
Definition Playlist.cpp:149
static void create_instance()
If __instance equals 0, a new Playlist singleton will be created and stored in it.
Definition Playlist.cpp:50
void activateSong(int SongNumber)
Definition Playlist.cpp:183
void execScript(int index)
Definition Playlist.cpp:217
void setFilename(const QString &filename)
Definition Playlist.h:163
void setSelectedSongNr(int songNumber)
Definition Playlist.h:143
Entry * get(int idx)
Definition Playlist.h:127
QString toQString(const QString &sPrefix="", bool bShort=true) const override
Formatted string version for debugging purposes.
Definition Playlist.cpp:230
void setActiveSongNumber(int ActiveSongNumber)
Definition Playlist.h:153
QString __filename
Definition Playlist.h:106
bool save_file(const QString &pl_path, const QString &name, bool overwrite, bool useRelativePaths)
Definition Playlist.cpp:131
const QString & getFilename()
Definition Playlist.h:158
static Playlist * get_instance()
Returns a pointer to the current Playlist singleton stored in __instance.
Definition Playlist.h:60
static Playlist * load(const QString &filename, bool useRelativePaths)
Definition Playlist.cpp:166
static Playlist * load_file(const QString &pl_path, bool useRelativePaths)
Definition Playlist.cpp:65
int size() const
Definition Playlist.h:122
bool getIsModified()
Definition Playlist.h:168
bool getSongFilenameByNumber(int songNumber, QString &fileName)
Definition Playlist.cpp:191
XMLNode is a subclass of QDomNode with read and write values methods.
Definition Xml.h:39