sgpemv2/src/add_request_dialog.cc

102 lines
2.9 KiB
C++
Raw Normal View History

// src/add_request_dialog.cc - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "add_request_dialog.hh"
#include "templates/sequences.tcc"
#include "backend/history.hh"
#include "backend/environment.hh"
#include "backend/simulation.hh"
#include "backend/resource.hh"
#include <iostream>
#include <sstream>
#include "gettext.h"
using namespace sgpem;
using namespace Gtk;
using namespace Glib;
using Gnome::Glade::Xml;
AddRequestDialog::AddRequestDialog(BaseObjectType* cobject, const RefPtr<Xml>& glade) :
Dialog(cobject)
{
glade->get_widget("SubRequests.View", _list);
glade->get_widget("Add", _add_button);
glade->get_widget("Add", _remove_button);
glade->get_widget("Resource.Combo", _resource_combo);
/** 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));
/** INITIALIZE COMBOBOX **/
_combo_columns.add(_combo_key_column);
_combo_columns.add(_combo_resource_column);
_combo_model = ListStore::create(_combo_columns);
_resource_combo->set_model(_combo_model);
/** INITIALIZE LISTVIEW **/
_list_columns.add(_list_resource_column);
_list_columns.add(_list_length_column);
_list_model = ListStore::create(_list_columns);
_list->set_model(_list_model);
_list->append_column(_("resource"), _list_resource_column);
_list->append_column(_("length"), _list_length_column);
}
void
AddRequestDialog::on_show()
{
typedef Environment::Resources::const_iterator ResourceIt;
Dialog::on_show();
const Environment::Resources& resources =
Simulation::get_instance().get_history().get_last_environment().get_resources();
_combo_model->clear();
for(Iseq<ResourceIt> it = const_iseq(resources); it; ++it)
{
TreeModel::Row row = *(_combo_model->append());
row[_combo_key_column] = it->first;
row[_combo_resource_column] = it->second->get_name();
}
}
void
AddRequestDialog::_on_add()
{
//TODO
}
void
AddRequestDialog::_on_remove()
{
//TODO
}