#include "lib/job_manager.h"
#include "lib/exceptions.h"
#include "lib/dcp_content.h"
+#include "lib/ffmpeg_content.h"
#include <wx/wx.h>
#include <wx/dirdlg.h>
+#include <boost/foreach.hpp>
+#include <iostream>
using std::cout;
using std::vector;
_repeat->Enable (!_content.empty ());
int n = 0;
- for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) {
- if (dynamic_pointer_cast<FFmpegContent> (*i)) {
+ BOOST_FOREACH (shared_ptr<Content> i, _content) {
+ if (dynamic_pointer_cast<FFmpegContent> (i)) {
++n;
}
}
ContentMenu::join ()
{
vector<shared_ptr<Content> > fc;
- for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) {
- shared_ptr<FFmpegContent> f = dynamic_pointer_cast<FFmpegContent> (*i);
+ BOOST_FOREACH (shared_ptr<Content> i, _content) {
+ shared_ptr<FFmpegContent> f = dynamic_pointer_cast<FFmpegContent> (i);
if (f) {
fc.push_back (f);
}
try {
shared_ptr<FFmpegContent> joined (new FFmpegContent (film, fc));
- for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) {
- film->remove_content (*i);
+ BOOST_FOREACH (shared_ptr<Content> i, _content) {
+ film->remove_content (i);
}
film->add_content (joined);
} catch (JoinError& e) {
/* Special case: we only remove FFmpegContent if its video view is selected;
if not, and its audio view is selected, we unmap the audio.
*/
- for (ContentList::iterator i = _content.begin(); i != _content.end(); ++i) {
- shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (*i);
+ BOOST_FOREACH (shared_ptr<Content> i, _content) {
+ shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (i);
if (!fc) {
continue;
}
shared_ptr<TimelineVideoContentView> video;
shared_ptr<TimelineAudioContentView> audio;
- for (TimelineContentViewList::iterator i = _views.begin(); i != _views.end(); ++i) {
- shared_ptr<TimelineVideoContentView> v = dynamic_pointer_cast<TimelineVideoContentView> (*i);
- shared_ptr<TimelineAudioContentView> a = dynamic_pointer_cast<TimelineAudioContentView> (*i);
+ BOOST_FOREACH (shared_ptr<TimelineContentView> j, _views) {
+ shared_ptr<TimelineVideoContentView> v = dynamic_pointer_cast<TimelineVideoContentView> (j);
+ shared_ptr<TimelineAudioContentView> a = dynamic_pointer_cast<TimelineAudioContentView> (j);
if (v && v->content() == fc) {
video = v;
} else if (a && a->content() == fc) {
/* XXX: a bit nasty */
shared_ptr<ImageContent> ic = dynamic_pointer_cast<ImageContent> (_content.front ());
- if (ic && !ic->still ()) {
+ shared_ptr<DCPContent> dc = dynamic_pointer_cast<DCPContent> (_content.front ());
+
+ int r = wxID_CANCEL;
+ boost::filesystem::path path;
+
+ if ((ic && !ic->still ()) || dc) {
wxDirDialog* d = new wxDirDialog (0, _("Choose a folder"), wxT (""), wxDD_DIR_MUST_EXIST);
- int const r = d->ShowModal ();
- if (r == wxID_OK) {
- content.reset (new ImageContent (film, boost::filesystem::path (wx_to_std (d->GetPath ()))));
- }
+ r = d->ShowModal ();
+ path = wx_to_std (d->GetPath ());
d->Destroy ();
} else {
wxFileDialog* d = new wxFileDialog (0, _("Choose a file"), wxT (""), wxT (""), wxT ("*.*"), wxFD_MULTIPLE);
- int const r = d->ShowModal ();
- if (r == wxID_OK) {
- content = content_factory (film, wx_to_std (d->GetPath ()));
- }
+ r = d->ShowModal ();
+ path = wx_to_std (d->GetPath ());
d->Destroy ();
}
+ if (r == wxID_OK) {
+ content = content_factory (film, path);
+ }
+
if (!content) {
return;
}
return;
}
- for (ContentList::iterator i = _content.begin(); i != _content.end(); ++i) {
- film->examine_content (*i);
+ BOOST_FOREACH (shared_ptr<Content> i, _content) {
+ film->examine_content (i);
}
}
dcp->add_kdm (dcp::EncryptedKDM (dcp::file_to_string (wx_to_std (d->GetPath ()))));
} catch (exception& e) {
error_dialog (_parent, wxString::Format (_("Could not load KDM (%s)"), e.what ()));
+ d->Destroy ();
+ return;
}
shared_ptr<Film> film = _film.lock ();