Changeset View
Changeset View
Standalone View
Standalone View
src/playlistgenerator/Preset.cpp
Show All 17 Lines | |||||
18 | 18 | | |||
19 | #include "Preset.h" | 19 | #include "Preset.h" | ||
20 | 20 | | |||
21 | #include "ConstraintNode.h" | 21 | #include "ConstraintNode.h" | ||
22 | #include "ConstraintFactory.h" | 22 | #include "ConstraintFactory.h" | ||
23 | #include "ConstraintSolver.h" | 23 | #include "ConstraintSolver.h" | ||
24 | #include "constraints/TrackSpreader.h" | 24 | #include "constraints/TrackSpreader.h" | ||
25 | 25 | | |||
26 | #include "core/interfaces/Logger.h" | 26 | #include "core/logger/Logger.h" | ||
27 | #include "core/meta/Meta.h" | 27 | #include "core/meta/Meta.h" | ||
28 | #include "core/support/Components.h" | 28 | #include "core/support/Components.h" | ||
29 | #include "core/support/Debug.h" | 29 | #include "core/support/Debug.h" | ||
30 | #include "core-impl/collections/support/CollectionManager.h" | 30 | #include "core-impl/collections/support/CollectionManager.h" | ||
31 | #include "playlist/PlaylistController.h" | 31 | #include "playlist/PlaylistController.h" | ||
32 | 32 | | |||
33 | #include <KLocalizedString> | 33 | #include <KLocalizedString> | ||
34 | 34 | | |||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | 116 | void APG::Preset::queueSolver() { | |||
124 | * obsolete jobs in the queue, and those that do run properly return | 124 | * obsolete jobs in the queue, and those that do run properly return | ||
125 | * obsolete results. So to avoid that problem, we avoid queueing the job | 125 | * obsolete results. So to avoid that problem, we avoid queueing the job | ||
126 | * until it's ready to run, and then the Weaver will start running it | 126 | * until it's ready to run, and then the Weaver will start running it | ||
127 | * pretty much immediately. -- sth */ | 127 | * pretty much immediately. -- sth */ | ||
128 | 128 | | |||
129 | emit lock( true ); | 129 | emit lock( true ); | ||
130 | 130 | | |||
131 | ConstraintSolver* s = static_cast<ConstraintSolver*>( sender() ); | 131 | ConstraintSolver* s = static_cast<ConstraintSolver*>( sender() ); | ||
132 | Amarok::Components::logger()->newProgressOperation( s, i18n("Generating a new playlist"), s->iterationCount(), s, &ConstraintSolver::requestAbort, Qt::QueuedConnection ); | 132 | Amarok::Logger::newProgressOperation( s, i18n("Generating a new playlist"), s->iterationCount(), s, &ConstraintSolver::requestAbort, Qt::QueuedConnection ); | ||
133 | connect( s, &APG::ConstraintSolver::done, this, &Preset::solverFinished, Qt::QueuedConnection ); | 133 | connect( s, &APG::ConstraintSolver::done, this, &Preset::solverFinished, Qt::QueuedConnection ); | ||
134 | 134 | | |||
135 | m_constraintTreeRoot->addChild( ConstraintTypes::TrackSpreader::createNew( m_constraintTreeRoot ), 0 ); // private mandatory constraint | 135 | m_constraintTreeRoot->addChild( ConstraintTypes::TrackSpreader::createNew( m_constraintTreeRoot ), 0 ); // private mandatory constraint | ||
136 | 136 | | |||
137 | ThreadWeaver::Queue::instance()->enqueue( QSharedPointer<ThreadWeaver::Job>(s) ); | 137 | ThreadWeaver::Queue::instance()->enqueue( QSharedPointer<ThreadWeaver::Job>(s) ); | ||
138 | } | 138 | } | ||
139 | 139 | | |||
140 | void | 140 | void | ||
141 | APG::Preset::solverFinished( ThreadWeaver::JobPointer job ) | 141 | APG::Preset::solverFinished( ThreadWeaver::JobPointer job ) | ||
142 | { | 142 | { | ||
143 | m_constraintTreeRoot->removeChild( 0 ); // remove the TrackSpreader | 143 | m_constraintTreeRoot->removeChild( 0 ); // remove the TrackSpreader | ||
144 | 144 | | |||
145 | ConstraintSolver* solver = static_cast<ConstraintSolver*>( job.data() ); | 145 | ConstraintSolver* solver = static_cast<ConstraintSolver*>( job.data() ); | ||
146 | if ( job->success() ) { | 146 | if ( job->success() ) { | ||
147 | debug() << "Solver" << solver->serial() << "finished successfully"; | 147 | debug() << "Solver" << solver->serial() << "finished successfully"; | ||
148 | if ( !solver->satisfied() ) { | 148 | if ( !solver->satisfied() ) { | ||
149 | Amarok::Components::logger()->longMessage( | 149 | Amarok::Logger::longMessage( | ||
150 | i18n("The playlist generator created a playlist which does not meet all " | 150 | i18n("The playlist generator created a playlist which does not meet all " | ||
151 | "of your constraints. If you are not satisfied with the results, " | 151 | "of your constraints. If you are not satisfied with the results, " | ||
152 | "try loosening or removing some constraints and then generating a " | 152 | "try loosening or removing some constraints and then generating a " | ||
153 | "new playlist.") ); | 153 | "new playlist.") ); | ||
154 | } | 154 | } | ||
155 | The::playlistController()->insertOptioned( solver->getSolution(), Playlist::OnReplacePlaylistAction ); | 155 | The::playlistController()->insertOptioned( solver->getSolution(), Playlist::OnReplacePlaylistAction ); | ||
156 | } else { | 156 | } else { | ||
157 | debug() << "Ignoring results from aborted Solver" << solver->serial(); | 157 | debug() << "Ignoring results from aborted Solver" << solver->serial(); | ||
158 | } | 158 | } | ||
159 | 159 | | |||
160 | emit lock( false ); | 160 | emit lock( false ); | ||
161 | } | 161 | } |