File indexing completed on 2024-05-05 04:48:43

0001 /****************************************************************************************
0002  * Copyright (c) 2007 Ian Monroe <ian@monroe.nu>                                        *
0003  * Copyright (c) 2008 Soren Harward <stharward@gmail.com>                               *
0004  *                                                                                      *
0005  * This program is free software; you can redistribute it and/or modify it under        *
0006  * the terms of the GNU General Public License as published by the Free Software        *
0007  * Foundation; either version 2 of the License, or (at your option) version 3 or        *
0008  * any later version accepted by the membership of KDE e.V. (or its successor approved  *
0009  * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of  *
0010  * version 3 of the license.                                                            *
0011  *                                                                                      *
0012  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0013  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0014  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0015  *                                                                                      *
0016  * You should have received a copy of the GNU General Public License along with         *
0017  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0018  ****************************************************************************************/
0019 
0020 #ifndef AMAROKPLAYLISTITEM_H
0021 #define AMAROKPLAYLISTITEM_H
0022 
0023 #include "core/meta/forward_declarations.h"
0024 
0025 #include <QMetaType>
0026 
0027 namespace Playlist
0028 {
0029     /** Playlist::Item is used in the playlist model to reference an entry in the playlist.
0030         It combines a track with a unique id and a played state.
0031     */
0032     class Item
0033     {
0034         public:
0035             enum State
0036             {
0037                 Invalid = 0,
0038                 NewlyAdded,
0039                 Unplayed,
0040                 Played
0041             };
0042 
0043             static void listRemove( QList<quint64> &target, QSet<quint64> &removeSet );
0044 
0045             Item();
0046             explicit Item( const Meta::TrackPtr &track );
0047             ~Item();
0048 
0049             const Meta::TrackPtr& track() const;
0050 
0051             State state() const { return m_state; }
0052             void setState ( State s ) { m_state = s; }
0053 
0054             /**
0055              * @return a random number which uniquely identifies this particular
0056              * instance of a track in the playlist
0057              */
0058             quint64 id() const { return m_id; }
0059 
0060         private:
0061             Meta::TrackPtr m_track;
0062             State          m_state;
0063             quint64        m_id;
0064     };
0065 }
0066 
0067 Q_DECLARE_METATYPE( Playlist::Item* )
0068 
0069 #endif