Fix playlist shuffle
- Shuffle all indexes - Use persistent indexes to store play history - Update virtual items to keep original shuffle order when the playlist is reordered - Make sure to always set virtual index on manual shuffle - Ignore repeat and shuffle when dynamic playlist is activated Fixes #707 Fixes #1381 Fixes #1366 Fixes #1353
This commit is contained in:
@@ -182,8 +182,9 @@ class Playlist : public QAbstractListModel {
|
||||
int current_row() const;
|
||||
int last_played_row() const;
|
||||
void reset_last_played() { last_played_item_index_ = QPersistentModelIndex(); }
|
||||
int next_row(const bool ignore_repeat_track = false) const;
|
||||
int previous_row(const bool ignore_repeat_track = false) const;
|
||||
void reset_played_indexes() { played_indexes_.clear(); }
|
||||
int next_row(const bool ignore_repeat_track = false);
|
||||
int previous_row(const bool ignore_repeat_track = false);
|
||||
|
||||
const QModelIndex current_index() const;
|
||||
|
||||
@@ -211,6 +212,9 @@ class Playlist : public QAbstractListModel {
|
||||
void set_sequence(PlaylistSequence *v);
|
||||
PlaylistSequence *sequence() const { return playlist_sequence_; }
|
||||
|
||||
PlaylistSequence::ShuffleMode ShuffleMode() const { return playlist_sequence_ && !is_dynamic() ? playlist_sequence_->shuffle_mode() : PlaylistSequence::ShuffleMode::Off; }
|
||||
PlaylistSequence::RepeatMode RepeatMode() const { return playlist_sequence_ && !is_dynamic() ? playlist_sequence_->repeat_mode() : PlaylistSequence::RepeatMode::Off; }
|
||||
|
||||
QUndoStack *undo_stack() const { return undo_stack_; }
|
||||
|
||||
bool scrobbled() const { return scrobbled_; }
|
||||
@@ -363,6 +367,8 @@ class Playlist : public QAbstractListModel {
|
||||
void Save();
|
||||
|
||||
private:
|
||||
static const int kMaxPlayedIndexes;
|
||||
|
||||
bool is_loading_;
|
||||
PlaylistFilter *filter_;
|
||||
Queue *queue_;
|
||||
@@ -382,6 +388,8 @@ class Playlist : public QAbstractListModel {
|
||||
// Contains the indices into items_ in the order that they will be played.
|
||||
QList<int> virtual_items_;
|
||||
|
||||
QList<QPersistentModelIndex> played_indexes_;
|
||||
|
||||
// A map of collection ID to playlist item - for fast lookups when collection items change.
|
||||
QMultiMap<int, PlaylistItemPtr> collection_items_by_id_;
|
||||
|
||||
@@ -391,8 +399,6 @@ class Playlist : public QAbstractListModel {
|
||||
bool current_is_paused_;
|
||||
int current_virtual_index_;
|
||||
|
||||
bool is_shuffled_;
|
||||
|
||||
PlaylistSequence *playlist_sequence_;
|
||||
|
||||
// Hack to stop QTreeView::setModel sorting the playlist
|
||||
|
||||
Reference in New Issue
Block a user