- bool const sc = selected_cinemas().size() == 1;
- bool const ss = selected_screens().size() == 1;
-
- _edit_cinema->Enable (sc);
- _remove_cinema->Enable (sc);
-
- _add_screen->Enable (sc);
- _edit_screen->Enable (ss);
- _remove_screen->Enable (ss);
-
- wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK));
- ok->Enable (sc || ss);
-
- _folder->Enable (_write_to->GetValue ());
-}
-
-void
-KDMDialog::add_cinema (shared_ptr<Cinema> c)
-{
- _cinemas[_targets->AppendItem (_root, std_to_wx (c->name))] = c;
-
- list<shared_ptr<Screen> > sc = c->screens ();
- for (list<shared_ptr<Screen> >::iterator i = sc.begin(); i != sc.end(); ++i) {
- add_screen (c, *i);
- }
-}
-
-void
-KDMDialog::add_screen (shared_ptr<Cinema> c, shared_ptr<Screen> s)
-{
- map<wxTreeItemId, shared_ptr<Cinema> >::const_iterator i = _cinemas.begin();
- while (i != _cinemas.end() && i->second != c) {
- ++i;
- }
-
- if (i == _cinemas.end()) {
- return;
- }
-
- _screens[_targets->AppendItem (i->first, std_to_wx (s->name))] = s;
-}
-
-void
-KDMDialog::add_cinema_clicked ()
-{
- CinemaDialog* d = new CinemaDialog (this, "Add Cinema");
- d->ShowModal ();
-
- shared_ptr<Cinema> c (new Cinema (d->name(), d->email()));
- Config::instance()->add_cinema (c);
- add_cinema (c);
-
- Config::instance()->write ();
-
- d->Destroy ();
-}
-
-void
-KDMDialog::edit_cinema_clicked ()
-{
- if (selected_cinemas().size() != 1) {
- return;
- }
-
- pair<wxTreeItemId, shared_ptr<Cinema> > c = selected_cinemas().front();
-
- CinemaDialog* d = new CinemaDialog (this, "Edit cinema", c.second->name, c.second->email);
- d->ShowModal ();
-
- c.second->name = d->name ();
- c.second->email = d->email ();
- _targets->SetItemText (c.first, std_to_wx (d->name()));
-
- Config::instance()->write ();
-
- d->Destroy ();
-}
-
-void
-KDMDialog::remove_cinema_clicked ()
-{
- if (selected_cinemas().size() != 1) {
- return;
- }
-
- pair<wxTreeItemId, shared_ptr<Cinema> > c = selected_cinemas().front();
-
- Config::instance()->remove_cinema (c.second);
- _targets->Delete (c.first);
-
- Config::instance()->write ();