1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-18 20:40:43 +01:00

Make dynamic playlists use the limit specified in the smart playlist dialog. Thanks google@robbertkrebbers.nl. Fixes issue 1082. Fixes issue 1192.

This commit is contained in:
David Sansome 2011-05-14 13:44:10 +00:00
parent 792352be3b
commit e2c6526840
7 changed files with 20 additions and 22 deletions

View File

@ -575,7 +575,7 @@ void Playlist::set_current_row(int i) {
using smart_playlists::Generator;
// Add more dynamic playlist items
const int count = current_item_index_.row() + Generator::kDynamicFuture - items_.count();
const int count = current_item_index_.row() + dynamic_playlist_->GetDynamicFuture() - items_.count();
if (count > 0) {
GeneratorInserter* inserter = new GeneratorInserter(task_manager_, library_, this);
connect(inserter, SIGNAL(Error(QString)), SIGNAL(LoadTracksError(QString)));
@ -585,7 +585,7 @@ void Playlist::set_current_row(int i) {
}
// Remove the first item
if (current_item_index_.row() > Generator::kDynamicHistory) {
if (current_item_index_.row() > dynamic_playlist_->GetDynamicHistory()) {
RemoveItemsWithoutUndo(0, 1);
}
}

View File

@ -25,8 +25,8 @@
namespace smart_playlists {
const int Generator::kDefaultLimit = 20;
const int Generator::kDynamicHistory = 5;
const int Generator::kDynamicFuture = 15;
const int Generator::kDefaultDynamicHistory = 5;
const int Generator::kDefaultDynamicFuture = 15;
Generator::Generator()
: QObject(NULL),

View File

@ -34,8 +34,8 @@ public:
Generator();
static const int kDefaultLimit;
static const int kDynamicHistory;
static const int kDynamicFuture;
static const int kDefaultDynamicHistory;
static const int kDefaultDynamicFuture;
// Creates a new Generator of the given type
static boost::shared_ptr<Generator> Create(const QString& type);
@ -61,13 +61,15 @@ public:
// If the generator can be used as a dynamic playlist then GenerateMore
// should return the next tracks in the sequence. The subclass should
// remember the last kDynamicHistory + kDynamicFuture tracks and ensure that
// remember the last GetDynamicHistory() + GetDynamicFuture() tracks and ensure that
// the tracks returned from this method are not in that set.
virtual bool is_dynamic() const { return false; }
virtual void set_dynamic(bool dynamic) {}
// Called from non-UI thread.
virtual PlaylistItemList GenerateMore(int count) { return PlaylistItemList(); }
virtual int GetDynamicHistory () { return kDefaultDynamicHistory; }
virtual int GetDynamicFuture () { return kDefaultDynamicFuture; }
signals:
void Error(const QString& message);

View File

@ -68,8 +68,6 @@ PlaylistItemList QueryGenerator::GenerateMore(int count) {
search_copy.id_not_in_ = previous_ids_;
if (count) {
search_copy.limit_ = count;
} else if (dynamic_) {
search_copy.limit_ = kDynamicFuture;
}
if (search_copy.sort_type_ != Search::Sort_Random) {
@ -84,7 +82,7 @@ PlaylistItemList QueryGenerator::GenerateMore(int count) {
backend_->songs_table(), song));
previous_ids_ << song.id();
if (previous_ids_.count() > kDynamicFuture + kDynamicHistory)
if (previous_ids_.count() > GetDynamicFuture() + GetDynamicHistory())
previous_ids_.removeFirst();
}
return items;

View File

@ -40,6 +40,7 @@ public:
void set_dynamic(bool dynamic) { dynamic_ = dynamic; }
Search search() const { return search_; }
int GetDynamicFuture () { return search_.limit_; }
private:
Search search_;

View File

@ -40,7 +40,7 @@
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>In dynamic mode new tracks will be chosen and added to the playlist every time a song finishes. Enabling dynamic mode will ignore any size limit you set on the playlist.</string>
<string>In dynamic mode new tracks will be chosen and added to the playlist every time a song finishes.</string>
</property>
<property name="wordWrap">
<bool>true</bool>

View File

@ -11,10 +11,10 @@ msgstr ""
"PO-Revision-Date: 2011-04-12 21:14+0000\n"
"Last-Translator: Cugel <Unknown>\n"
"Language-Team: Dutch <nl@li.org>\n"
"Language: nl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: nl\n"
"X-Launchpad-Export-Date: 2011-04-13 05:02+0000\n"
"X-Generator: Launchpad (build 12735)\n"
@ -85,15 +85,15 @@ msgstr "%1 nummers"
msgid "%1: Wiimotedev module"
msgstr "%1: Wiimotedev module"
#, c-format, qt-plural-format
#, c-format
msgid "%n failed"
msgstr "%n mislukt"
#, c-format, qt-plural-format
#, c-format
msgid "%n finished"
msgstr "%n voltooid"
#, c-format, qt-plural-format
#, c-format
msgid "%n remaining"
msgstr "%n te gaan"
@ -1378,13 +1378,10 @@ msgstr "Beeldformaat (*.png *.jpg *.jpeg *.bmp *.xpm *.pbm *.ppm *.xbm)"
msgid ""
"In dynamic mode new tracks will be chosen and added to the playlist every "
"time a song finishes. Enabling dynamic mode will ignore any size limit you "
"set on the playlist."
"time a song finishes."
msgstr ""
"In 'dynamische modus' worden nieuwe nummers gekozen en aan de afspeellijst "
"toegevoegd op het moment dat een nummer eindigt. Het activeren van deze "
"modus negeert eventuele limieten die voor het aantal nummers in de "
"afspeellijst zijn ingesteld."
"toegevoegd op het moment dat een nummer eindigt."
msgid "Inbox"
msgstr ""
@ -3129,7 +3126,7 @@ msgstr "Z-A"
msgid "Zero"
msgstr "Nul"
#, c-format, qt-plural-format
#, c-format
msgid "add %n songs"
msgstr "%n nummers toevoegen"
@ -3218,7 +3215,7 @@ msgstr "opties"
msgid "press enter"
msgstr ""
#, c-format, qt-plural-format
#, c-format
msgid "remove %n songs"
msgstr "%n nummers verwijderen"