mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-16 11:19:18 +01:00
Make the player actually use the queue order. Fixes issue #24.
This commit is contained in:
parent
cbc6169ea8
commit
aa2d69f1bf
@ -348,6 +348,11 @@ int Playlist::next_index() const {
|
||||
if (stop_after_.isValid() && current_index() == stop_after_.row())
|
||||
return -1;
|
||||
|
||||
// Any queued items take priority
|
||||
if (!queue_->is_empty()) {
|
||||
return queue_->PeekNext();
|
||||
}
|
||||
|
||||
int next_virtual_index = NextVirtualIndex(current_virtual_index_);
|
||||
if (next_virtual_index >= virtual_items_.count()) {
|
||||
// We've gone off the end of the playlist.
|
||||
@ -419,6 +424,10 @@ void Playlist::set_current_index(int i) {
|
||||
emit CurrentSongChanged(current_item_metadata());
|
||||
}
|
||||
|
||||
if (current_item_index_.row() == queue_->PeekNext()) {
|
||||
queue_->TakeNext();
|
||||
}
|
||||
|
||||
// Update the virtual index
|
||||
if (i == -1)
|
||||
current_virtual_index_ = -1;
|
||||
|
@ -300,5 +300,21 @@ Qt::ItemFlags Queue::flags(const QModelIndex &index) const {
|
||||
flags |= Qt::ItemIsDropEnabled;
|
||||
|
||||
return flags;
|
||||
|
||||
}
|
||||
|
||||
int Queue::PeekNext() const {
|
||||
if (source_indexes_.isEmpty())
|
||||
return -1;
|
||||
return source_indexes_.first().row();
|
||||
}
|
||||
|
||||
int Queue::TakeNext() {
|
||||
if (source_indexes_.isEmpty())
|
||||
return -1;
|
||||
|
||||
beginRemoveRows(QModelIndex(), 0, 0);
|
||||
int ret = source_indexes_.takeFirst().row();
|
||||
endRemoveRows();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -38,9 +38,10 @@ public:
|
||||
// Query the queue
|
||||
bool is_empty() const;
|
||||
int PositionOf(const QModelIndex& source_index) const;
|
||||
int PeekNext() const;
|
||||
|
||||
// Modify the queue
|
||||
QModelIndex TakeNext();
|
||||
int TakeNext();
|
||||
void ToggleTracks(const QModelIndexList& source_indexes);
|
||||
void Clear();
|
||||
void Move(const QList<int>& proxy_rows, int pos);
|
||||
|
Loading…
Reference in New Issue
Block a user