Merge df45e6efe0
into fbb266adc2
This commit is contained in:
commit
b307ddfc85
|
@ -173,6 +173,12 @@ Playlist::Playlist(PlaylistBackend* backend, TaskManager* task_manager,
|
||||||
|
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
|
settings.beginGroup(kSettingsGroup);
|
||||||
|
|
||||||
|
grey_unfound_ = settings.value("greyoutdeleted", false).toBool();
|
||||||
|
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
qLog(Debug) << "k_max_scrobble_point"
|
qLog(Debug) << "k_max_scrobble_point"
|
||||||
<< (max_play_count_point_nsecs_ / kNsecPerSec);
|
<< (max_play_count_point_nsecs_ / kNsecPerSec);
|
||||||
}
|
}
|
||||||
|
@ -1223,6 +1229,9 @@ void Playlist::UpdateItems(const SongList& songs) {
|
||||||
} else {
|
} else {
|
||||||
new_item = PlaylistItemPtr(new SongPlaylistItem(song));
|
new_item = PlaylistItemPtr(new SongPlaylistItem(song));
|
||||||
}
|
}
|
||||||
|
if (grey_unfound_ && !song.is_valid()) {
|
||||||
|
new_item->SetForegroundColor(kInvalidSongPriority, kInvalidSongColor);
|
||||||
|
}
|
||||||
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));
|
||||||
// Also update undo actions
|
// Also update undo actions
|
||||||
|
@ -1626,11 +1635,7 @@ void Playlist::ItemsLoaded(QFuture<PlaylistItemList> future) {
|
||||||
|
|
||||||
emit RestoreFinished();
|
emit RestoreFinished();
|
||||||
|
|
||||||
QSettings s;
|
if (grey_unfound_) {
|
||||||
s.beginGroup(kSettingsGroup);
|
|
||||||
|
|
||||||
// should we gray out deleted songs asynchronously on startup?
|
|
||||||
if (s.value("greyoutdeleted", false).toBool()) {
|
|
||||||
QtConcurrent::run(this, &Playlist::InvalidateDeletedSongs);
|
QtConcurrent::run(this, &Playlist::InvalidateDeletedSongs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -471,6 +471,8 @@ class Playlist : public QAbstractListModel {
|
||||||
|
|
||||||
// Cancel async restore if songs are already replaced
|
// Cancel async restore if songs are already replaced
|
||||||
bool cancel_restore_;
|
bool cancel_restore_;
|
||||||
|
|
||||||
|
bool grey_unfound_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// QDataStream& operator <<(QDataStream&, const Playlist*);
|
// QDataStream& operator <<(QDataStream&, const Playlist*);
|
||||||
|
|
|
@ -40,10 +40,7 @@ SongList AsxIniParser::Load(QIODevice* device, const QString& playlist_path,
|
||||||
QString value = line.mid(equals + 1);
|
QString value = line.mid(equals + 1);
|
||||||
|
|
||||||
if (key.startsWith("ref")) {
|
if (key.startsWith("ref")) {
|
||||||
Song song = LoadSong(value, 0, dir);
|
ret << LoadSong(value, 0, dir);
|
||||||
if (song.is_valid()) {
|
|
||||||
ret << song;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,10 +71,7 @@ SongList ASXParser::Load(QIODevice* device, const QString& playlist_path,
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!reader.atEnd() && Utilities::ParseUntilElement(&reader, "entry")) {
|
while (!reader.atEnd() && Utilities::ParseUntilElement(&reader, "entry")) {
|
||||||
Song song = ParseTrack(&reader, dir);
|
ret << ParseTrack(&reader, dir);
|
||||||
if (song.is_valid()) {
|
|
||||||
ret << song;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -111,10 +108,14 @@ Song ASXParser::ParseTrack(QXmlStreamReader* reader, const QDir& dir) const {
|
||||||
return_song:
|
return_song:
|
||||||
Song song = LoadSong(ref, 0, dir);
|
Song song = LoadSong(ref, 0, dir);
|
||||||
|
|
||||||
// Override metadata with what was in the playlist
|
// Override metadata with what was in the playlist if the song is not in the
|
||||||
song.set_title(title);
|
// library.
|
||||||
song.set_artist(artist);
|
if (!song.is_library_song()) {
|
||||||
song.set_album(album);
|
song.set_title(title);
|
||||||
|
song.set_artist(artist);
|
||||||
|
song.set_album(album);
|
||||||
|
}
|
||||||
|
|
||||||
return song;
|
return song;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -227,8 +227,30 @@ SongList CueParser::Load(QIODevice* device, const QString& playlist_path,
|
||||||
// finalize parsing songs
|
// finalize parsing songs
|
||||||
for (int i = 0; i < entries.length(); i++) {
|
for (int i = 0; i < entries.length(); i++) {
|
||||||
CueEntry entry = entries.at(i);
|
CueEntry entry = entries.at(i);
|
||||||
|
Song song;
|
||||||
|
|
||||||
Song song = LoadSong(entry.file, IndexToMarker(entry.index), dir);
|
// override song metadata with metadata from the multi-file cue if the song
|
||||||
|
// isn't found in the library
|
||||||
|
if (files == 1) {
|
||||||
|
song = LoadSong(entry.file, IndexToMarker(entry.index), dir);
|
||||||
|
} else {
|
||||||
|
song = LoadSong(entry.file, 0, dir);
|
||||||
|
|
||||||
|
if (!song.is_library_song()) {
|
||||||
|
song.set_title(entry.title);
|
||||||
|
song.set_artist(entry.PrettyArtist());
|
||||||
|
song.set_album(entry.album);
|
||||||
|
song.set_albumartist(entry.album_artist);
|
||||||
|
song.set_genre(entry.genre);
|
||||||
|
song.set_year(entry.date.toInt());
|
||||||
|
song.set_composer(entry.PrettyComposer());
|
||||||
|
song.set_disc(entry.disc.toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
ret << song;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// cue song has mtime equal to qMax(media_file_mtime, cue_sheet_mtime)
|
// cue song has mtime equal to qMax(media_file_mtime, cue_sheet_mtime)
|
||||||
if (cue_mtime.isValid()) {
|
if (cue_mtime.isValid()) {
|
||||||
|
@ -239,10 +261,8 @@ SongList CueParser::Load(QIODevice* device, const QString& playlist_path,
|
||||||
// overwrite the stuff, we may have read from the file or library, using
|
// overwrite the stuff, we may have read from the file or library, using
|
||||||
// the current .cue metadata
|
// the current .cue metadata
|
||||||
|
|
||||||
// set track number only in single-file mode
|
// set track number
|
||||||
if (files == 1) {
|
song.set_track(i + 1);
|
||||||
song.set_track(i + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// the last TRACK for every FILE gets it's 'end' marker from the media
|
// the last TRACK for every FILE gets it's 'end' marker from the media
|
||||||
// file's
|
// file's
|
||||||
|
|
|
@ -59,15 +59,20 @@ SongList M3UParser::Load(QIODevice* device, const QString& playlist_path,
|
||||||
}
|
}
|
||||||
} else if (!line.isEmpty()) {
|
} else if (!line.isEmpty()) {
|
||||||
Song song = LoadSong(line, 0, dir);
|
Song song = LoadSong(line, 0, dir);
|
||||||
if (!current_metadata.title.isEmpty()) {
|
|
||||||
song.set_title(current_metadata.title);
|
// Override metadata from playlist if the song is not in the library.
|
||||||
}
|
if (!song.is_library_song()) {
|
||||||
if (!current_metadata.artist.isEmpty()) {
|
if (!current_metadata.title.isEmpty()) {
|
||||||
song.set_artist(current_metadata.artist);
|
song.set_title(current_metadata.title);
|
||||||
}
|
}
|
||||||
if (current_metadata.length > 0) {
|
if (!current_metadata.artist.isEmpty()) {
|
||||||
song.set_length_nanosec(current_metadata.length);
|
song.set_artist(current_metadata.artist);
|
||||||
|
}
|
||||||
|
if (current_metadata.length > 0) {
|
||||||
|
song.set_length_nanosec(current_metadata.length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret << song;
|
ret << song;
|
||||||
|
|
||||||
current_metadata = Metadata();
|
current_metadata = Metadata();
|
||||||
|
|
|
@ -43,19 +43,21 @@ SongList PLSParser::Load(QIODevice* device, const QString& playlist_path,
|
||||||
if (key.startsWith("file")) {
|
if (key.startsWith("file")) {
|
||||||
Song song = LoadSong(value, 0, dir);
|
Song song = LoadSong(value, 0, dir);
|
||||||
|
|
||||||
// Use the title and length we've already loaded if any
|
// Use the title and length we've already loaded if any and only if the
|
||||||
if (!songs[n].title().isEmpty()) song.set_title(songs[n].title());
|
// song is not in the library.
|
||||||
if (songs[n].length_nanosec() != -1)
|
if (!song.is_library_song()) {
|
||||||
song.set_length_nanosec(songs[n].length_nanosec());
|
if (!songs[n].title().isEmpty()) song.set_title(songs[n].title());
|
||||||
|
if (songs[n].length_nanosec() != -1)
|
||||||
|
song.set_length_nanosec(songs[n].length_nanosec());
|
||||||
|
}
|
||||||
|
|
||||||
songs[n] = song;
|
songs[n] = song;
|
||||||
} else if (key.startsWith("title")) {
|
} else if (key.startsWith("title")) {
|
||||||
songs[n].set_title(value);
|
if (!songs[n].is_library_song()) songs[n].set_title(value);
|
||||||
} else if (key.startsWith("length")) {
|
} else if (key.startsWith("length")) {
|
||||||
qint64 seconds = value.toLongLong();
|
qint64 seconds = value.toLongLong();
|
||||||
if (seconds > 0) {
|
if ((seconds > 0) && !songs[n].is_library_song())
|
||||||
songs[n].set_length_nanosec(seconds * kNsecPerSec);
|
songs[n].set_length_nanosec(seconds * kNsecPerSec);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,10 +55,7 @@ void WplParser::ParseSeq(const QDir& dir, QXmlStreamReader* reader,
|
||||||
if (name == "media") {
|
if (name == "media") {
|
||||||
QStringRef src = reader->attributes().value("src");
|
QStringRef src = reader->attributes().value("src");
|
||||||
if (!src.isEmpty()) {
|
if (!src.isEmpty()) {
|
||||||
Song song = LoadSong(src.toString(), 0, dir);
|
songs->append(LoadSong(src.toString(), 0, dir));
|
||||||
if (song.is_valid()) {
|
|
||||||
songs->append(song);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Utilities::ConsumeCurrentElement(reader);
|
Utilities::ConsumeCurrentElement(reader);
|
||||||
|
|
|
@ -102,13 +102,17 @@ Song XSPFParser::ParseTrack(QXmlStreamReader* reader, const QDir& dir) const {
|
||||||
return_song:
|
return_song:
|
||||||
Song song = LoadSong(location, 0, dir);
|
Song song = LoadSong(location, 0, dir);
|
||||||
|
|
||||||
// Override metadata with what was in the playlist
|
// If the song is not in the library, fill metadata with what was in the
|
||||||
song.set_title(title);
|
// playlist.
|
||||||
song.set_artist(artist);
|
if (!song.is_library_song()) {
|
||||||
song.set_album(album);
|
song.set_title(title);
|
||||||
song.set_art_manual(art);
|
song.set_artist(artist);
|
||||||
song.set_length_nanosec(nanosec);
|
song.set_album(album);
|
||||||
song.set_track(track_num);
|
song.set_art_manual(art);
|
||||||
|
song.set_length_nanosec(nanosec);
|
||||||
|
song.set_track(track_num);
|
||||||
|
}
|
||||||
|
|
||||||
return song;
|
return song;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue