]> git.tdb.fi Git - r2c2.git/commitdiff
Some refactoring in preparation for UI persistence
authorMikko Rasa <tdb@tdb.fi>
Fri, 3 Apr 2015 22:40:03 +0000 (01:40 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 3 Apr 2015 22:40:03 +0000 (01:40 +0300)
source/engineer/departuresdialog.cpp
source/engineer/departuresdialog.h
source/engineer/traindialog.cpp
source/engineer/traindialog.h

index e1f99a399f01345a11323f2c44750b0c7a0b5cf9..a1a31121447a7e825dc75a628fa51f1d59850934 100644 (file)
@@ -47,9 +47,13 @@ DeparturesDialog::DeparturesDialog(const Layout &l, const string &group):
        }
 }
 
-void DeparturesDialog::group_selected(unsigned index)
+void DeparturesDialog::set_group(const string &group)
 {
-       const string &group = groups.get(index);
+       int index = groups.find(group);
+       if(index<0)
+               throw key_error(group);
+       drp_groups->set_selected_index(index);
+
        lbl_title->set_text("Departures from "+group);
 
        for(vector<Row>::iterator i=rows.begin(); i!=rows.end(); ++i)
@@ -63,6 +67,11 @@ void DeparturesDialog::group_selected(unsigned index)
        update_rows();
 }
 
+void DeparturesDialog::group_selected(unsigned index)
+{
+       set_group(groups.get(index));
+}
+
 void DeparturesDialog::update_rows()
 {
        const list<Departures::Departure> &deps = departures->get_departures();
index 098fab82bf614b319531b4e0767393a1bcce6d65..3b7b2ce11fb6da9144f376da68e06dfac3976b8e 100644 (file)
@@ -31,6 +31,8 @@ private:
 public:
        DeparturesDialog(const R2C2::Layout &, const std::string & = std::string());
 
+       void set_group(const std::string &);
+
 private:
        void group_selected(unsigned);
        void update_rows();
index 432f3dd22c99b98f7ea8d212b2dfeb73db861b9c..6aa469a37bc7edc85403c694c2b321f9c2e51186 100644 (file)
@@ -134,8 +134,13 @@ void TrainDialog::ui_forward_toggled(bool value)
 
 void TrainDialog::expand_clicked()
 {
-       pnl_expander->set_visible(!pnl_expander->is_visible());
-       btn_expand->set_style(pnl_expander->is_visible() ? "arrow_up" : "arrow_down");
+       set_expanded(!pnl_expander->is_visible());
+}
+
+void TrainDialog::set_expanded(bool e)
+{
+       pnl_expander->set_visible(e);
+       btn_expand->set_style(e ? "arrow_up" : "arrow_down");
        signal_autosize_changed.emit();
        find_ancestor<GLtk::Root>()->get_layout()->update();
 }
index 545c3b0dae3afc0d1380e8f570dce783c4ad12b1..3d6d1438895544ba6bb8780823c8fc8fa3b81c08 100644 (file)
@@ -37,6 +37,7 @@ private:
        void update_forward(bool);
        void ui_forward_toggled(bool);
        void expand_clicked();
+       void set_expanded(bool);
        void toggle_panel(bool, Msp::GLtk::Panel *);
 };