From 0b45af42b5a30c3a71d2e1de491843d125e46793 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 10 Jan 2013 21:54:45 +0000 Subject: [PATCH] Fixes to times for KDMs. --- src/lib/film.cc | 5 +++-- src/lib/film.h | 7 ++++--- src/tools/dvdomatic.cc | 6 +++++- src/wx/kdm_dialog.cc | 21 ++++++++++++++++----- src/wx/kdm_dialog.h | 7 +++++-- 5 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/lib/film.cc b/src/lib/film.cc index 1b53b3d3e..012495226 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -65,6 +65,7 @@ using std::ofstream; using std::setfill; using std::min; using std::make_pair; +using std::list; using std::cout; using boost::shared_ptr; using boost::lexical_cast; @@ -1388,8 +1389,8 @@ Film::audio_stream () const void Film::make_kdms ( list >, - boost::locale::date_time from, - boost::locale::date_time until, + boost::posix_time::ptime from, + boost::posix_time::ptime until, string directory ) const { diff --git a/src/lib/film.h b/src/lib/film.h index c9d99dae3..b119d59a6 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -32,6 +32,7 @@ #include #include #include +#include extern "C" { #include } @@ -103,10 +104,10 @@ public: void make_kdms ( std::list >, - boost::locale::date_time from, - boost::locale::date_time until, + boost::posix_time::ptime from, + boost::posix_time::ptime until, std::string directory - ); + ) const; enum Property { NONE, diff --git a/src/tools/dvdomatic.cc b/src/tools/dvdomatic.cc index 7d7adcce8..b6662f281 100644 --- a/src/tools/dvdomatic.cc +++ b/src/tools/dvdomatic.cc @@ -337,9 +337,13 @@ public: void jobs_make_kdms (wxCommandEvent &) { + if (!film) { + return; + } + KDMDialog* d = new KDMDialog (this); if (d->ShowModal () == wxID_OK) { - _film->make_kdms ( + film->make_kdms ( d->screens (), d->from (), d->until (), diff --git a/src/wx/kdm_dialog.cc b/src/wx/kdm_dialog.cc index 43d904d90..0febdf38e 100644 --- a/src/wx/kdm_dialog.cc +++ b/src/wx/kdm_dialog.cc @@ -329,7 +329,7 @@ KDMDialog::screens () const list > > cinemas = selected_cinemas (); for (list > >::iterator i = cinemas.begin(); i != cinemas.end(); ++i) { - for (list::iterator j = i->second->screens.begin(); j != i->second->screens.end(); ++j) { + for (list >::iterator j = i->second->screens.begin(); j != i->second->screens.end(); ++j) { s.push_back (*j); } } @@ -340,21 +340,32 @@ KDMDialog::screens () const } s.sort (); - s.uniq (); + s.unique (); return s; } -boost::locale::date_time +boost::posix_time::ptime KDMDialog::from () const { + return posix_time (_from_date, _from_time); +} +boost::posix_time::ptime +KDMDialog::posix_time (wxDatePickerCtrl* date_picker, wxTimePickerCtrl* time_picker) +{ + wxDateTime const date = date_picker->GetValue (); + wxDateTime const time = time_picker->GetValue (); + return boost::posix_time::ptime ( + boost::gregorian::date (date.GetYear(), date.GetMonth() + 1, date.GetDay()), + boost::posix_time::time_duration (time.GetHour(), time.GetMinute(), time.GetSecond()) + ); } -boost::locale::date_time +boost::posix_time::ptime KDMDialog::until () const { - + return posix_time (_until_date, _until_time); } string diff --git a/src/wx/kdm_dialog.h b/src/wx/kdm_dialog.h index d161223a8..ac2db9b95 100644 --- a/src/wx/kdm_dialog.h +++ b/src/wx/kdm_dialog.h @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -37,8 +38,8 @@ public: KDMDialog (wxWindow *); std::list > screens () const; - boost::local::date_time from () const; - boost::local::date_time until () const; + boost::posix_time::ptime from () const; + boost::posix_time::ptime until () const; std::string directory () const; private: @@ -54,6 +55,8 @@ private: std::list > > selected_cinemas () const; std::list > > selected_screens () const; void setup_sensitivity (); + + static boost::posix_time::ptime posix_time (wxDatePickerCtrl *, wxTimePickerCtrl *); wxTreeCtrl* _targets; wxButton* _add_cinema; -- 2.30.2