summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-03-02 21:41:58 +0000
committerCarl Hetherington <cth@carlh.net>2016-03-08 10:30:34 +0000
commit581ea73e56388d87a0c7f736efce447076618393 (patch)
treedccfd764d2234e7a3c4f15827ea5f237ebab5f65
parent61978a4f081a3c41896bf41185634778b7c1e9ce (diff)
Add GUI and storage for UTC offset in Cinema.
-rw-r--r--src/lib/cinema.cc15
-rw-r--r--src/lib/cinema.h16
-rw-r--r--src/wx/cinema_dialog.cc26
-rw-r--r--src/wx/cinema_dialog.h4
-rw-r--r--src/wx/screens_panel.cc5
5 files changed, 57 insertions, 9 deletions
diff --git a/src/lib/cinema.cc b/src/lib/cinema.cc
index ebd716009..5e2b1b533 100644
--- a/src/lib/cinema.cc
+++ b/src/lib/cinema.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,9 +19,12 @@
#include "cinema.h"
#include "screen.h"
+#include "dcpomatic_assert.h"
#include <libcxml/cxml.h>
+#include <dcp/raw_convert.h>
#include <libxml++/libxml++.h>
#include <boost/foreach.hpp>
+#include <iostream>
using std::list;
using std::string;
@@ -29,6 +32,7 @@ using boost::shared_ptr;
Cinema::Cinema (cxml::ConstNodePtr node)
: name (node->string_child ("Name"))
+ , _utc_offset (node->optional_number_child<int>("UTCOffset").get_value_or (0))
{
BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children("Email")) {
emails.push_back (i->content ());
@@ -56,6 +60,8 @@ Cinema::as_xml (xmlpp::Element* parent) const
parent->add_child("Email")->add_child_text (i);
}
+ parent->add_child("UTCOffset")->add_child_text (dcp::raw_convert<string> (_utc_offset));
+
BOOST_FOREACH (shared_ptr<Screen> i, _screens) {
i->as_xml (parent->add_child ("Screen"));
}
@@ -73,3 +79,10 @@ Cinema::remove_screen (shared_ptr<Screen> s)
{
_screens.remove (s);
}
+
+void
+Cinema::set_utc_offset (int o)
+{
+ DCPOMATIC_ASSERT (o >= -11 && o <= 12);
+ _utc_offset = o;
+}
diff --git a/src/lib/cinema.h b/src/lib/cinema.h
index aec4c83ec..7df83c767 100644
--- a/src/lib/cinema.h
+++ b/src/lib/cinema.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -33,15 +33,16 @@ class Screen;
/** @class Cinema
* @brief A description of a Cinema for KDM generation.
*
- * This is a cinema name, contact email addresses and a list of
+ * This is a cinema name, some metadata and a list of
* Screen objects.
*/
class Cinema : public boost::enable_shared_from_this<Cinema>
{
public:
- Cinema (std::string const & n, std::list<std::string> const & e)
+ Cinema (std::string const & n, std::list<std::string> const & e, int utc_offset)
: name (n)
, emails (e)
+ , _utc_offset (utc_offset)
{}
Cinema (cxml::ConstNodePtr);
@@ -53,12 +54,21 @@ public:
void add_screen (boost::shared_ptr<Screen>);
void remove_screen (boost::shared_ptr<Screen>);
+ void set_utc_offset (int o);
+
std::string name;
std::list<std::string> emails;
+ int utc_offset () const {
+ return _utc_offset;
+ }
std::list<boost::shared_ptr<Screen> > screens () const {
return _screens;
}
private:
std::list<boost::shared_ptr<Screen> > _screens;
+ /** Offset such that the equivalent time in UTC can be determined
+ by subtracting the offset from the local time.
+ */
+ int _utc_offset;
};
diff --git a/src/wx/cinema_dialog.cc b/src/wx/cinema_dialog.cc
index 183e3b1b2..6fb4acc6b 100644
--- a/src/wx/cinema_dialog.cc
+++ b/src/wx/cinema_dialog.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,6 +19,7 @@
#include "cinema_dialog.h"
#include "wx_util.h"
+#include "lib/dcpomatic_assert.h"
#include <boost/foreach.hpp>
using std::string;
@@ -35,7 +36,7 @@ column (string s)
return s;
}
-CinemaDialog::CinemaDialog (wxWindow* parent, string title, string name, list<string> emails)
+CinemaDialog::CinemaDialog (wxWindow* parent, string title, string name, list<string> emails, int utc_offset)
: wxDialog (parent, wxID_ANY, std_to_wx (title))
{
wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
@@ -49,6 +50,11 @@ CinemaDialog::CinemaDialog (wxWindow* parent, string title, string name, list<st
sizer->Add (_name, wxGBPosition (r, 1));
++r;
+ add_label_to_sizer (sizer, this, _("UTC offset (time zone)"), true, wxGBPosition (r, 0));
+ _utc_offset = new wxChoice (this, wxID_ANY);
+ sizer->Add (_utc_offset, wxGBPosition (r, 1));
+ ++r;
+
add_label_to_sizer (sizer, this, _("Email addresses for KDM delivery"), false, wxGBPosition (r, 0), wxGBSpan (1, 2));
++r;
@@ -70,6 +76,16 @@ CinemaDialog::CinemaDialog (wxWindow* parent, string title, string name, list<st
overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
}
+ for (int i = -11; i <= -1; ++i) {
+ _utc_offset->Append (wxString::Format (_("UTC%d"), i));
+ }
+ _utc_offset->Append (_("UTC"));
+ for (int i = 1; i <= 12; ++i) {
+ _utc_offset->Append (wxString::Format (_("UTC+%d"), i));
+ }
+
+ _utc_offset->SetSelection (utc_offset + 11);
+
overall_sizer->Layout ();
overall_sizer->SetSizeHints (this);
}
@@ -99,3 +115,9 @@ CinemaDialog::emails () const
copy (_emails.begin(), _emails.end(), back_inserter (e));
return e;
}
+
+int
+CinemaDialog::utc_offset () const
+{
+ return _utc_offset->GetSelection() - 11;
+}
diff --git a/src/wx/cinema_dialog.h b/src/wx/cinema_dialog.h
index 7d27bd94b..a34935e51 100644
--- a/src/wx/cinema_dialog.h
+++ b/src/wx/cinema_dialog.h
@@ -27,10 +27,11 @@
class CinemaDialog : public wxDialog
{
public:
- CinemaDialog (wxWindow *, std::string, std::string name = "", std::list<std::string> emails = std::list<std::string> ());
+ CinemaDialog (wxWindow *, std::string, std::string name = "", std::list<std::string> emails = std::list<std::string> (), int utc_offset = 0);
std::string name () const;
std::list<std::string> emails () const;
+ int utc_offset () const;
private:
std::vector<std::string> get_emails () const;
@@ -39,4 +40,5 @@ private:
wxTextCtrl* _name;
EditableList<std::string, EmailDialog>* _email_list;
std::vector<std::string> _emails;
+ wxChoice* _utc_offset;
};
diff --git a/src/wx/screens_panel.cc b/src/wx/screens_panel.cc
index 63d528b77..a75316d8c 100644
--- a/src/wx/screens_panel.cc
+++ b/src/wx/screens_panel.cc
@@ -149,7 +149,7 @@ ScreensPanel::add_cinema_clicked ()
{
CinemaDialog* d = new CinemaDialog (this, "Add Cinema");
if (d->ShowModal () == wxID_OK) {
- shared_ptr<Cinema> c (new Cinema (d->name(), d->emails()));
+ shared_ptr<Cinema> c (new Cinema (d->name(), d->emails(), d->utc_offset()));
Config::instance()->add_cinema (c);
add_cinema (c);
}
@@ -166,10 +166,11 @@ ScreensPanel::edit_cinema_clicked ()
pair<wxTreeItemId, shared_ptr<Cinema> > c = *_selected_cinemas.begin();
- CinemaDialog* d = new CinemaDialog (this, "Edit cinema", c.second->name, c.second->emails);
+ CinemaDialog* d = new CinemaDialog (this, "Edit cinema", c.second->name, c.second->emails, c.second->utc_offset());
if (d->ShowModal () == wxID_OK) {
c.second->name = d->name ();
c.second->emails = d->emails ();
+ c.second->set_utc_offset (d->utc_offset ());
_targets->SetItemText (c.first, std_to_wx (d->name()));
Config::instance()->changed ();
}