ClienteTFG/controller_info.cpp

44 lines
1.3 KiB
C++
Raw Normal View History

#include "controller_info.h"
controller_info::controller_info(view_info *view, session_manager *sesion)
{
this->view=view;
this->sesion=sesion;
this->load_info();
2020-05-26 18:09:22 +02:00
this->add_controlers();
}
void controller_info::load_info(){
std::list<std::string> list=this->sesion->get_packages_info();
for(std::string data:list){
Gtk::TreeModel::Row row = *(this->view->m_refTreeModel->append());
row[this->view->m_Columns.r_name]=get_first(data);
row[this->view->m_Columns.r_date]=get_first(data);
row[this->view->m_Columns.r_config]=(get_first(data)=="t");
row[this->view->m_Columns.r_user]=get_first(data);
}
}
2020-05-20 00:09:18 +02:00
std::string controller_info::get_first(std::string &info){
int pos = info.find(":");
std::string ret = info.substr(0, pos);
info=info.substr(pos+1, info.size()+1);
return ret;
}
2020-05-26 18:09:22 +02:00
void controller_info::add_controlers(){
this->view->b_remove.signal_clicked().connect(sigc::mem_fun(this,
&controller_info::on_button_clicked));
}
void controller_info::on_button_clicked(){
Gtk::TreeModel::Row row = *this->view->tree.get_selection()->get_selected();
std::string name=row.get_value(this->view->m_Columns.r_name);
if(name.find("Gtk-CRITICAL **:")==std::string::npos){
this->sesion->remove_command(name);
}
this->view->restart_table();
this->load_info();
}