diff --git a/ChangeLog b/ChangeLog index 123d90a99..7a263a624 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ 5. Add option to group albums with multiple artists under Various Artists. 6. When checking whether a song exists in device, or library, need to also check 'single tracks' and 'multiple artist' groupings - if these have been enabled. +7. Update playlists if modified by another client. 0.5.1 ----- diff --git a/models/playlistsmodel.cpp b/models/playlistsmodel.cpp index e475abfa8..19a36794a 100644 --- a/models/playlistsmodel.cpp +++ b/models/playlistsmodel.cpp @@ -476,7 +476,7 @@ void PlaylistsModel::setPlaylists(const QList &playlists) } beginResetModel(); foreach (const Playlist &p, playlists) { - items.append(new PlaylistItem(p.name, allocateKey())); + items.append(new PlaylistItem(p, allocateKey())); } endResetModel(); updateItemMenu(); @@ -495,6 +495,14 @@ void PlaylistsModel::setPlaylists(const QList &playlists) foreach (const Playlist &p, playlists) { retreived.insert(p.name); + PlaylistItem *pl=getPlaylist(p.name); + + if (pl && pl->lastModifiedlastModified=p.lastModified; + if (pl->loaded) { + emit playlistInfo(pl->name); + } + } } removed=existing-retreived; @@ -516,7 +524,10 @@ void PlaylistsModel::setPlaylists(const QList &playlists) if (added.count()) { beginInsertRows(parent, items.count(), items.count()+added.count()-1); foreach (const QString &p, added) { - items.append(new PlaylistItem(p, allocateKey())); + int idx=playlists.indexOf(Playlist(p)); + if (-1!=idx) { + items.append(new PlaylistItem(playlists.at(idx), allocateKey())); + } } endInsertRows(); } diff --git a/models/playlistsmodel.h b/models/playlistsmodel.h index f666801ee..3b72fc17d 100644 --- a/models/playlistsmodel.h +++ b/models/playlistsmodel.h @@ -57,7 +57,7 @@ public: struct PlaylistItem : public Item { PlaylistItem(quint32 k) : loaded(false), time(0), key(k) { } - PlaylistItem(const QString &n, quint32 k) : name(n), loaded(false), time(0), key(k) { } + PlaylistItem(const Playlist &pl, quint32 k) : name(pl.name), loaded(false), time(0), key(k), lastModified(pl.lastModified) { } virtual ~PlaylistItem(); bool isPlaylist() { return true; } void updateGenres(); @@ -70,6 +70,7 @@ public: QSet genres; quint32 time; quint32 key; + QDateTime lastModified; }; static PlaylistsModel * self(); diff --git a/mpd/mpdparseutils.cpp b/mpd/mpdparseutils.cpp index 84b0be826..d42f75d0e 100644 --- a/mpd/mpdparseutils.cpp +++ b/mpd/mpdparseutils.cpp @@ -91,11 +91,7 @@ QList MPDParseUtils::parsePlaylists(const QByteArray &data) tokens = lines.at(i).split(':'); if (tokens.at(0) == "Last-Modified") { - QByteArray lastModified(tokens.at(1)); - lastModified += tokens.at(2); - lastModified += tokens.at(3); - playlist.lastModified.fromString(lastModified, Qt::ISODate); - + playlist.lastModified=QDateTime::fromString(tokens.at(1).trimmed()+':'+tokens.at(2)+':'+tokens.at(3), Qt::ISODate); playlists.append(playlist); } }