diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-08-01 00:48:15 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-08-01 00:48:15 +0100 |
| commit | 1d022220899c63e2cae0a2a9a81f6c6db955a23d (patch) | |
| tree | fdf436255ae717e6269d98626e9d45824fc77e82 /src | |
| parent | 9c01623c3038b978ba732de2ad147d29fad60afe (diff) | |
Simplify NameFormat stuff.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/cinema_kdms.cc | 7 | ||||
| -rw-r--r-- | src/lib/cinema_kdms.h | 6 | ||||
| -rw-r--r-- | src/lib/config.cc | 11 | ||||
| -rw-r--r-- | src/lib/config.h | 15 | ||||
| -rw-r--r-- | src/lib/kdm_filename_format.cc | 38 | ||||
| -rw-r--r-- | src/lib/kdm_filename_format.h | 33 | ||||
| -rw-r--r-- | src/lib/screen_kdm.cc | 2 | ||||
| -rw-r--r-- | src/lib/screen_kdm.h | 4 | ||||
| -rw-r--r-- | src/lib/send_kdm_email_job.cc | 2 | ||||
| -rw-r--r-- | src/lib/send_kdm_email_job.h | 6 | ||||
| -rw-r--r-- | src/lib/wscript | 1 | ||||
| -rw-r--r-- | src/wx/config_dialog.cc | 4 | ||||
| -rw-r--r-- | src/wx/kdm_dialog.h | 1 | ||||
| -rw-r--r-- | src/wx/kdm_output_panel.cc | 4 | ||||
| -rw-r--r-- | src/wx/kdm_output_panel.h | 5 | ||||
| -rw-r--r-- | src/wx/name_format_editor.h | 57 | ||||
| -rw-r--r-- | src/wx/wscript | 1 |
17 files changed, 38 insertions, 159 deletions
diff --git a/src/lib/cinema_kdms.cc b/src/lib/cinema_kdms.cc index 78e7c5ace..299cdf94e 100644 --- a/src/lib/cinema_kdms.cc +++ b/src/lib/cinema_kdms.cc @@ -27,7 +27,6 @@ #include "emailer.h" #include "compose.hpp" #include "log.h" -#include "kdm_filename_format.h" #include <zip.h> #include <boost/foreach.hpp> @@ -40,7 +39,7 @@ using std::runtime_error; using boost::shared_ptr; void -CinemaKDMs::make_zip_file (boost::filesystem::path zip_file, KDMFilenameFormat name_format, dcp::NameFormat::Map name_values) const +CinemaKDMs::make_zip_file (boost::filesystem::path zip_file, dcp::NameFormat name_format, dcp::NameFormat::Map name_values) const { int error; struct zip* zip = zip_open (zip_file.string().c_str(), ZIP_CREATE | ZIP_EXCL, &error); @@ -119,7 +118,7 @@ void CinemaKDMs::write_zip_files ( list<CinemaKDMs> cinema_kdms, boost::filesystem::path directory, - KDMFilenameFormat name_format, + dcp::NameFormat name_format, dcp::NameFormat::Map name_values ) { @@ -140,7 +139,7 @@ CinemaKDMs::write_zip_files ( void CinemaKDMs::email ( list<CinemaKDMs> cinema_kdms, - KDMFilenameFormat name_format, + dcp::NameFormat name_format, dcp::NameFormat::Map name_values, string cpl_name, shared_ptr<Log> log diff --git a/src/lib/cinema_kdms.h b/src/lib/cinema_kdms.h index 826b93806..e29fa5cbd 100644 --- a/src/lib/cinema_kdms.h +++ b/src/lib/cinema_kdms.h @@ -27,20 +27,20 @@ class Log; class CinemaKDMs { public: - void make_zip_file (boost::filesystem::path zip_file, KDMFilenameFormat name_format, dcp::NameFormat::Map name_values) const; + void make_zip_file (boost::filesystem::path zip_file, dcp::NameFormat name_format, dcp::NameFormat::Map name_values) const; static std::list<CinemaKDMs> collect (std::list<ScreenKDM> kdms); static void write_zip_files ( std::list<CinemaKDMs> cinema_kdms, boost::filesystem::path directory, - KDMFilenameFormat name_format, + dcp::NameFormat name_format, dcp::NameFormat::Map name_values ); static void email ( std::list<CinemaKDMs> cinema_kdms, - KDMFilenameFormat name_format, + dcp::NameFormat name_format, dcp::NameFormat::Map name_values, std::string cpl_name, boost::shared_ptr<Log> log diff --git a/src/lib/config.cc b/src/lib/config.cc index d332c805a..5dbbd692e 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -30,8 +30,7 @@ #include "util.h" #include "cross.h" #include "raw_convert.h" -#include "kdm_filename_format.h" -#include <dcp/filename_format.h> +#include <dcp/name_format.h> #include <dcp/colour_matrix.h> #include <dcp/certificate_chain.h> #include <libcxml/cxml.h> @@ -110,8 +109,8 @@ Config::set_defaults () #endif _cinemas_file = path ("cinemas.xml"); _show_hints_before_make_dcp = true; - _kdm_filename_format = KDMFilenameFormat ("KDM %f %c %s"); - _dcp_filename_format = dcp::FilenameFormat ("%t_%i"); + _kdm_filename_format = dcp::NameFormat ("KDM %f %c %s"); + _dcp_filename_format = dcp::NameFormat ("%t_%i"); _allowed_dcp_frame_rates.clear (); _allowed_dcp_frame_rates.push_back (24); @@ -294,8 +293,8 @@ try _cinemas_file = f.optional_string_child("CinemasFile").get_value_or (path ("cinemas.xml").string ()); _show_hints_before_make_dcp = f.optional_bool_child("ShowHintsBeforeMakeDCP").get_value_or (true); - _kdm_filename_format = KDMFilenameFormat (f.optional_string_child("KDMFilenameFormat").get_value_or ("KDM %f %c %s")); - _dcp_filename_format = dcp::FilenameFormat (f.optional_string_child("DCPFilenameFormat").get_value_or ("%t_%i.mxf")); + _kdm_filename_format = dcp::NameFormat (f.optional_string_child("KDMFilenameFormat").get_value_or ("KDM %f %c %s")); + _dcp_filename_format = dcp::NameFormat (f.optional_string_child("DCPFilenameFormat").get_value_or ("%t_%i.mxf")); /* Replace any cinemas from config.xml with those from the configured file */ if (boost::filesystem::exists (_cinemas_file)) { diff --git a/src/lib/config.h b/src/lib/config.h index 0de71be51..3a0308462 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -26,9 +26,8 @@ #define DCPOMATIC_CONFIG_H #include "isdcf_metadata.h" -#include "kdm_filename_format.h" #include "types.h" -#include <dcp/filename_format.h> +#include <dcp/name_format.h> #include <dcp/certificate_chain.h> #include <dcp/encrypted_kdm.h> #include <boost/shared_ptr.hpp> @@ -268,11 +267,11 @@ public: return _show_hints_before_make_dcp; } - KDMFilenameFormat kdm_filename_format () const { + dcp::NameFormat kdm_filename_format () const { return _kdm_filename_format; } - dcp::FilenameFormat dcp_filename_format () const { + dcp::NameFormat dcp_filename_format () const { return _dcp_filename_format; } @@ -483,11 +482,11 @@ public: maybe_set (_show_hints_before_make_dcp, s); } - void set_kdm_filename_format (KDMFilenameFormat n) { + void set_kdm_filename_format (dcp::NameFormat n) { maybe_set (_kdm_filename_format, n); } - void set_dcp_filename_format (dcp::FilenameFormat n) { + void set_dcp_filename_format (dcp::NameFormat n) { maybe_set (_dcp_filename_format, n); } @@ -602,8 +601,8 @@ private: std::vector<dcp::EncryptedKDM> _dkdms; boost::filesystem::path _cinemas_file; bool _show_hints_before_make_dcp; - KDMFilenameFormat _kdm_filename_format; - dcp::FilenameFormat _dcp_filename_format; + dcp::NameFormat _kdm_filename_format; + dcp::NameFormat _dcp_filename_format; /** Singleton instance, or 0 */ static Config* _instance; diff --git a/src/lib/kdm_filename_format.cc b/src/lib/kdm_filename_format.cc deleted file mode 100644 index 20e8298fe..000000000 --- a/src/lib/kdm_filename_format.cc +++ /dev/null @@ -1,38 +0,0 @@ -/* - Copyright (C) 2016 Carl Hetherington <cth@carlh.net> - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. - -*/ - -#include "kdm_filename_format.h" - -using std::string; - -KDMFilenameFormat::KDMFilenameFormat (string specification) - : NameFormat (specification) -{ - /* film name */ - add ('f'); - /* cinema */ - add ('c'); - /* screen */ - add ('s'); - /* from date/time */ - add ('b'); - /* to date/time */ - add ('e'); -} diff --git a/src/lib/kdm_filename_format.h b/src/lib/kdm_filename_format.h deleted file mode 100644 index b96ac34ae..000000000 --- a/src/lib/kdm_filename_format.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - Copyright (C) 2016 Carl Hetherington <cth@carlh.net> - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. - -*/ - -#ifndef DCPOMATIC_KDM_FILENAME_FORMAT -#define DCPOMATIC_KDM_FILENAME_FORMAT - -#include <dcp/name_format.h> - -class KDMFilenameFormat : public dcp::NameFormat -{ -public: - KDMFilenameFormat () {} - KDMFilenameFormat (std::string specification); -}; - -#endif diff --git a/src/lib/screen_kdm.cc b/src/lib/screen_kdm.cc index 9cb831622..129e64aee 100644 --- a/src/lib/screen_kdm.cc +++ b/src/lib/screen_kdm.cc @@ -35,7 +35,7 @@ operator== (ScreenKDM const & a, ScreenKDM const & b) } void -ScreenKDM::write_files (list<ScreenKDM> screen_kdms, boost::filesystem::path directory, KDMFilenameFormat name_format, dcp::NameFormat::Map name_values) +ScreenKDM::write_files (list<ScreenKDM> screen_kdms, boost::filesystem::path directory, dcp::NameFormat name_format, dcp::NameFormat::Map name_values) { /* Write KDMs to the specified directory */ BOOST_FOREACH (ScreenKDM const & i, screen_kdms) { diff --git a/src/lib/screen_kdm.h b/src/lib/screen_kdm.h index 227526449..60486c259 100644 --- a/src/lib/screen_kdm.h +++ b/src/lib/screen_kdm.h @@ -21,8 +21,8 @@ #ifndef DCPOMATIC_SCREEN_KDM_H #define DCPOMATIC_SCREEN_KDM_H -#include "kdm_filename_format.h" #include <dcp/encrypted_kdm.h> +#include <dcp/name_format.h> #include <boost/shared_ptr.hpp> class Screen; @@ -38,7 +38,7 @@ public: static void write_files ( std::list<ScreenKDM> screen_kdms, boost::filesystem::path directory, - KDMFilenameFormat name_format, dcp::NameFormat::Map name_values + dcp::NameFormat name_format, dcp::NameFormat::Map name_values ); boost::shared_ptr<Screen> screen; diff --git a/src/lib/send_kdm_email_job.cc b/src/lib/send_kdm_email_job.cc index b06704545..642939462 100644 --- a/src/lib/send_kdm_email_job.cc +++ b/src/lib/send_kdm_email_job.cc @@ -33,7 +33,7 @@ using boost::shared_ptr; /** @param log Log to write to, or 0 */ SendKDMEmailJob::SendKDMEmailJob ( list<CinemaKDMs> cinema_kdms, - KDMFilenameFormat name_format, + dcp::NameFormat name_format, dcp::NameFormat::Map name_values, string cpl_name, shared_ptr<Log> log diff --git a/src/lib/send_kdm_email_job.h b/src/lib/send_kdm_email_job.h index 17b2db89c..c2916f69d 100644 --- a/src/lib/send_kdm_email_job.h +++ b/src/lib/send_kdm_email_job.h @@ -19,8 +19,8 @@ */ #include "job.h" -#include "kdm_filename_format.h" #include <dcp/types.h> +#include <dcp/name_format.h> #include <boost/filesystem.hpp> class Screen; @@ -32,7 +32,7 @@ class SendKDMEmailJob : public Job public: SendKDMEmailJob ( std::list<CinemaKDMs> cinema_kdms, - KDMFilenameFormat name_format, + dcp::NameFormat name_format, dcp::NameFormat::Map name_values, std::string cpl_name, boost::shared_ptr<Log> log @@ -43,7 +43,7 @@ public: void run (); private: - KDMFilenameFormat _name_format; + dcp::NameFormat _name_format; dcp::NameFormat::Map _name_values; std::string _cpl_name; std::list<CinemaKDMs> _cinema_kdms; diff --git a/src/lib/wscript b/src/lib/wscript index 6e937c26f..9883f31d6 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -94,7 +94,6 @@ sources = """ job.cc job_manager.cc json_server.cc - kdm_filename_format.cc log.cc log_entry.cc magick_image_proxy.cc diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index 10ee7c79a..3f3565122 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -1420,7 +1420,7 @@ private: examples['i'] = "eb1c112c-ca3c-4ae6-9263-c6714ff05d64"; examples['r'] = "1"; examples['n'] = "4"; - _dcp_filename_format = new NameFormatEditor<dcp::FilenameFormat> (_panel, Config::instance()->dcp_filename_format(), titles, examples); + _dcp_filename_format = new NameFormatEditor (_panel, Config::instance()->dcp_filename_format(), titles, examples); table->Add (_dcp_filename_format->panel(), 1, wxEXPAND | wxALL); #ifdef __WXOSX__ @@ -1550,7 +1550,7 @@ private: wxSpinCtrl* _maximum_j2k_bandwidth; wxCheckBox* _allow_any_dcp_frame_rate; wxCheckBox* _only_servers_encode; - NameFormatEditor<dcp::FilenameFormat>* _dcp_filename_format; + NameFormatEditor* _dcp_filename_format; wxCheckBox* _log_general; wxCheckBox* _log_warning; wxCheckBox* _log_error; diff --git a/src/wx/kdm_dialog.h b/src/wx/kdm_dialog.h index 07b998224..a76c2a14f 100644 --- a/src/wx/kdm_dialog.h +++ b/src/wx/kdm_dialog.h @@ -19,7 +19,6 @@ */ #include "wx_util.h" -#include "lib/kdm_filename_format.h" #include <dcp/types.h> #include <wx/wx.h> #include <boost/shared_ptr.hpp> diff --git a/src/wx/kdm_output_panel.cc b/src/wx/kdm_output_panel.cc index 2808357d4..537cf6652 100644 --- a/src/wx/kdm_output_panel.cc +++ b/src/wx/kdm_output_panel.cc @@ -68,7 +68,7 @@ KDMOutputPanel::KDMOutputPanel (wxWindow* parent, bool interop) ex['s'] = "Screen 1"; ex['b'] = "2012/03/15 12:30"; ex['e'] = "2012/03/22 02:30"; - _filename_format = new NameFormatEditor<KDMFilenameFormat> (this, Config::instance()->kdm_filename_format(), titles, ex); + _filename_format = new NameFormatEditor (this, Config::instance()->kdm_filename_format(), titles, ex); table->Add (_filename_format->panel(), 1, wxEXPAND); _write_to = new wxRadioButton (this, wxID_ANY, _("Write to")); @@ -126,7 +126,7 @@ KDMOutputPanel::save_kdm_name_format () const Config::instance()->set_kdm_filename_format (name_format ()); } -KDMFilenameFormat +dcp::NameFormat KDMOutputPanel::name_format () const { return _filename_format->get (); diff --git a/src/wx/kdm_output_panel.h b/src/wx/kdm_output_panel.h index ee6a94e68..efc9c0c93 100644 --- a/src/wx/kdm_output_panel.h +++ b/src/wx/kdm_output_panel.h @@ -20,7 +20,6 @@ #include "wx_util.h" #include "name_format_editor.h" -#include "lib/kdm_filename_format.h" #include <dcp/types.h> #include <wx/wx.h> #include <boost/filesystem.hpp> @@ -36,14 +35,14 @@ public: boost::filesystem::path directory () const; bool write_to () const; dcp::Formulation formulation () const; - KDMFilenameFormat name_format () const; + dcp::NameFormat name_format () const; void setup_sensitivity (); void save_kdm_name_format () const; private: wxChoice* _type; - NameFormatEditor<KDMFilenameFormat>* _filename_format; + NameFormatEditor* _filename_format; wxRadioButton* _write_to; #ifdef DCPOMATIC_USE_OWN_PICKER DirPickerCtrl* _folder; diff --git a/src/wx/name_format_editor.h b/src/wx/name_format_editor.h index 71295807f..204de76d3 100644 --- a/src/wx/name_format_editor.h +++ b/src/wx/name_format_editor.h @@ -25,44 +25,18 @@ #include <dcp/name_format.h> #include <wx/wx.h> #include <boost/foreach.hpp> +#include <boost/signals2.hpp> -template <class T> class NameFormatEditor { public: - NameFormatEditor (wxWindow* parent, T name, dcp::NameFormat::Map titles, dcp::NameFormat::Map examples) - : _panel (new wxPanel (parent)) - , _example (new wxStaticText (_panel, wxID_ANY, "")) - , _sizer (new wxBoxSizer (wxVERTICAL)) - , _specification (new wxTextCtrl (_panel, wxID_ANY, "")) - , _name (name) - , _examples (examples) - { - _sizer->Add (_specification, 0, wxEXPAND, DCPOMATIC_SIZER_Y_GAP); - _sizer->Add (_example, 0, wxBOTTOM, DCPOMATIC_SIZER_Y_GAP); - _panel->SetSizer (_sizer); - - BOOST_FOREACH (char c, name.components ()) { - wxStaticText* t = new wxStaticText (_panel, wxID_ANY, std_to_wx (String::compose ("%%%1 %2", c, titles[c]))); - _sizer->Add (t); - wxFont font = t->GetFont(); - font.SetStyle (wxFONTSTYLE_ITALIC); - font.SetPointSize (font.GetPointSize() - 1); - t->SetFont (font); - t->SetForegroundColour (wxColour (0, 0, 204)); - } - - _specification->SetValue (std_to_wx (_name.specification ())); - _specification->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&NameFormatEditor::changed, this)); - - update_example (); - } + NameFormatEditor (wxWindow* parent, dcp::NameFormat name, dcp::NameFormat::Map titles, dcp::NameFormat::Map examples); wxPanel* panel () const { return _panel; } - T get () const { + dcp::NameFormat get () const { return _name; } @@ -70,34 +44,15 @@ public: private: - void changed () - { - update_example (); - Changed (); - } - - virtual void update_example () - { - _name.set_specification (wx_to_std (_specification->GetValue ())); - - wxString example = wxString::Format (_("e.g. %s"), _name.get (_examples)); - wxString wrapped; - for (size_t i = 0; i < example.Length(); ++i) { - if (i > 0 && (i % 40) == 0) { - wrapped += "\n"; - } - wrapped += example[i]; - } - - _example->SetLabel (wrapped); - } + void changed (); + void update_example (); wxPanel* _panel; wxStaticText* _example; wxSizer* _sizer; wxTextCtrl* _specification; - T _name; + dcp::NameFormat _name; dcp::NameFormat::Map _examples; }; diff --git a/src/wx/wscript b/src/wx/wscript index bb56ee5b8..ee77e6c20 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -68,6 +68,7 @@ sources = """ key_dialog.cc make_chain_dialog.cc move_to_dialog.cc + name_format_editor.cc new_film_dialog.cc playhead_to_timecode_dialog.cc playhead_to_frame_dialog.cc |
