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

0001 /****************************************************************************************
0002  * Copyright (c) 2011 Ralf Engels <ralf-engels@gmx.de>                                  *
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) version 3 or        *
0007  * any later version accepted by the membership of KDE e.V. (or its successor approved  *
0008  * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of  *
0009  * version 3 of the license.                                                            *
0010  *                                                                                      *
0011  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0012  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0013  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0014  *                                                                                      *
0015  * You should have received a copy of the GNU General Public License along with         *
0016  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0017  ****************************************************************************************/
0018 
0019 #ifndef AMAROK_ALBUMPLAY_BIAS_H
0020 #define AMAROK_ALBUMPLAY_BIAS_H
0021 
0022 #include "dynamic/Bias.h"
0023 #include "dynamic/BiasFactory.h"
0024 #include "widgets/MetaQueryWidget.h"
0025 
0026 namespace Dynamic
0027 {
0028     class AlbumPlayBias : public RandomBias
0029     {
0030         Q_OBJECT
0031 
0032         public:
0033             enum FollowType
0034             {
0035                 DirectlyFollow,
0036                 Follow,
0037                 DontCare
0038             };
0039 
0040             AlbumPlayBias();
0041 
0042             void fromXml( QXmlStreamReader *reader ) override;
0043             void toXml( QXmlStreamWriter *writer ) const override;
0044 
0045             static QString sName();
0046             QString name() const override;
0047             QString toString() const override;
0048 
0049             QWidget* widget( QWidget* parent = nullptr ) override;
0050 
0051             TrackSet matchingTracks( const Meta::TrackList& playlist,
0052                                              int contextCount, int finalCount,
0053                                              const TrackCollectionPtr &universe ) const override;
0054 
0055             bool trackMatches( int position,
0056                                        const Meta::TrackList& playlist,
0057                                        int contextCount ) const override;
0058 
0059             FollowType follow() const;
0060             void setFollow( FollowType value );
0061 
0062         protected Q_SLOTS:
0063             void selectionChanged( int );
0064 
0065         protected:
0066             static QString nameForFollow( FollowType match );
0067             static FollowType followForName( const QString &name );
0068             virtual bool sameTrack( Meta::TrackPtr track1, Meta::TrackPtr track2 ) const;
0069 
0070             FollowType m_follow;
0071 
0072         private:
0073             Q_DISABLE_COPY(AlbumPlayBias)
0074     };
0075 
0076 
0077     class AMAROK_EXPORT AlbumPlayBiasFactory : public Dynamic::AbstractBiasFactory
0078     {
0079         public:
0080             QString i18nName() const override;
0081             QString name() const override;
0082             QString i18nDescription() const override;
0083             BiasPtr createBias() override;
0084     };
0085 
0086 }
0087 
0088 #endif
0089