File indexing completed on 2023-05-30 11:30:53

0001 /**
0002  * Copyright (C) 2002-2004 Michael Pyne <mpyne@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 UPCOMINGPLAYLIST_H
0018 #define UPCOMINGPLAYLIST_H
0019 
0020 #include <QPointer>
0021 #include <QMap>
0022 
0023 #include "playlist.h"
0024 #include "playlistitem.h"
0025 
0026 /**
0027  * A class to implement upcoming playlist support in JuK for the "Play Queue".
0028  * After the playlist is created, tracks are played from top to bottom until
0029  * the playlist is empty.  As long as this playlist is alive it will be the
0030  * "playing playlist" under PlaylistBox.
0031  *
0032  * Also, enabling this playlist causes the base Playlist class to add an item
0033  * to the context-menu to add the selected items to this playlist.  If the user
0034  * double-clicks any track to force it to play, it is added to the top of this
0035  * playlist automatically, replacing any currently playing song.
0036  *
0037  * @author Michael Pyne <mpyne@kde.org>
0038  */
0039 class UpcomingPlaylist : public Playlist
0040 {
0041 public:
0042     /**
0043      * Constructor for the UpcomingPlaylist object.  You should only ever have
0044      * one instance of this class.  You should call the initialize() function
0045      * before using the created object.
0046      *
0047      * @see initialize
0048      * @param collection The PlaylistCollection that owns this playlist.
0049      */
0050     explicit UpcomingPlaylist(PlaylistCollection *collection);
0051 
0052     /**
0053      * Appends the given items to the end of the playlist.  Use this function
0054      * instead of createItems() since this function ensures that the items are
0055      * added to the end of the playlist.
0056      *
0057      * @see createItems(const PlaylistItemList &, PlaylistItem *)
0058      * @param itemList The list of PlaylistItems to append.
0059      */
0060     void appendItems(const PlaylistItemList &itemList);
0061 
0062     /**
0063      * Reimplemented to set the playing item in both the source playlist
0064      * and the upcoming playlist.
0065      */
0066     virtual void playNext() override;
0067 
0068     /**
0069      * Reimplemented to remove the item from the Playlist index.
0070      */
0071     virtual void clearItem(PlaylistItem *item) override;
0072 
0073     virtual void addFiles(const QStringList &files, PlaylistItem *after = nullptr) override;
0074 
0075     /**
0076      * Returns a reference to the index between items in the list and the
0077      * playlist that they came from.  This is used to remap the currently
0078      * playing item to the source playlist.
0079      */
0080     QMap<PlaylistItem::Pointer, QPointer<Playlist> > &playlistIndex();
0081 
0082 private:
0083     QMap<PlaylistItem::Pointer, QPointer<Playlist> > m_playlistIndex;
0084 };
0085 
0086 QDataStream &operator<<(QDataStream &s, const UpcomingPlaylist &p);
0087 QDataStream &operator>>(QDataStream &s, UpcomingPlaylist &p);
0088 
0089 #endif /* UPCOMINGPLAYLIST_H */
0090 
0091 // vim: set et sw=4 tw=0 sta: