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

0001 /****************************************************************************************
0002  * Copyright (c) 2008-2012 Soren Harward <stharward@gmail.com>                          *
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 APG_TRACKSPREADER_CONSTRAINT
0018 #define APG_TRACKSPREADER_CONSTRAINT
0019 
0020 #include "playlistgenerator/Constraint.h"
0021 
0022 #include "core/meta/forward_declarations.h"
0023 
0024 class Constraint;
0025 class ConstraintFactoryEntry;
0026 
0027 namespace ConstraintTypes {
0028 
0029     /* This constraint tries to prevent duplicate tracks from ending up too
0030      * close to each other in the playlist.  It is a stripped-down constraint
0031      * that is never registered with the ConstraintFactory, has no
0032      * user-configurable options, and cannot be exported to an XML file.  It is
0033      * added to a constraint tree at the root when the Constraint Solver
0034      * starts, and it is then removed from the tree as soon as the Solver
0035      * finishes. -- sth */
0036 
0037     class TrackSpreader : public Constraint {
0038         Q_OBJECT
0039 
0040         public:
0041             static Constraint* createNew( ConstraintNode* );
0042             static ConstraintFactoryEntry* registerMe();
0043 
0044             QWidget* editWidget() const override;
0045             void toXml( QDomDocument&, QDomElement& ) const override;
0046 
0047             QString getName() const override { return QString(); }
0048             
0049             double satisfaction( const Meta::TrackList& ) const override;
0050 
0051         private:
0052             explicit TrackSpreader(ConstraintNode*);
0053 
0054             double distance( const int, const int ) const;
0055     };
0056 } // namespace ConstraintTypes
0057 
0058 #endif // PLAYLIST_GENERATOR_CHECKPOINT