X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fengineer%2Fnewtraindialog.cpp;h=ef9fbf82b6dfe79a58924f65f5e34b610b31acd2;hb=5eeb8f5749586b9aae2996d2143e300388d15611;hp=78a3f113b6b0a161ed1ea96e2d6ddddb83a28f60;hpb=b8cf5d2f394c151c6b095396dafdc66162cb060e;p=r2c2.git diff --git a/source/engineer/newtraindialog.cpp b/source/engineer/newtraindialog.cpp index 78a3f11..ef9fbf8 100644 --- a/source/engineer/newtraindialog.cpp +++ b/source/engineer/newtraindialog.cpp @@ -42,10 +42,18 @@ NewTrainDialog::NewTrainDialog(Engineer &e): drp_protocol->set_selected_index(0); - const Catalogue::VehicleMap &cat_vtypes = engineer.get_layout().get_catalogue().get_vehicles(); - for(Catalogue::VehicleMap::const_iterator i=cat_vtypes.begin(); i!=cat_vtypes.end(); ++i) - if(i->second->is_locomotive()) - loco_types.append(i->second); + const Catalogue::ObjectMap &obj_types = engineer.get_layout().get_catalogue().get_all(); + for(Catalogue::ObjectMap::const_iterator i=obj_types.begin(); i!=obj_types.end(); ++i) + if(const VehicleType *vt = dynamic_cast(i->second)) + if(vt->is_locomotive()) + loco_types.append(vt); +} + +void NewTrainDialog::prefill(const Driver::DetectedLocomotive &loco) +{ + drp_protocol->set_selected_index(protocols.find(loco.protocol)); + ent_address->set_text(lexical_cast(loco.address)); + ent_name->set_text(loco.name); } void NewTrainDialog::on_response(int code)