- Completed the management of add-related actions on the schedulables tree view
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@920 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
8c3d8b4878
commit
d60a7aa25e
7 changed files with 1341 additions and 857 deletions
|
@ -44,12 +44,19 @@ AddRequestDialog::AddRequestDialog(BaseObjectType* cobject, const RefPtr<Xml>& g
|
|||
_glade->get_widget("Add", _add_button);
|
||||
_glade->get_widget("Remove", _remove_button);
|
||||
_glade->get_widget("Resource.Combo", _resource_combo);
|
||||
|
||||
|
||||
_glade->get_widget("OK.Button", _ok_button);
|
||||
|
||||
/** ATTACH SIGNAL HANDLERS FOR BUTTONS **/
|
||||
|
||||
_add_button->signal_clicked().connect(sigc::mem_fun(*this, &AddRequestDialog::_on_add));
|
||||
_remove_button->signal_clicked().connect(sigc::mem_fun(*this, &AddRequestDialog::_on_remove));
|
||||
_add_button->signal_clicked().connect(
|
||||
sigc::mem_fun(*this, &AddRequestDialog::_on_add));
|
||||
|
||||
_remove_button->signal_clicked().connect(
|
||||
sigc::mem_fun(*this, &AddRequestDialog::_on_remove));
|
||||
|
||||
_ok_button->set_sensitive(false);
|
||||
_remove_button->set_sensitive(false);
|
||||
_add_button->set_sensitive(false);
|
||||
|
||||
/** INITIALIZE COMBOBOX **/
|
||||
_combo_columns.add(_combo_key_column);
|
||||
|
@ -59,6 +66,9 @@ AddRequestDialog::AddRequestDialog(BaseObjectType* cobject, const RefPtr<Xml>& g
|
|||
_resource_combo->set_model(_combo_model);
|
||||
_resource_combo->pack_start(_combo_key_column, false);
|
||||
_resource_combo->pack_start(_combo_resource_column, true);
|
||||
|
||||
_resource_combo->signal_changed().connect(
|
||||
sigc::mem_fun(*this, &AddRequestDialog::_on_combo_selection_changed));
|
||||
|
||||
/** INITIALIZE LISTVIEW **/
|
||||
|
||||
|
@ -69,14 +79,43 @@ AddRequestDialog::AddRequestDialog(BaseObjectType* cobject, const RefPtr<Xml>& g
|
|||
_list_model = ListStore::create(_list_columns);
|
||||
_list->set_model(_list_model);
|
||||
|
||||
_list_model->signal_row_deleted().connect(
|
||||
sigc::mem_fun(*this, &AddRequestDialog::_on_row_removed));
|
||||
|
||||
_list_model->signal_row_inserted().connect(
|
||||
sigc::mem_fun(*this, &AddRequestDialog::_on_row_added));
|
||||
|
||||
_list->append_column(_("key"), _list_key_column);
|
||||
_list->append_column(_("resource"), _list_resource_column);
|
||||
_list->append_column(_("length"), _list_length_column);
|
||||
|
||||
_list->get_selection()->signal_changed().connect(
|
||||
sigc::mem_fun(*this, &AddRequestDialog::_on_selection_changed));
|
||||
sigc::mem_fun(*this, &AddRequestDialog::_on_list_selection_changed));
|
||||
|
||||
Simulation::get_instance().get_history().add_resource("guitar");
|
||||
Simulation::get_instance().get_history().add_resource("drums");
|
||||
}
|
||||
|
||||
Request&
|
||||
AddRequestDialog::construct_request(Thread& owner)
|
||||
{
|
||||
assert(_list_model->children());
|
||||
|
||||
SpinButton* instant_spin;
|
||||
_glade->get_widget("Instant.Spin", instant_spin);
|
||||
|
||||
History& h = Simulation::get_instance().get_history();
|
||||
|
||||
Request& r = h.add_request(owner, instant_spin->get_value_as_int());
|
||||
|
||||
TreeNodeChildren sreq_container = _list_model->children();
|
||||
|
||||
for(Iseq<TreeIter> it = iseq(sreq_container); it; ++it)
|
||||
h.add_subrequest(r, (*it)[_list_key_column], (*it)[_list_length_column]);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
void
|
||||
AddRequestDialog::on_show()
|
||||
{
|
||||
|
@ -95,7 +134,7 @@ AddRequestDialog::on_show()
|
|||
row[_combo_key_column] = it->first;
|
||||
row[_combo_resource_column] = it->second->get_name();
|
||||
}
|
||||
|
||||
|
||||
Dialog::on_show();
|
||||
}
|
||||
|
||||
|
@ -104,23 +143,20 @@ AddRequestDialog::_on_add()
|
|||
{
|
||||
TreeModel::iterator sel = _resource_combo->get_active();
|
||||
|
||||
if(sel)
|
||||
{
|
||||
SpinButton* duration_spin;
|
||||
|
||||
_glade->get_widget("Duration.Spin", duration_spin);
|
||||
SpinButton* duration_spin;
|
||||
|
||||
TreeModel::Row row = *(_list_model->append());
|
||||
_glade->get_widget("Duration.Spin", duration_spin);
|
||||
|
||||
const unsigned int key = (*sel)[_combo_key_column];
|
||||
row[_list_key_column] = key;
|
||||
TreeModel::Row row = *(_list_model->append());
|
||||
|
||||
const ustring resource = (*sel)[_combo_resource_column];
|
||||
row[_list_resource_column] = resource;
|
||||
const unsigned int key = (*sel)[_combo_key_column];
|
||||
row[_list_key_column] = key;
|
||||
|
||||
const unsigned int length = duration_spin->get_value_as_int();
|
||||
row[_list_length_column] = length;
|
||||
}
|
||||
const ustring resource = (*sel)[_combo_resource_column];
|
||||
row[_list_resource_column] = resource;
|
||||
|
||||
const unsigned int length = duration_spin->get_value_as_int();
|
||||
row[_list_length_column] = length;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -131,9 +167,28 @@ AddRequestDialog::_on_remove()
|
|||
}
|
||||
|
||||
void
|
||||
AddRequestDialog::_on_selection_changed()
|
||||
AddRequestDialog::_on_list_selection_changed()
|
||||
{
|
||||
_remove_button->set_sensitive(
|
||||
_list->get_selection()->count_selected_rows() > 0);
|
||||
}
|
||||
|
||||
void
|
||||
AddRequestDialog::_on_row_added(const Gtk::TreePath& path, const Gtk::TreeIter& it)
|
||||
{
|
||||
_ok_button->set_sensitive(true);
|
||||
}
|
||||
|
||||
void
|
||||
AddRequestDialog::_on_row_removed(const Gtk::TreePath& path)
|
||||
{
|
||||
_ok_button->set_sensitive(static_cast<bool>(_list_model->children()));
|
||||
}
|
||||
|
||||
void
|
||||
AddRequestDialog::_on_combo_selection_changed()
|
||||
{
|
||||
_add_button->set_sensitive(
|
||||
static_cast<bool>(_resource_combo->get_active()));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue