diff options
| author | Carl Hetherington <cth@carlh.net> | 2019-03-21 00:10:08 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2019-05-10 23:43:42 +0100 |
| commit | 14b8b29e6660f5a7fb21135fb5f90b4c1ce51a4b (patch) | |
| tree | ed06e1b877a40f57b8d4d43c1db490e6765fba6a /src/lib | |
| parent | d17044d0da61d6077a1f20170ba76ab765a44e50 (diff) | |
Basics of metadata dialog - ratings.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/film.cc | 14 | ||||
| -rw-r--r-- | src/lib/film.h | 11 | ||||
| -rw-r--r-- | src/lib/util.h | 11 | ||||
| -rw-r--r-- | src/lib/writer.cc | 1 |
4 files changed, 35 insertions, 2 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc index 0b2b67801..0b9e57117 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -408,6 +408,9 @@ Film::metadata (bool with_content_paths) const m->set_attribute("Type", dcp::marker_to_string(i->first)); m->add_child_text(raw_convert<string>(i->second.get())); } + BOOST_FOREACH (dcp::Rating i, _ratings) { + i.as_xml (root->add_child("Rating")); + } _playlist->as_xml (root->add_child ("Playlist"), with_content_paths); return doc; @@ -540,6 +543,10 @@ Film::read_metadata (optional<boost::filesystem::path> path) _markers[dcp::marker_from_string(i->string_attribute("Type"))] = DCPTime(dcp::raw_convert<DCPTime::Type>(i->content())); } + BOOST_FOREACH (cxml::ConstNodePtr i, f.node_children("Rating")) { + _ratings.push_back (dcp::Rating(i)); + } + list<string> notes; /* This method is the only one that can return notes (so far) */ _playlist->set_from_xml (shared_from_this(), f.node_child ("Playlist"), _state_version, notes); @@ -1709,6 +1716,13 @@ Film::unset_marker (dcp::Marker type) _markers.erase (type); } +void +Film::set_ratings (vector<dcp::Rating> r) +{ + ChangeSignaller<Film> ch (this, RATINGS); + _ratings = r; +} + optional<DCPTime> Film::marker (dcp::Marker type) const { diff --git a/src/lib/film.h b/src/lib/film.h index d61612e47..e5d29145c 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -201,7 +201,8 @@ public: REEL_LENGTH, UPLOAD_AFTER_MAKE_DCP, REENCODE_J2K, - MARKERS + MARKERS, + RATINGS }; @@ -302,6 +303,10 @@ public: return _markers; } + std::vector<dcp::Rating> ratings () const { + return _ratings; + } + /* SET */ void set_directory (boost::filesystem::path); @@ -334,6 +339,7 @@ public: void set_reencode_j2k (bool); void set_marker (dcp::Marker type, DCPTime time); void unset_marker (dcp::Marker type); + void set_ratings (std::vector<dcp::Rating> r); /** Emitted when some property has of the Film is about to change or has changed */ mutable boost::signals2::signal<void (ChangeType, Property)> Change; @@ -414,6 +420,7 @@ private: /** true if the user has ever explicitly set the video frame rate of this film */ bool _user_explicit_video_frame_rate; std::map<dcp::Marker, DCPTime> _markers; + std::vector<dcp::Rating> _ratings; int _state_version; diff --git a/src/lib/util.h b/src/lib/util.h index 5ffdae450..6cb818b39 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -111,4 +111,15 @@ extern boost::shared_ptr<dcp::CertificateChain> read_swaroop_chain (boost::files extern void write_swaroop_chain (boost::shared_ptr<const dcp::CertificateChain> chain, boost::filesystem::path output); #endif +template <class T> +std::list<T> +vector_to_list (std::vector<T> v) +{ + std::list<T> l; + BOOST_FOREACH (T& i, v) { + l.push_back (i); + } + return l; +} + #endif diff --git a/src/lib/writer.cc b/src/lib/writer.cc index d0f0825f1..79e5c8c36 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -558,6 +558,7 @@ Writer::finish () meta.set_issue_date_now (); cpl->set_metadata (meta); + cpl->set_ratings (vector_to_list(_film->ratings())); shared_ptr<const dcp::CertificateChain> signer; if (_film->is_signed ()) { |
