mirror of
https://github.com/clementine-player/Clementine
synced 2025-02-02 20:36:44 +01:00
Initial playlist implementation
This commit is contained in:
parent
e52c7f6475
commit
6e387c2578
@ -151,6 +151,18 @@ void Queue::ToggleTracks(const QModelIndexList& source_indexes) {
|
||||
}
|
||||
}
|
||||
|
||||
void Queue::InsertFirst(const QModelIndexList& source_indexes) {
|
||||
const int rows = source_indexes.count();
|
||||
// Enqueue the tracks at the beginning
|
||||
beginInsertRows(QModelIndex(), 0, rows - 1);
|
||||
int offset = 0;
|
||||
for (const QModelIndex& source_index : source_indexes) {
|
||||
source_indexes_.insert(offset, QPersistentModelIndex(source_index));
|
||||
offset++;
|
||||
}
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
int Queue::PositionOf(const QModelIndex& source_index) const {
|
||||
return mapFromSource(source_index).row();
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ class Queue : public QAbstractProxyModel {
|
||||
// Modify the queue
|
||||
int TakeNext();
|
||||
void ToggleTracks(const QModelIndexList& source_indexes);
|
||||
void InsertFirst(const QModelIndexList& source_indexes);
|
||||
void Clear();
|
||||
void Move(const QList<int>& proxy_rows, int pos);
|
||||
void MoveUp(int row);
|
||||
|
@ -677,6 +677,9 @@ MainWindow::MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd,
|
||||
playlist_queue_ = playlist_menu_->addAction("", this, SLOT(PlaylistQueue()));
|
||||
playlist_queue_->setShortcut(QKeySequence("Ctrl+D"));
|
||||
ui_->playlist->addAction(playlist_queue_);
|
||||
playlist_queue_play_next_ = playlist_menu_->addAction("", this, SLOT(PlaylistQueuePlayNext()));
|
||||
playlist_queue_play_next_->setShortcut(QKeySequence("Ctrl+Shift+D"));
|
||||
ui_->playlist->addAction(playlist_queue_play_next_);
|
||||
playlist_skip_ = playlist_menu_->addAction("", this, SLOT(PlaylistSkip()));
|
||||
ui_->playlist->addAction(playlist_skip_);
|
||||
playlist_menu_->addSeparator();
|
||||
@ -1760,6 +1763,11 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos,
|
||||
else
|
||||
playlist_queue_->setText(tr("Toggle queue status"));
|
||||
|
||||
if (in_queue == 0 && not_in_queue == 1)
|
||||
playlist_queue_play_next_->setText(tr("Play next"));
|
||||
else if (in_queue == 0 && not_in_queue > 1)
|
||||
playlist_queue_play_next_->setText(tr("Play selected tracks next"));
|
||||
|
||||
if (in_skipped == 1 && not_in_skipped == 0)
|
||||
playlist_skip_->setText(tr("Unskip track"));
|
||||
else if (in_skipped > 1 && not_in_skipped == 0)
|
||||
@ -2500,6 +2508,17 @@ void MainWindow::PlaylistQueue() {
|
||||
app_->playlist_manager()->current()->queue()->ToggleTracks(indexes);
|
||||
}
|
||||
|
||||
void MainWindow::PlaylistQueuePlayNext() {
|
||||
QModelIndexList indexes;
|
||||
for (const QModelIndex& proxy_index :
|
||||
ui_->playlist->view()->selectionModel()->selectedRows()) {
|
||||
indexes << app_->playlist_manager()->current()->proxy()->mapToSource(
|
||||
proxy_index);
|
||||
}
|
||||
|
||||
app_->playlist_manager()->current()->queue()->InsertFirst(indexes);
|
||||
}
|
||||
|
||||
void MainWindow::PlaylistSkip() {
|
||||
QModelIndexList indexes;
|
||||
for (const QModelIndex& proxy_index :
|
||||
|
@ -162,6 +162,7 @@ signals:
|
||||
void PlaylistPlay();
|
||||
void PlaylistStopAfter();
|
||||
void PlaylistQueue();
|
||||
void PlaylistQueuePlayNext();
|
||||
void PlaylistSkip();
|
||||
void PlaylistRemoveCurrent();
|
||||
void PlaylistEditFinished(const QModelIndex& index);
|
||||
@ -361,6 +362,7 @@ signals:
|
||||
QAction* playlist_delete_;
|
||||
QAction* playlist_open_in_browser_;
|
||||
QAction* playlist_queue_;
|
||||
QAction* playlist_queue_play_next_;
|
||||
QAction* playlist_skip_;
|
||||
QAction* playlist_add_to_another_;
|
||||
QList<QAction*> playlistitem_actions_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user