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
class SPL
{
public:
+ SPL ()
+ : _missing (false)
+ {}
+
void add (SPLEntry e) {
_spl.push_back (e);
}
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
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);
}
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);
}
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()) {
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;