File indexing completed on 2024-05-19 04:50:00
0001 /**************************************************************************************** 0002 * Copyright (c) 2008 Nikolaj Hald Nielsen <nhn@kde.org> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #ifndef SQLPLAYLISTGROUP_H 0018 #define SQLPLAYLISTGROUP_H 0019 0020 #include "core/meta/forward_declarations.h" 0021 #include "SqlPlaylist.h" 0022 0023 #include <QString> 0024 #include <QStringList> 0025 0026 #include "AmarokSharedPointer.h" 0027 namespace Playlists 0028 { 0029 class SqlPlaylistGroup; 0030 typedef AmarokSharedPointer<SqlPlaylistGroup> SqlPlaylistGroupPtr; 0031 typedef QList<SqlPlaylistGroupPtr> SqlPlaylistGroupList; 0032 0033 /** 0034 A class for allowing a "folder structure" in the playlist browser and the database. Takes care of reading and writing itself to the database. 0035 0036 @author Nikolaj Hald Nielsen <nhn@kde.org> 0037 */ 0038 class SqlPlaylistGroup : public virtual QSharedData 0039 { 0040 public: 0041 SqlPlaylistGroup( const QStringList &dbResultRow, 0042 const SqlPlaylistGroupPtr &parent, PlaylistProvider *provider ); 0043 SqlPlaylistGroup( const QString &name, 0044 const SqlPlaylistGroupPtr &parent, PlaylistProvider *provider ); 0045 0046 ~SqlPlaylistGroup(); 0047 0048 QString name() const { return m_name; } 0049 QString description() const { return m_description; } 0050 0051 SqlPlaylistGroupPtr parent() const { return m_parent; } 0052 0053 void setName( const QString &name ); 0054 void setParent( const Playlists::SqlPlaylistGroupPtr &parent ); 0055 void setDescription( const QString &description ); 0056 0057 int id() const { return m_dbId; } 0058 void save(); 0059 void removeFromDb(); 0060 void clear(); 0061 SqlPlaylistGroupList allChildGroups() const; 0062 SqlPlaylistList allChildPlaylists() const; 0063 0064 //transitional: this class is deprecated but we do need access to the children until 0065 //the database changes to using labels for playlist groups. 0066 friend class SqlUserPlaylistProvider; 0067 0068 private: 0069 SqlPlaylistGroupList childSqlGroups() const; 0070 SqlPlaylistList childSqlPlaylists() const; 0071 0072 int m_dbId; 0073 mutable bool m_hasFetchedChildGroups; 0074 mutable bool m_hasFetchedChildPlaylists; 0075 mutable SqlPlaylistGroupList m_childGroups; 0076 mutable SqlPlaylistList m_childPlaylists; 0077 QString m_name; 0078 QString m_description; 0079 SqlPlaylistGroupPtr m_parent; 0080 0081 PlaylistProvider *m_provider; 0082 }; 0083 } 0084 0085 Q_DECLARE_METATYPE( Playlists::SqlPlaylistGroupPtr ) 0086 Q_DECLARE_METATYPE( Playlists::SqlPlaylistGroupList ) 0087 0088 #endif