summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-12-01 20:00:09 +0100
committerCarl Hetherington <cth@carlh.net>2022-12-01 20:00:09 +0100
commita733da8088152a2487691629753fe8a2addfa5a3 (patch)
tree789f3ddf26e56fb7733614f655474d7af0e3e1ed
parent704e1112538d809fd55bd7f25385eaa5d064966c (diff)
Save playlist when content is added, moved or removed.
-rw-r--r--src/lib/spl.h15
-rw-r--r--src/tools/dcpomatic_playlist.cc11
2 files changed, 25 insertions, 1 deletions
diff --git a/src/lib/spl.h b/src/lib/spl.h
index b002a0882..f55a9fe1f 100644
--- a/src/lib/spl.h
+++ b/src/lib/spl.h
@@ -114,6 +114,21 @@ public:
Changed(Change::NAME);
}
+ void add(SPLEntry e) {
+ SPL::add(e);
+ Changed(Change::CONTENT);
+ }
+
+ void remove(std::size_t index) {
+ SPL::remove(index);
+ Changed(Change::CONTENT);
+ }
+
+ void swap(size_t a, size_t b) {
+ SPL::swap(a, b);
+ Changed(Change::CONTENT);
+ }
+
boost::signals2::signal<void (Change)> Changed;
};
diff --git a/src/tools/dcpomatic_playlist.cc b/src/tools/dcpomatic_playlist.cc
index 5a8ee9126..5368cb3af 100644
--- a/src/tools/dcpomatic_playlist.cc
+++ b/src/tools/dcpomatic_playlist.cc
@@ -176,7 +176,9 @@ private:
return;
}
- if (change == SignalSPL::Change::NAME) {
+ switch (change) {
+ case SignalSPL::Change::NAME:
+ {
int N = 0;
for (auto i: _playlists) {
if (i == playlist) {
@@ -184,6 +186,13 @@ private:
}
++N;
}
+ break;
+ }
+ case SignalSPL::Change::CONTENT:
+ if (auto dir = Config::instance()->player_playlist_directory()) {
+ playlist->write(*dir / (playlist->id() + ".xml"));
+ }
+ break;
}
}