File indexing completed on 2024-05-19 04:49:50

0001 /****************************************************************************************
0002  * Copyright (c) 2008 Seb Ruiz <ruiz@kde.org>                                           *
0003  * Copyright (c) 2008 Soren Harward <stharward@gmail.com>                               *
0004  * Copyright (c) 2010 Nanno Langstraat <langstr@gmail.com>                              *
0005  *                                                                                      *
0006  * This program is free software; you can redistribute it and/or modify it under        *
0007  * the terms of the GNU General Public License as published by the Free Software        *
0008  * Foundation; either version 2 of the License, or (at your option) version 3 or        *
0009  * any later version accepted by the membership of KDE e.V. (or its successor approved  *
0010  * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of  *
0011  * version 3 of the license.                                                            *
0012  *                                                                                      *
0013  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0014  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0015  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0016  *                                                                                      *
0017  * You should have received a copy of the GNU General Public License along with         *
0018  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0019  ****************************************************************************************/
0020 
0021 #ifndef AMAROK_RANDOMTRACKNAVIGATOR_H
0022 #define AMAROK_RANDOMTRACKNAVIGATOR_H
0023 
0024 #include "NonlinearTrackNavigator.h"
0025 
0026 namespace Playlist
0027 {
0028     /**
0029      * Plays a random track in the playlist
0030      */
0031     class RandomTrackNavigator : public NonlinearTrackNavigator
0032     {
0033         Q_OBJECT
0034 
0035         public:
0036             RandomTrackNavigator();
0037 
0038             static const int AVOID_RECENTLY_PLAYED_MAX = 512;    //!< Try to avoid the 'N' most recently played items.
0039 
0040         private:
0041             //! Overrides from 'NonlinearTrackNavigator'
0042             void planOne() override;
0043             void notifyItemsInserted( const QSet<quint64> &insertedItems ) override { Q_UNUSED( insertedItems ); }
0044             void notifyItemsRemoved( const QSet<quint64> &removedItems ) override { Q_UNUSED( removedItems ); }
0045 
0046             QSet<quint64> getRecentHistory( int size );
0047             quint64 chooseRandomItem(const QSet<quint64> &avoidSet );
0048     };
0049 }
0050 
0051 #endif