summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-12-08 22:17:35 +0000
committerCarl Hetherington <cth@carlh.net>2018-12-08 22:17:35 +0000
commit2e0c94655f51ea9f01afea57f0c5f9d0f8efeb8d (patch)
tree2f70c2b76d1c97c786c3b205f19eb983951c8d02 /src
parent29436ead35fbb6041fd24115623cad7638693d8e (diff)
swaroop: better handling of missing content in SPLs.
Diffstat (limited to 'src')
-rw-r--r--src/lib/spl.cc7
-rw-r--r--src/lib/spl.h12
-rw-r--r--src/tools/dcpomatic_playlist.cc3
-rw-r--r--src/wx/swaroop_controls.cc36
4 files changed, 43 insertions, 15 deletions
diff --git a/src/lib/spl.cc b/src/lib/spl.cc
index 74538aa99..2cba229c1 100644
--- a/src/lib/spl.cc
+++ b/src/lib/spl.cc
@@ -28,24 +28,23 @@
using std::cout;
using boost::shared_ptr;
-bool
+void
SPL::read (boost::filesystem::path path, ContentStore* store)
{
_spl.clear ();
+ _missing = false;
cxml::Document doc ("SPL");
doc.read_file (path);
- bool missing = false;
BOOST_FOREACH (cxml::ConstNodePtr i, doc.node_children("Entry")) {
shared_ptr<Content> c = store->get(i->string_child("Digest"));
if (c) {
add (SPLEntry(c, i));
} else {
- missing = true;
+ _missing = true;
}
}
_name = path.filename().string();
- return missing;
}
void
diff --git a/src/lib/spl.h b/src/lib/spl.h
index a0b754f04..b94c08571 100644
--- a/src/lib/spl.h
+++ b/src/lib/spl.h
@@ -28,6 +28,10 @@ class ContentStore;
class SPL
{
public:
+ SPL ()
+ : _missing (false)
+ {}
+
void add (SPLEntry e) {
_spl.push_back (e);
}
@@ -48,16 +52,22 @@ public:
return _spl[index];
}
- bool read (boost::filesystem::path path, ContentStore* store);
+ void read (boost::filesystem::path path, ContentStore* store);
void write (boost::filesystem::path path) const;
std::string name () const {
return _name;
}
+ bool missing () const {
+ return _missing;
+ }
+
private:
std::string _name;
std::vector<SPLEntry> _spl;
+ /** true if any content was missing when read() was last called on this SPL */
+ bool _missing;
};
#endif
diff --git a/src/tools/dcpomatic_playlist.cc b/src/tools/dcpomatic_playlist.cc
index bac47d6db..ad54e3648 100644
--- a/src/tools/dcpomatic_playlist.cc
+++ b/src/tools/dcpomatic_playlist.cc
@@ -295,7 +295,8 @@ private:
wxFileDialog* d = new wxFileDialog (this, _("Select playlist file"), default_dir, wxEmptyString, wxT("XML files (*.xml)|*.xml"));
if (d->ShowModal() == wxID_OK) {
_list->DeleteAllItems ();
- if (!_playlist.read (wx_to_std(d->GetPath()), _content_dialog)) {
+ _playlist.read (wx_to_std(d->GetPath()), _content_dialog);
+ if (!_playlist.missing()) {
BOOST_FOREACH (SPLEntry i, _playlist.get()) {
add (i);
}
diff --git a/src/wx/swaroop_controls.cc b/src/wx/swaroop_controls.cc
index 2f51fed3f..99a19f5de 100644
--- a/src/wx/swaroop_controls.cc
+++ b/src/wx/swaroop_controls.cc
@@ -214,7 +214,11 @@ SwaroopControls::add_playlist_to_list (SPL spl)
wxListItem it;
it.SetId(N);
it.SetColumn(0);
- it.SetText (std_to_wx(spl.name()));
+ string t = spl.name();
+ if (spl.missing()) {
+ t += " (content missing)";
+ }
+ it.SetText (std_to_wx(t));
_spl_view->InsertItem (it);
}
@@ -248,17 +252,36 @@ SwaroopControls::update_playlist_directory ()
void
SwaroopControls::spl_selection_changed ()
{
- _current_spl_view->DeleteAllItems ();
-
long int selected = _spl_view->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
if (selected == -1) {
+ _current_spl_view->DeleteAllItems ();
+ _selected_playlist = boost::none;
+ return;
+ }
+
+ if (_playlists[selected].missing()) {
+ error_dialog (this, "This playlist cannot be loaded as some content is missing.");
_selected_playlist = boost::none;
+ _spl_view->SetItemState (selected, 0, wxLIST_STATE_SELECTED);
return;
}
- wxProgressDialog progress (_("DCP-o-matic"), _("Loading playlist"));
+ wxProgressDialog* progress = new wxProgressDialog (_("DCP-o-matic"), _("Loading playlist"));
shared_ptr<Film> film (new Film(optional<boost::filesystem::path>()));
+ BOOST_FOREACH (SPLEntry i, _playlists[selected].get()) {
+ film->add_content (i.content);
+ if (!progress->Pulse()) {
+ /* user pressed cancel */
+ _selected_playlist = boost::none;
+ _spl_view->SetItemState (selected, 0, wxLIST_STATE_SELECTED);
+ progress->Destroy ();
+ return;
+ }
+ }
+
+ progress->Destroy ();
+ _current_spl_view->DeleteAllItems ();
int N = 0;
BOOST_FOREACH (SPLEntry i, _playlists[selected].get()) {
@@ -267,12 +290,7 @@ SwaroopControls::spl_selection_changed ()
it.SetColumn (0);
it.SetText (std_to_wx(i.name));
_current_spl_view->InsertItem (it);
- film->add_content (i.content);
++N;
- if (!progress.Pulse()) {
- /* user pressed cancel */
- return;
- }
}
_selected_playlist = selected;