Tidying.
[dcpomatic.git] / src / wx / content_menu.cc
index e7ce3cc9c92a34fca9422267ff5a5e59be04d2e0..fe117aac03521e9f1d198a512d62b84667d91852 100644 (file)
 */
 
 
+#include "content_advanced_dialog.h"
 #include "content_menu.h"
+#include "content_properties_dialog.h"
 #include "repeat_dialog.h"
-#include "wx_util.h"
-#include "timeline_video_content_view.h"
 #include "timeline_audio_content_view.h"
-#include "content_properties_dialog.h"
-#include "content_advanced_dialog.h"
-#include "lib/playlist.h"
-#include "lib/film.h"
-#include "lib/image_content.h"
+#include "timeline_video_content_view.h"
+#include "wx_util.h"
+#include "lib/audio_content.h"
+#include "lib/config.h"
 #include "lib/content_factory.h"
-#include "lib/examine_content_job.h"
-#include "lib/job_manager.h"
-#include "lib/exceptions.h"
+#include "lib/copy_dcp_details_to_film.h"
 #include "lib/dcp_content.h"
 #include "lib/dcp_examiner.h"
+#include "lib/examine_content_job.h"
+#include "lib/exceptions.h"
 #include "lib/ffmpeg_content.h"
-#include "lib/audio_content.h"
-#include "lib/config.h"
-#include "lib/copy_dcp_details_to_film.h"
+#include "lib/film.h"
+#include "lib/image_content.h"
+#include "lib/job_manager.h"
+#include "lib/playlist.h"
 #include <dcp/cpl.h>
-#include <dcp/exceptions.h>
 #include <dcp/decrypted_kdm.h>
-#include <wx/wx.h>
+#include <dcp/exceptions.h>
+#include <dcp/search.h>
 #include <wx/dirdlg.h>
-#include <iostream>
+#include <wx/wx.h>
 
 
-using std::cout;
-using std::vector;
+using std::dynamic_pointer_cast;
 using std::exception;
 using std::list;
+using std::make_shared;
 using std::shared_ptr;
+using std::vector;
 using std::weak_ptr;
-using std::dynamic_pointer_cast;
-using std::make_shared;
 using boost::optional;
 #if BOOST_VERSION >= 106100
 using namespace boost::placeholders;
@@ -145,8 +144,7 @@ ContentMenu::popup (weak_ptr<Film> film, ContentList c, TimelineContentViewList
                        _ov->Enable (dcp->needs_assets ());
                        _set_dcp_settings->Enable (static_cast<bool>(dcp));
                        try {
-                               DCPExaminer ex (dcp, true);
-                               auto cpls = ex.cpls ();
+                               auto cpls = dcp::find_and_resolve_cpls (dcp->directories(), true);
                                _choose_cpl->Enable (cpls.size() > 1);
                                /* We can't have 0 as a menu item ID on OS X */
                                int id = 1;
@@ -336,7 +334,7 @@ ContentMenu::find_missing ()
                path = wx_to_std (d->GetPath ());
                d->Destroy ();
        } else {
-               auto d = new wxFileDialog (0, _("Choose a file"), wxT (""), wxT (""), wxT ("*.*"), wxFD_MULTIPLE);
+               auto d = new wxFileDialog (0, _("Choose a file"), wxT (""), wxT (""), wxT ("*.*"));
                r = d->ShowModal ();
                path = wx_to_std (d->GetPath ());
                d->Destroy ();
@@ -437,16 +435,9 @@ ContentMenu::kdm ()
                        return;
                }
 
-               DCPExaminer ex (dcp, true);
-
-               bool kdm_matches_any_cpl = false;
-               for (auto i: ex.cpls()) {
-                       if (i->id() == kdm->cpl_id()) {
-                               kdm_matches_any_cpl = true;
-                       }
-               }
-
-               bool kdm_matches_selected_cpl = dcp->cpl() || kdm->cpl_id() == dcp->cpl().get();
+               auto cpls = dcp::find_and_resolve_cpls (dcp->directories(), true);
+               bool const kdm_matches_any_cpl = std::any_of(cpls.begin(), cpls.end(), [kdm](shared_ptr<const dcp::CPL> cpl) { return cpl->id() == kdm->cpl_id(); });
+               bool const kdm_matches_selected_cpl = dcp->cpl() || kdm->cpl_id() == dcp->cpl().get();
 
                if (!kdm_matches_any_cpl) {
                        error_dialog (_parent, _("This KDM was not made for this DCP.  You will need a different one."));
@@ -517,8 +508,7 @@ ContentMenu::cpl_selected (wxCommandEvent& ev)
        auto dcp = dynamic_pointer_cast<DCPContent> (_content.front());
        DCPOMATIC_ASSERT (dcp);
 
-       DCPExaminer ex (dcp, true);
-       auto cpls = ex.cpls ();
+       auto cpls = dcp::find_and_resolve_cpls (dcp->directories(), true);
        DCPOMATIC_ASSERT (ev.GetId() > 0);
        DCPOMATIC_ASSERT (ev.GetId() <= int (cpls.size()));