1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-18 20:34:39 +01:00

Merge pull request #4305 from TheUbuntuGuy/master

Fix stop after track.  Fixes #3572
This commit is contained in:
David Sansome 2014-04-26 13:10:23 +10:00
commit 231443f6d1
3 changed files with 9 additions and 13 deletions

View File

@ -190,15 +190,15 @@ void Player::NextItem(Engine::TrackChangeFlags change) {
bool Player::HandleStopAfter() {
if (app_->playlist_manager()->active()->stop_after_current()) {
app_->playlist_manager()->active()->StopAfter(-1);
// Find what the next track would've been, and mark that one as current
// so it plays next time the user presses Play.
const int next_row = app_->playlist_manager()->active()->next_row();
if (next_row != -1) {
app_->playlist_manager()->active()->set_current_row(next_row);
app_->playlist_manager()->active()->set_current_row(next_row, true);
}
app_->playlist_manager()->active()->StopAfter(-1);
Stop();
return true;
}

View File

@ -189,7 +189,6 @@ bool Playlist::column_is_editable(Playlist::Column column) {
bool Playlist::set_column_value(Song& song, Playlist::Column column,
const QVariant& value) {
if (!song.IsEditable()) return false;
switch (column) {
@ -546,9 +545,6 @@ int Playlist::PreviousVirtualIndex(int i, bool ignore_repeat_track) const {
}
int Playlist::next_row(bool ignore_repeat_track) const {
// Did we want to stop after this track?
if (stop_after_.isValid() && current_row() == stop_after_.row()) return -1;
// Any queued items take priority
if (!queue_->is_empty()) {
return queue_->PeekNext();
@ -611,7 +607,7 @@ int Playlist::dynamic_history_length() const {
: 0;
}
void Playlist::set_current_row(int i) {
void Playlist::set_current_row(int i, bool is_stopping) {
QModelIndex old_current_item_index = current_item_index_;
ClearStreamMetadata();
@ -630,7 +626,7 @@ void Playlist::set_current_row(int i) {
old_current_item_index.row(), ColumnCount - 1));
}
if (current_item_index_.isValid()) {
if (current_item_index_.isValid() && !is_stopping) {
InformOfCurrentSongChange();
}
@ -1399,13 +1395,13 @@ void Playlist::ReOrderWithoutUndo(const PlaylistItemList& new_items) {
layoutAboutToBeChanged();
// This is a slow and nasty way to keep the persistent indices
QMap<int, shared_ptr<PlaylistItem> > old_persistent_mappings;
QMap<int, shared_ptr<PlaylistItem>> old_persistent_mappings;
for (const QModelIndex& index : persistentIndexList()) {
old_persistent_mappings[index.row()] = items_[index.row()];
}
items_ = new_items;
QMapIterator<int, shared_ptr<PlaylistItem> > it(old_persistent_mappings);
QMapIterator<int, shared_ptr<PlaylistItem>> it(old_persistent_mappings);
while (it.hasNext()) {
it.next();
for (int col = 0; col < ColumnCount; ++col) {
@ -1445,7 +1441,7 @@ void Playlist::Save() const {
}
namespace {
typedef QFutureWatcher<shared_ptr<PlaylistItem> > PlaylistItemFutureWatcher;
typedef QFutureWatcher<shared_ptr<PlaylistItem>> PlaylistItemFutureWatcher;
}
void Playlist::Restore() {

View File

@ -290,7 +290,7 @@ class Playlist : public QAbstractListModel {
const QModelIndex& parent = QModelIndex());
public slots:
void set_current_row(int index);
void set_current_row(int index, bool is_stopping = false);
void Paused();
void Playing();
void Stopped();