return lexical_cast<float> (s);
}
}
-
-bool
-string_not_empty (string s)
-{
- return !s.empty ();
-}
extern std::string video_asset_filename (boost::shared_ptr<dcp::PictureAsset> asset, int reel_index, int reel_count, boost::optional<std::string> content_summary);
extern std::string audio_asset_filename (boost::shared_ptr<dcp::SoundAsset> asset, int reel_index, int reel_count, boost::optional<std::string> content_summary);
extern float relaxed_string_to_float (std::string);
-extern bool string_not_empty (std::string);
#endif
using std::vector;
using boost::shared_ptr;
using boost::bind;
+using boost::optional;
enum {
ID_help_report_a_problem = 1,
{
}
+
+ optional<dcp::EncryptedKDM> get ()
+ {
+ try {
+ return dcp::EncryptedKDM (dcp::file_to_string (wx_to_std (_dialog->GetPath ())));
+ } catch (cxml::Error& e) {
+ error_dialog (_parent, wxString::Format ("This file does not look like a KDM (%s)", std_to_wx (e.what()).data()));
+ }
+
+ return optional<dcp::EncryptedKDM> ();
+ }
};
static string
vector<string> columns;
columns.push_back (wx_to_std (_("CPL")));
_dkdm = new EditableList<dcp::EncryptedKDM, KDMFileDialogWrapper> (
- overall_panel, columns, bind (&DOMFrame::dkdms, this), bind (&DOMFrame::set_dkdms, this, _1), bind (&always_valid), bind (&column, _1), false
+ overall_panel, columns, bind (&DOMFrame::dkdms, this), bind (&DOMFrame::set_dkdms, this, _1), bind (&column, _1), false
);
right->Add (_dkdm, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_Y_GAP);
vector<string> columns;
columns.push_back (wx_to_std (_("Address")));
_email_list = new EditableList<string, EmailDialog> (
- this, columns, bind (&CinemaDialog::get_emails, this), bind (&CinemaDialog::set_emails, this, _1), bind (&string_not_empty, _1), bind (&column, _1)
+ this, columns, bind (&CinemaDialog::get_emails, this), bind (&CinemaDialog::set_emails, this, _1), bind (&column, _1)
);
sizer->Add (_email_list, wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND);
columns,
boost::bind (&Config::servers, Config::instance()),
boost::bind (&Config::set_servers, Config::instance(), _1),
- boost::bind (&always_valid),
boost::bind (&EncodingServersPage::server_column, this, _1)
);
columns,
bind (&Config::kdm_cc, Config::instance()),
bind (&Config::set_kdm_cc, Config::instance(), _1),
- bind (&string_not_empty, _1),
bind (&column, _1)
);
table->Add (_kdm_cc, 1, wxEXPAND | wxALL);
+++ /dev/null
-/*
- 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/>.
-
-*/
-
-bool
-always_valid ()
-{
- return true;
-}
#include <boost/function.hpp>
#include <vector>
-bool always_valid ();
-
/** @param T type of things being edited.
* @param S dialog to edit a thing.
*/
std::vector<std::string> columns,
boost::function<std::vector<T> ()> get,
boost::function<void (std::vector<T>)> set,
- boost::function<bool (T)> valid,
boost::function<std::string (T, int)> column,
bool can_edit = true,
bool title = true
: wxPanel (parent)
, _get (get)
, _set (set)
- , _valid (valid)
, _columns (columns.size ())
, _column (column)
, _edit (0)
S* dialog = new S (this);
if (dialog->ShowModal() == wxID_OK) {
- T const v = dialog->get ();
- if (_valid (v)) {
- add_to_control (v);
+ boost::optional<T> const v = dialog->get ();
+ if (v) {
+ add_to_control (v.get ());
std::vector<T> all = _get ();
- all.push_back (v);
+ all.push_back (v.get ());
_set (all);
}
}
S* dialog = new S (this);
dialog->set (all[item]);
if (dialog->ShowModal() == wxID_OK) {
- T const v = dialog->get ();
- if (!_valid (v)) {
+ boost::optional<T> const v = dialog->get ();
+ if (!v) {
return;
}
- all[item] = v;
+ all[item] = v.get ();
}
dialog->Destroy ();
boost::function <std::vector<T> ()> _get;
boost::function <void (std::vector<T>)> _set;
- boost::function <bool (T)> _valid;
int _columns;
boost::function<std::string (T, int)> _column;
using std::string;
using boost::shared_ptr;
+using boost::optional;
EmailDialog::EmailDialog (wxWindow* parent)
: TableDialog (parent, _("Email address"), 2, 1, true)
_email->SetValue (std_to_wx (address));
}
-string
+optional<string>
EmailDialog::get () const
{
- return wx_to_std (_email->GetValue ());
+ string s = wx_to_std (_email->GetValue ());
+ if (s.empty ()) {
+ /* Invalid email address */
+ return optional<string> ();
+ }
+
+ return s;
}
*/
#include "table_dialog.h"
+#include <boost/optional.hpp>
class EmailDialog : public TableDialog
{
EmailDialog (wxWindow *);
void set (std::string);
- std::string get () const;
+ boost::optional<std::string> get () const;
private:
wxTextCtrl* _email;
void set (T) {}
- T get ()
+ boost::optional<T> get ()
{
return T (dcp::file_to_string (wx_to_std (_dialog->GetPath ())));
}
delete this;
}
-private:
+protected:
wxWindow* _parent;
wxFileDialog* _dialog;
};
columns,
bind (&ScreenDialog::trusted_devices, this),
bind (&ScreenDialog::set_trusted_devices, this, _1),
- bind (&always_valid),
bind (&column, _1),
false
);
using std::string;
using boost::shared_ptr;
+using boost::optional;
ServerDialog::ServerDialog (wxWindow* parent)
: TableDialog (parent, _("Server"), 2, 1, true)
_host->SetValue (std_to_wx (server));
}
-string
+optional<string>
ServerDialog::get () const
{
return wx_to_std (_host->GetValue ());
ServerDialog (wxWindow *);
void set (std::string);
- std::string get () const;
+ boost::optional<std::string> get () const;
private:
wxTextCtrl* _host;
content_properties_dialog.cc
content_sub_panel.cc
dcp_panel.cc
- editable_list.cc
email_dialog.cc
image_sequence_dialog.cc
image_subtitle_colour_dialog.cc