Fix a bug in InsertItems functions that makes Cdda tracks to not be saved/restored correctly when restarting Clementine
This commit is contained in:
parent
1779050fff
commit
7ac9e4c6d1
|
@ -299,6 +299,9 @@ int Song::filesize() const { return d->filesize_; }
|
||||||
Song::FileType Song::filetype() const { return d->filetype_; }
|
Song::FileType Song::filetype() const { return d->filetype_; }
|
||||||
bool Song::is_stream() const { return d->filetype_ == Type_Stream; }
|
bool Song::is_stream() const { return d->filetype_ == Type_Stream; }
|
||||||
bool Song::is_cdda() const { return d->filetype_ == Type_Cdda; }
|
bool Song::is_cdda() const { return d->filetype_ == Type_Cdda; }
|
||||||
|
bool Song::is_library_song() const {
|
||||||
|
return !is_cdda() && !is_stream() && id() != -1;
|
||||||
|
}
|
||||||
const QString& Song::art_automatic() const { return d->art_automatic_; }
|
const QString& Song::art_automatic() const { return d->art_automatic_; }
|
||||||
const QString& Song::art_manual() const { return d->art_manual_; }
|
const QString& Song::art_manual() const { return d->art_manual_; }
|
||||||
const QString& Song::etag() const { return d->etag_; }
|
const QString& Song::etag() const { return d->etag_; }
|
||||||
|
|
|
@ -192,6 +192,8 @@ class Song {
|
||||||
FileType filetype() const;
|
FileType filetype() const;
|
||||||
bool is_stream() const;
|
bool is_stream() const;
|
||||||
bool is_cdda() const;
|
bool is_cdda() const;
|
||||||
|
// Guess if it is a library song using fields set. Might not be 100% reliable.
|
||||||
|
bool is_library_song() const;
|
||||||
|
|
||||||
const QString& art_automatic() const;
|
const QString& art_automatic() const;
|
||||||
const QString& art_manual() const;
|
const QString& art_manual() const;
|
||||||
|
|
|
@ -182,8 +182,8 @@ void CddaSongLoader::AudioCDTagsLoaded(
|
||||||
qobject_cast<MusicBrainzClient*>(sender());
|
qobject_cast<MusicBrainzClient*>(sender());
|
||||||
musicbrainz_client->deleteLater();
|
musicbrainz_client->deleteLater();
|
||||||
SongList songs;
|
SongList songs;
|
||||||
int track_number = 1;
|
|
||||||
if (results.size() == 0) return;
|
if (results.size() == 0) return;
|
||||||
|
int track_number = 1;
|
||||||
for (const MusicBrainzClient::Result& ret : results) {
|
for (const MusicBrainzClient::Result& ret : results) {
|
||||||
Song song;
|
Song song;
|
||||||
song.set_artist(artist);
|
song.set_artist(artist);
|
||||||
|
@ -193,6 +193,8 @@ void CddaSongLoader::AudioCDTagsLoaded(
|
||||||
song.set_track(track_number);
|
song.set_track(track_number);
|
||||||
song.set_year(ret.year_);
|
song.set_year(ret.year_);
|
||||||
song.set_id(track_number);
|
song.set_id(track_number);
|
||||||
|
song.set_filetype(Song::Type_Cdda);
|
||||||
|
song.set_valid(true);
|
||||||
// We need to set url: that's how playlist will find the correct item to
|
// We need to set url: that's how playlist will find the correct item to
|
||||||
// update
|
// update
|
||||||
song.set_url(GetUrlFromTrack(track_number++));
|
song.set_url(GetUrlFromTrack(track_number++));
|
||||||
|
|
|
@ -1082,10 +1082,11 @@ void Playlist::InsertSongsOrLibraryItems(const SongList& songs, int pos,
|
||||||
bool play_now, bool enqueue) {
|
bool play_now, bool enqueue) {
|
||||||
PlaylistItemList items;
|
PlaylistItemList items;
|
||||||
for (const Song& song : songs) {
|
for (const Song& song : songs) {
|
||||||
if (song.id() == -1)
|
if (song.is_library_song()) {
|
||||||
items << PlaylistItemPtr(new SongPlaylistItem(song));
|
|
||||||
else
|
|
||||||
items << PlaylistItemPtr(new LibraryPlaylistItem(song));
|
items << PlaylistItemPtr(new LibraryPlaylistItem(song));
|
||||||
|
} else {
|
||||||
|
items << PlaylistItemPtr(new SongPlaylistItem(song));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
InsertItems(items, pos, play_now, enqueue);
|
InsertItems(items, pos, play_now, enqueue);
|
||||||
}
|
}
|
||||||
|
@ -1155,11 +1156,11 @@ void Playlist::UpdateItems(const SongList& songs) {
|
||||||
// And CD tracks as well (tags are loaded in a second step)
|
// And CD tracks as well (tags are loaded in a second step)
|
||||||
item->Metadata().filetype() == Song::Type_Cdda)) {
|
item->Metadata().filetype() == Song::Type_Cdda)) {
|
||||||
PlaylistItemPtr new_item;
|
PlaylistItemPtr new_item;
|
||||||
if (song.id() == -1) {
|
if (song.is_library_song()) {
|
||||||
new_item = PlaylistItemPtr(new SongPlaylistItem(song));
|
|
||||||
} else {
|
|
||||||
new_item = PlaylistItemPtr(new LibraryPlaylistItem(song));
|
new_item = PlaylistItemPtr(new LibraryPlaylistItem(song));
|
||||||
library_items_by_id_.insertMulti(song.id(), new_item);
|
library_items_by_id_.insertMulti(song.id(), new_item);
|
||||||
|
} else {
|
||||||
|
new_item = PlaylistItemPtr(new SongPlaylistItem(song));
|
||||||
}
|
}
|
||||||
items_[i] = new_item;
|
items_[i] = new_item;
|
||||||
emit dataChanged(index(i, 0), index(i, ColumnCount - 1));
|
emit dataChanged(index(i, 0), index(i, ColumnCount - 1));
|
||||||
|
|
|
@ -116,7 +116,7 @@ void SongLoaderInserter::AudioCDTagsLoaded(bool success) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SongLoaderInserter::InsertSongs() {
|
void SongLoaderInserter::InsertSongs() {
|
||||||
// Insert songs (that haven't been completelly loaded) to allow user to see
|
// Insert songs (that haven't been completely loaded) to allow user to see
|
||||||
// and play them while not loaded completely
|
// and play them while not loaded completely
|
||||||
if (destination_) {
|
if (destination_) {
|
||||||
destination_->InsertSongsOrLibraryItems(songs_, row_, play_now_, enqueue_);
|
destination_->InsertSongsOrLibraryItems(songs_, row_, play_now_, enqueue_);
|
||||||
|
|
Loading…
Reference in New Issue