Merge master.
[dcpomatic.git] / src / wx / content_panel.cc
index 13ae2d88ae6d9abd8e3bd5d0d00c9dff608daab0..991080e590f059e123ca443333d4dd1e26b03886 100644 (file)
@@ -38,6 +38,7 @@
 
 using std::list;
 using std::string;
+using std::cout;
 using boost::shared_ptr;
 using boost::weak_ptr;
 using boost::dynamic_pointer_cast;
@@ -99,6 +100,7 @@ ContentPanel::ContentPanel (wxNotebook* n, boost::shared_ptr<Film> f)
        _content->Bind (wxEVT_COMMAND_LIST_ITEM_SELECTED, boost::bind (&ContentPanel::selection_changed, this));
        _content->Bind (wxEVT_COMMAND_LIST_ITEM_DESELECTED, boost::bind (&ContentPanel::selection_changed, this));
        _content->Bind (wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, boost::bind (&ContentPanel::right_click, this, _1));
+       _content->Bind (wxEVT_DROP_FILES, boost::bind (&ContentPanel::files_dropped, this, _1));
        _add_file->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ContentPanel::add_file_clicked, this));
        _add_folder->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ContentPanel::add_folder_clicked, this));
        _remove->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ContentPanel::remove_clicked, this));
@@ -399,7 +401,7 @@ ContentPanel::set_selection (weak_ptr<Content> wc)
 void
 ContentPanel::film_content_changed (int property)
 {
-       if (property == ContentProperty::PATH || property == ContentProperty::POSITION) {
+       if (property == ContentProperty::PATH || property == ContentProperty::POSITION || property == DCPContentProperty::CAN_BE_PLAYED) {
                setup ();
        }
                
@@ -425,19 +427,26 @@ ContentPanel::setup ()
        for (ContentList::iterator i = content.begin(); i != content.end(); ++i) {
                int const t = _content->GetItemCount ();
                bool const valid = (*i)->paths_valid ();
+               shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (*i);
+               bool const needs_kdm = dcp && !dcp->can_be_played ();
 
                string s = (*i)->summary ();
+               
                if (!valid) {
                        s = _("MISSING: ") + s;
                }
 
+               if (needs_kdm) {
+                       s = _("NEEDS KDM: ") + s;
+               }
+
                _content->InsertItem (t, std_to_wx (s));
 
                if ((*i)->summary() == selected_summary) {
                        _content->SetItemState (t, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
                }
 
-               if (!valid) {
+               if (!valid || needs_kdm) {
                        _content->SetItemTextColour (t, *wxRED);
                }
        }
@@ -448,3 +457,15 @@ ContentPanel::setup ()
        }
 }
 
+void
+ContentPanel::files_dropped (wxDropFilesEvent& event)
+{
+       if (!_film) {
+               return;
+       }
+       
+       wxString* paths = event.GetFiles ();
+       for (int i = 0; i < event.GetNumberOfFiles(); i++) {
+               _film->examine_and_add_content (content_factory (_film, wx_to_std (paths[i])));
+       }
+}