Don't expand all cinemas on opening KDM dialogs (#779).
authorCarl Hetherington <cth@carlh.net>
Fri, 8 Jan 2016 14:49:03 +0000 (14:49 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 8 Jan 2016 14:49:03 +0000 (14:49 +0000)
ChangeLog
src/wx/screens_panel.cc
src/wx/screens_panel.h

index 8e80ea29b960c593c7dcb7c966b4877326566098..3a68a17224b8e1806e8a40e7ad98cd9b4dcfbf9b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2016-01-08  c.hetherington  <cth@carlh.net>
+
+       * Don't expand all cinemas on opening KDM dialogs (#779).
+
 2016-01-07  Carl Hetherington  <cth@carlh.net>
 
        * Version 2.6.14 released.
index a081e2dfccff4f80b7d8d64cedd2b2d7c14c72c1..7a5eb5fad73d9d54a460c798f9b19ec936b871f1 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2015-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,6 +33,7 @@ using std::map;
 using std::string;
 using std::make_pair;
 using boost::shared_ptr;
+using boost::optional;
 
 ScreensPanel::ScreensPanel (wxWindow* parent)
        : wxPanel (parent, wxID_ANY)
@@ -50,8 +51,6 @@ ScreensPanel::ScreensPanel (wxWindow* parent)
 
        add_cinemas ();
 
-       _targets->ExpandAll ();
-
        wxBoxSizer* target_buttons = new wxBoxSizer (wxVERTICAL);
 
        _add_cinema = new wxButton (this, wxID_ANY, _("Add Cinema..."));
@@ -129,7 +128,7 @@ ScreensPanel::add_cinema (shared_ptr<Cinema> c)
        _targets->SortChildren (_root);
 }
 
-void
+optional<wxTreeItemId>
 ScreensPanel::add_screen (shared_ptr<Cinema> c, shared_ptr<Screen> s)
 {
        CinemaMap::const_iterator i = _cinemas.begin();
@@ -138,11 +137,11 @@ ScreensPanel::add_screen (shared_ptr<Cinema> c, shared_ptr<Screen> s)
        }
 
        if (i == _cinemas.end()) {
-               return;
+               return optional<wxTreeItemId> ();
        }
 
        _screens[_targets->AppendItem (i->first, std_to_wx (s->name))] = s;
-       _targets->Expand (i->first);
+       return i->first;
 }
 
 void
@@ -207,7 +206,10 @@ ScreensPanel::add_screen_clicked ()
 
        shared_ptr<Screen> s (new Screen (d->name(), d->recipient(), d->trusted_devices()));
        c->add_screen (s);
-       add_screen (c, s);
+       optional<wxTreeItemId> id = add_screen (c, s);
+       if (id) {
+               _targets->Expand (id.get ());
+       }
 
        Config::instance()->changed ();
 
index 0095937b71d48269bdf79179e2a54e689a532cc0..cc5170d97d680e86879513b8fadd59b862ae0987 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2015-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
@@ -41,7 +41,7 @@ public:
 private:
        void add_cinemas ();
        void add_cinema (boost::shared_ptr<Cinema>);
-       void add_screen (boost::shared_ptr<Cinema>, boost::shared_ptr<Screen>);
+       boost::optional<wxTreeItemId> add_screen (boost::shared_ptr<Cinema>, boost::shared_ptr<Screen>);
        void add_cinema_clicked ();
        void edit_cinema_clicked ();
        void remove_cinema_clicked ();