- 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()));
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,12 @@
|
|||
#ifndef ADD_REQUEST_DIALOG_HH
|
||||
#define ADD_REQUEST_DIALOG_HH 1
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
class Request;
|
||||
class Thread;
|
||||
}
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtkmm/treeview.h>
|
||||
|
@ -36,13 +42,24 @@ namespace sgpem
|
|||
public:
|
||||
AddRequestDialog(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& glade);
|
||||
|
||||
/**
|
||||
\brief Attemts to build a request by using the data supplied
|
||||
up to now.
|
||||
\note Must be called only after it has been shown at least
|
||||
one time with an OK, otherwise expect undefined behaviour!
|
||||
*/
|
||||
Request& construct_request(Thread& t);
|
||||
|
||||
protected:
|
||||
virtual void on_show();
|
||||
|
||||
private:
|
||||
void _on_add();
|
||||
void _on_remove();
|
||||
void _on_selection_changed();
|
||||
void _on_list_selection_changed();
|
||||
void _on_row_added(const Gtk::TreePath& path, const Gtk::TreeIter& it);
|
||||
void _on_row_removed(const Gtk::TreePath& path);
|
||||
void _on_combo_selection_changed();
|
||||
|
||||
Glib::RefPtr<Gnome::Glade::Xml> _glade;
|
||||
Gtk::TreeView* _list;
|
||||
|
@ -54,6 +71,7 @@ namespace sgpem
|
|||
|
||||
Gtk::Button* _add_button;
|
||||
Gtk::Button* _remove_button;
|
||||
Gtk::Button* _ok_button;
|
||||
|
||||
Gtk::ComboBox* _resource_combo;
|
||||
Glib::RefPtr<Gtk::ListStore> _combo_model;
|
||||
|
|
|
@ -244,18 +244,6 @@ SchedulablesTreeWidget::_on_add_process()
|
|||
void
|
||||
SchedulablesTreeWidget::_on_add_thread()
|
||||
{
|
||||
// TreeModel::iterator sel = get_selection()->get_selected();
|
||||
//
|
||||
// if(!sel)
|
||||
// return;
|
||||
//
|
||||
// const void* p_handle = (*sel)[_handles_column];
|
||||
// HandleType type = (*sel)[_types_column];
|
||||
// Process* p = reinterpret_cast<Process*>(const_cast<void*>(p_handle));
|
||||
//
|
||||
// if(p == NULL || type != htype_process)
|
||||
// return;
|
||||
|
||||
Process* p = get_selected_process();
|
||||
if(p == NULL)
|
||||
return;
|
||||
|
@ -286,26 +274,13 @@ SchedulablesTreeWidget::_on_add_thread()
|
|||
void
|
||||
SchedulablesTreeWidget::_on_add_request()
|
||||
{
|
||||
// TreeModel::iterator sel = get_selection()->get_selected();
|
||||
//
|
||||
// if(!sel)
|
||||
// return;
|
||||
//
|
||||
// const void* p_handle = (*sel)[_handles_column];
|
||||
// HandleType type = (*sel)[_types_column];
|
||||
// Thread* t = reinterpret_cast<Thread*>(const_cast<void*>(p_handle));
|
||||
//
|
||||
// if(t == NULL || type != htype_thread)
|
||||
// return;
|
||||
Thread* t = get_selected_thread();
|
||||
|
||||
if(t == NULL)
|
||||
return;
|
||||
|
||||
if(_add_request_dialog->run() == RESPONSE_OK)
|
||||
{
|
||||
//FIXME writre code for me :-)
|
||||
}
|
||||
_add_request_dialog->construct_request(*t);
|
||||
|
||||
_add_request_dialog->hide();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue