Modified queue to store tracks to skip
This commit is contained in:
parent
94aa151f1a
commit
048c2d9b9c
|
@ -442,8 +442,9 @@ int Playlist::NextVirtualIndex(int i, bool ignore_repeat_track) const {
|
|||
++i;
|
||||
|
||||
// Advance i until we find any track that is in the filter
|
||||
while (i < virtual_items_.count() && !FilterContainsVirtualIndex(i))
|
||||
++i;
|
||||
while ((i < virtual_items_.count() && !FilterContainsVirtualIndex(i)) || queue_->SkipSourceRow(i)) {
|
||||
++i;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,17 @@ bool Queue::ContainsSourceRow(int source_row) const {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Queue::SkipSourceRow(int source_row) const {
|
||||
qDebug() << "Entrou aqui";
|
||||
qDebug() << source_row;
|
||||
for (int i=0 ; i<skipped_indexes_.count() ; ++i) {
|
||||
qDebug() << skipped_indexes_[i].row();
|
||||
if (skipped_indexes_[i].row() == source_row)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QModelIndex Queue::mapToSource(const QModelIndex& proxy_index) const {
|
||||
if (!proxy_index.isValid())
|
||||
return QModelIndex();
|
||||
|
@ -156,6 +167,26 @@ void Queue::ToggleTracks(const QModelIndexList &source_indexes) {
|
|||
}
|
||||
}
|
||||
|
||||
void Queue::SkipTracks(const QModelIndexList &source_indexes) {
|
||||
qDebug() << "Enqueuing";
|
||||
foreach (const QModelIndex& source_index, source_indexes) {
|
||||
QModelIndex proxy_index = mapFromSource(source_index);
|
||||
if (proxy_index.isValid()) {
|
||||
// Dequeue the track
|
||||
const int row = proxy_index.row();
|
||||
beginRemoveRows(QModelIndex(), row, row);
|
||||
skipped_indexes_.removeAt(row);
|
||||
endRemoveRows();
|
||||
} else {
|
||||
// Enqueue the track
|
||||
const int row = source_indexes_.count();
|
||||
beginInsertRows(QModelIndex(), row, row);
|
||||
skipped_indexes_ << QPersistentModelIndex(source_index);
|
||||
endInsertRows();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int Queue::PositionOf(const QModelIndex& source_index) const {
|
||||
return mapFromSource(source_index).row();
|
||||
}
|
||||
|
|
|
@ -34,11 +34,13 @@ public:
|
|||
bool is_empty() const;
|
||||
int PositionOf(const QModelIndex& source_index) const;
|
||||
bool ContainsSourceRow(int source_row) const;
|
||||
bool SkipSourceRow(int source_row) const;
|
||||
int PeekNext() const;
|
||||
|
||||
// Modify the queue
|
||||
int TakeNext();
|
||||
void ToggleTracks(const QModelIndexList& source_indexes);
|
||||
void SkipTracks(const QModelIndexList& source_indexes);
|
||||
void Clear();
|
||||
void Move(const QList<int>& proxy_rows, int pos);
|
||||
void MoveUp(int row);
|
||||
|
@ -69,6 +71,8 @@ private slots:
|
|||
|
||||
private:
|
||||
QList<QPersistentModelIndex> source_indexes_;
|
||||
QList<QPersistentModelIndex> skipped_indexes_;
|
||||
|
||||
};
|
||||
|
||||
#endif // QUEUE_H
|
||||
|
|
Loading…
Reference in New Issue