Add an "Expand" button to add more tracks to a dynamic playlist. Fixes issue 1268

This commit is contained in:
HyperQuantum 2011-11-10 11:21:41 +00:00 committed by David Sansome
parent 128b91d60d
commit 94a7ceb898
7 changed files with 654 additions and 561 deletions

View File

@ -24,6 +24,7 @@ DynamicPlaylistControls::DynamicPlaylistControls(QWidget *parent)
{
ui_->setupUi(this);
connect(ui_->expand, SIGNAL(clicked()), SIGNAL(Expand()));
connect(ui_->repopulate, SIGNAL(clicked()), SIGNAL(Repopulate()));
connect(ui_->off, SIGNAL(clicked()), SIGNAL(TurnOff()));
}

View File

@ -30,6 +30,7 @@ public:
~DynamicPlaylistControls();
signals:
void Expand();
void Repopulate();
void TurnOff();

View File

@ -59,6 +59,13 @@
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="expand">
<property name="text">
<string>Expand</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="repopulate">
<property name="text">

View File

@ -576,11 +576,7 @@ void Playlist::set_current_row(int i) {
// Add more dynamic playlist items
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)));
connect(inserter, SIGNAL(PlayRequested(QModelIndex)), SIGNAL(PlayRequested(QModelIndex)));
inserter->Load(this, -1, false, false, dynamic_playlist_, count);
InsertDynamicItems(count);
}
// Remove the first item
@ -592,6 +588,14 @@ void Playlist::set_current_row(int i) {
UpdateScrobblePoint();
}
void Playlist::InsertDynamicItems(int count) {
GeneratorInserter* inserter = new GeneratorInserter(task_manager_, library_, this);
connect(inserter, SIGNAL(Error(QString)), SIGNAL(LoadTracksError(QString)));
connect(inserter, SIGNAL(PlayRequested(QModelIndex)), SIGNAL(PlayRequested(QModelIndex)));
inserter->Load(this, -1, false, false, dynamic_playlist_, count);
}
Qt::ItemFlags Playlist::flags(const QModelIndex &index) const {
Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
@ -1498,6 +1502,13 @@ void Playlist::RepopulateDynamicPlaylist() {
InsertSmartPlaylist(dynamic_playlist_);
}
void Playlist::ExpandDynamicPlaylist() {
if (!dynamic_playlist_)
return;
InsertDynamicItems(5);
}
void Playlist::RemoveItemsNotInQueue() {
if (queue_->is_empty()) {
RemoveItemsWithoutUndo(0, items_.count());

View File

@ -276,6 +276,7 @@ class Playlist : public QAbstractListModel {
void ShuffleModeChanged(PlaylistSequence::ShuffleMode mode);
void ExpandDynamicPlaylist();
void RepopulateDynamicPlaylist();
void TurnOffDynamicPlaylist();
@ -308,6 +309,8 @@ class Playlist : public QAbstractListModel {
template<typename T>
void InsertSongItems(const SongList& songs, int pos, bool play_now, bool enqueue);
void InsertDynamicItems(int count) ;
// Modify the playlist without changing the undo stack. These are used by
// our friends in PlaylistUndoCommands
void InsertItemsWithoutUndo(const PlaylistItemList& items, int pos,

View File

@ -175,6 +175,8 @@ void PlaylistView::SetPlaylist(Playlist* playlist) {
this, SLOT(DynamicModeChanged(bool)));
disconnect(playlist_, SIGNAL(destroyed()), this, SLOT(PlaylistDestroyed()));
disconnect(dynamic_controls_, SIGNAL(Expand()),
playlist_, SLOT(ExpandDynamicPlaylist()));
disconnect(dynamic_controls_, SIGNAL(Repopulate()),
playlist_, SLOT(RepopulateDynamicPlaylist()));
disconnect(dynamic_controls_, SIGNAL(TurnOff()),
@ -193,6 +195,7 @@ void PlaylistView::SetPlaylist(Playlist* playlist) {
connect(playlist_, SIGNAL(CurrentSongChanged(Song)), SLOT(MaybeAutoscroll()));
connect(playlist_, SIGNAL(DynamicModeChanged(bool)), SLOT(DynamicModeChanged(bool)));
connect(playlist_, SIGNAL(destroyed()), SLOT(PlaylistDestroyed()));
connect(dynamic_controls_, SIGNAL(Expand()), playlist_, SLOT(ExpandDynamicPlaylist()));
connect(dynamic_controls_, SIGNAL(Repopulate()), playlist_, SLOT(RepopulateDynamicPlaylist()));
connect(dynamic_controls_, SIGNAL(TurnOff()), playlist_, SLOT(TurnOffDynamicPlaylist()));
}

File diff suppressed because it is too large Load Diff