hydrogen 1.2.3
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-2024 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 static Playlist* load_from( XMLNode* root, QFileInfo& fileInfo, bool useRelativePaths );
121};
122
123inline int Playlist::size() const
124{
125 return __entries.size();
126}
127
129{
130 assert( idx >= 0 && idx < size() );
131 return __entries[ idx ];
132}
133
134inline void Playlist::add( Entry* entry )
135{
136 __entries.push_back( entry );
137}
138
140{
142}
143
144inline void Playlist::setSelectedSongNr( int songNumber )
145{
146 m_nSelectedSongNumber = songNumber;
147}
148
150{
151 return m_nActiveSongNumber;
152}
153
154inline void Playlist::setActiveSongNumber( int ActiveSongNumber )
155{
156 m_nActiveSongNumber = ActiveSongNumber ;
157}
158
159inline const QString& Playlist::getFilename()
160{
161 return __filename;
162}
163
164inline void Playlist::setFilename( const QString& filename )
165{
166 __filename = filename;
167}
168
170{
171 return m_bIsModified;
172}
173
174inline void Playlist::setIsModified( bool IsModified )
175{
176 m_bIsModified = IsModified;
177}
178
179};
180
181#endif // H2C_PLAYLIST_H
#define H2_OBJECT(name)
Definition Object.h:224
Drumkit info.
Definition Playlist.h:37
void add(Entry *entry)
Definition Playlist.h:134
static Playlist * __instance
Object holding the current Playlist singleton.
Definition Playlist.h:105
void setNextSongByNumber(int SongNumber)
Definition Playlist.cpp:197
std::vector< Entry * > __entries
Definition Playlist.h:108
void setIsModified(bool IsModified)
Definition Playlist.h:174
int getActiveSongNumber()
Definition Playlist.h:149
int m_nSelectedSongNumber
Definition Playlist.h:110
int m_nActiveSongNumber
Definition Playlist.h:111
int getSelectedSongNr()
Definition Playlist.h:139
void save_to(XMLNode *node, bool useRelativePaths)
Definition Playlist.cpp:141
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:173
void execScript(int index)
Definition Playlist.cpp:207
void setFilename(const QString &filename)
Definition Playlist.h:164
void setSelectedSongNr(int songNumber)
Definition Playlist.h:144
Entry * get(int idx)
Definition Playlist.h:128
QString toQString(const QString &sPrefix="", bool bShort=true) const override
Formatted string version for debugging purposes.
Definition Playlist.cpp:220
void setActiveSongNumber(int ActiveSongNumber)
Definition Playlist.h:154
QString __filename
Definition Playlist.h:106
bool save_file(const QString &pl_path, const QString &name, bool overwrite, bool useRelativePaths)
Definition Playlist.cpp:123
static Playlist * load_from(XMLNode *root, QFileInfo &fileInfo, bool useRelativePaths)
Definition Playlist.cpp:88
const QString & getFilename()
Definition Playlist.h:159
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:156
static Playlist * load_file(const QString &pl_path, bool useRelativePaths)
Definition Playlist.cpp:65
int size() const
Definition Playlist.h:123
bool getIsModified()
Definition Playlist.h:169
bool getSongFilenameByNumber(int songNumber, QString &fileName)
Definition Playlist.cpp:181
XMLNode is a subclass of QDomNode with read and write values methods.
Definition Xml.h:39