using boost::weak_ptr;
using boost::optional;
using boost::dynamic_pointer_cast;
+using namespace dcpomatic;
-ContentView::ContentView (wxWindow* parent, weak_ptr<Film> film)
+ContentView::ContentView (wxWindow* parent)
: wxListCtrl (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_NO_HEADER)
- , _film (film)
{
AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 80);
/* type */
void
ContentView::update ()
{
- shared_ptr<Film> film = _film.lock ();
- if (!film) {
- return;
- }
-
using namespace boost::filesystem;
DeleteAllItems ();
_content.clear ();
optional<path> dir = Config::instance()->player_content_directory();
- if (!dir) {
- return;
+ if (!dir || !boost::filesystem::is_directory(*dir)) {
+ dir = home_directory ();
}
wxProgressDialog progress (_("DCP-o-matic"), _("Reading content directory"));
for (directory_iterator i = directory_iterator(*dir); i != directory_iterator(); ++i) {
try {
+ progress.Pulse ();
+
shared_ptr<Content> content;
if (is_directory(*i) && (is_regular_file(*i / "ASSETMAP") || is_regular_file(*i / "ASSETMAP.xml"))) {
content.reset (new DCPContent(*i));
}
if (content) {
- shared_ptr<ExamineContentJob> job(new ExamineContentJob(film, content));
+ shared_ptr<ExamineContentJob> job(new ExamineContentJob(shared_ptr<Film>(), content));
jm->add (job);
jobs.push_back (job);
}
} catch (boost::filesystem::filesystem_error& e) {
/* Never mind */
- } catch (dcp::DCPReadError& e) {
+ } catch (dcp::ReadError& e) {
/* Never mind */
}
}
}
return;
}
- dcpomatic_sleep (1);
+ dcpomatic_sleep_seconds (1);
}
/* Add content from successful jobs and report errors */
{
int const N = GetItemCount();
- shared_ptr<Film> film = _film.lock ();
- DCPOMATIC_ASSERT (film);
-
wxListItem it;
it.SetId(N);
it.SetColumn(0);
- DCPTime length = content->length_after_trim (film);
+ DCPTime length = content->approximate_length ();
int h, m, s, f;
length.split (24, h, m, s, f);
it.SetText(wxString::Format("%02d:%02d:%02d", h, m, s));
return shared_ptr<Content>();
}
-
-void
-ContentView::set_film (weak_ptr<Film> film)
-{
- if (_film.lock() == film.lock()) {
- return;
- }
-
- _film = film;
- update ();
-}