Don't display first playlist on startup.
[dcpomatic.git] / src / tools / dcpomatic_playlist.cc
index c327a8603d1f11a0c87c73da8ab0f69b7298dbf4..bc1f78dc36432935ca539bc2010ba3df3f514212 100644 (file)
@@ -166,22 +166,33 @@ private:
        void add_playlist_to_model (shared_ptr<SignalSPL> playlist)
        {
                _playlists.push_back (playlist);
-               playlist->NameChanged.connect (bind(&PlaylistList::name_changed, this, weak_ptr<SignalSPL>(playlist)));
+               playlist->Changed.connect(bind(&PlaylistList::changed, this, weak_ptr<SignalSPL>(playlist), _1));
        }
 
-       void name_changed (weak_ptr<SignalSPL> wp)
+       void changed(weak_ptr<SignalSPL> wp, SignalSPL::Change change)
        {
                auto playlist = wp.lock ();
                if (!playlist) {
                        return;
                }
 
-               int N = 0;
-               for (auto i: _playlists) {
-                       if (i == playlist) {
-                               _list->SetItem (N, 0, std_to_wx(i->name()));
+               switch (change) {
+               case SignalSPL::Change::NAME:
+               {
+                       int N = 0;
+                       for (auto i: _playlists) {
+                               if (i == playlist) {
+                                       _list->SetItem (N, 0, std_to_wx(i->name()));
+                               }
+                               ++N;
+                       }
+                       break;
+               }
+               case SignalSPL::Change::CONTENT:
+                       if (auto dir = Config::instance()->player_playlist_directory()) {
+                               playlist->write(*dir / (playlist->id() + ".xml"));
                        }
-                       ++N;
+                       break;
                }
        }
 
@@ -400,9 +411,7 @@ private:
 
                DCPOMATIC_ASSERT (_playlist);
 
-               auto tmp = (*_playlist)[s];
-               (*_playlist)[s] = (*_playlist)[s-1];
-               (*_playlist)[s-1] = tmp;
+               _playlist->swap(s, s - 1);
 
                set_item (s - 1, (*_playlist)[s-1]);
                set_item (s, (*_playlist)[s]);
@@ -417,9 +426,7 @@ private:
 
                DCPOMATIC_ASSERT (_playlist);
 
-               auto tmp = (*_playlist)[s];
-               (*_playlist)[s] = (*_playlist)[s+1];
-               (*_playlist)[s+1] = tmp;
+               _playlist->swap(s, s + 1);
 
                set_item (s + 1, (*_playlist)[s+1]);
                set_item (s, (*_playlist)[s]);
@@ -477,8 +484,6 @@ public:
 
                _playlist_list->Edit.connect (bind(&DOMFrame::change_playlist, this, _1));
 
-               _playlist_content->set (_playlist_list->first_playlist());
-
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_exit, this), wxID_EXIT);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::help_about, this), wxID_ABOUT);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::edit_preferences, this), wxID_PREFERENCES);