Commit c10439cb authored by Mathieu Faverge's avatar Mathieu Faverge

Move the palette to common directory and cleanuop some spaces

parent c4506771
......@@ -42,13 +42,14 @@
#
SET(VITE_HDRS
common/common.hpp
common/Message.hpp
common/Errors.hpp
common/Tools.hpp
common/Info.hpp
common/Session.hpp
common/Memory.hpp
common/Message.hpp
common/Palette.hpp
common/Session.hpp
common/Tools.hpp
common/common.hpp
# Data structure headers
trace/values/Color.hpp
trace/values/Date.hpp
......@@ -83,7 +84,6 @@ SET(VITE_HDRS
trace/Trace.hpp
trace/IntervalOfContainer.hpp
# Render headers
render/Palette.hpp
render/Render.hpp
render/Geometry.hpp
render/Hook_event.hpp
......@@ -145,12 +145,13 @@ SET(VITE_UIS
SET(VITE_SRCS
# Messages & Errors
common/Message.cpp
common/Errors.cpp
common/Tools.cpp
common/Info.cpp
common/Session.cpp
common/Memory.cpp
common/Message.cpp
common/Palette.cpp
common/Session.cpp
common/Tools.cpp
# Data structure code files
trace/values/Color.cpp
trace/values/Date.cpp
......@@ -177,7 +178,6 @@ SET(VITE_SRCS
trace/Trace.cpp
trace/IntervalOfContainer.cpp
# Render code files
render/Palette.cpp
render/Geometry.cpp
render/Hook_event.cpp
render/Render.hpp
......
......@@ -30,8 +30,8 @@ Color *Palette::get_color(const std::string &state_name) {
bool Palette::is_visible(const std::string &state_name){
return _visible[state_name];
}
}
void Palette::add_state(const std::string &state, Color &c, bool visible) {
if(_pairs.find(state) != _pairs.end()) {
......@@ -43,7 +43,7 @@ void Palette::add_state(const std::string &state, Color &c, bool visible) {
}
void Palette::clear(){
_pairs.clear();
_pairs.clear();
}
std::string Palette::get_name() const {
......
......@@ -60,7 +60,7 @@
/* -- */
#include "trace/values/Value.hpp"
#include "trace/values/Color.hpp"
#include "render/Palette.hpp"
#include "common/Palette.hpp"
#include "common/Session.hpp"
using namespace std;
......@@ -77,11 +77,13 @@ int Session::Minimap::pen_size;
QColor Session::Minimap::pen_color;
QColor Session::Minimap::brush_color;
bool Session::Minimap::is_closed;
Palette *Session::_palette = NULL;
Palette *Session::_link_types = NULL;
Palette *Session::_event_types = NULL;
bool Session::_use_palettes= false;
bool Session::_use_palettes_is_set=false;
QSettings *Session::settings = NULL;
Session::Session() {
......
......@@ -119,7 +119,7 @@ private:
public:
static QSettings *settings;
static Palette *_palette;
// static Palette *_palette;
static Palette * _link_types;
static Palette * _event_types;
......
/*
** This file is part of the ViTE project.
**
** This software is governed by the CeCILL-A license under French law
** and abiding by the rules of distribution of free software. You can
** use, modify and/or redistribute the software under the terms of the
** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following
** URL: "http://www.cecill.info".
**
** As a counterpart to the access to the source code and rights to copy,
** modify and redistribute granted by the license, users are provided
** only with a limited warranty and the software's author, the holder of
** the economic rights, and the successive licensors have only limited
** liability.
**
** In this respect, the user's attention is drawn to the risks associated
** with loading, using, modifying and/or developing or reproducing the
** software by the user in light of its specific status of free software,
** that may mean that it is complicated to manipulate, and that also
** therefore means that it is reserved for developers and experienced
** professionals having in-depth computer knowledge. Users are therefore
** encouraged to load and test the software's suitability as regards
** their requirements in conditions enabling the security of their
** systems and/or data to be ensured and, more generally, to use and
** operate it in the same conditions as regards security.
**
** The fact that you are presently reading this means that you have had
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
** ViTE developers are (for version 0.* to 1.0):
**
** - COULOMB Kevin
** - FAVERGE Mathieu
** - JAZEIX Johnny
** - LAGRASSE Olivier
** - MARCOUEILLE Jule
** - NOISETTE Pascal
** - REDONDY Arthur
** - VUCHENER Clément
**
*/
** This file is part of the ViTE project.
**
** This software is governed by the CeCILL-A license under French law
** and abiding by the rules of distribution of free software. You can
** use, modify and/or redistribute the software under the terms of the
** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following
** URL: "http://www.cecill.info".
**
** As a counterpart to the access to the source code and rights to copy,
** modify and redistribute granted by the license, users are provided
** only with a limited warranty and the software's author, the holder of
** the economic rights, and the successive licensors have only limited
** liability.
**
** In this respect, the user's attention is drawn to the risks associated
** with loading, using, modifying and/or developing or reproducing the
** software by the user in light of its specific status of free software,
** that may mean that it is complicated to manipulate, and that also
** therefore means that it is reserved for developers and experienced
** professionals having in-depth computer knowledge. Users are therefore
** encouraged to load and test the software's suitability as regards
** their requirements in conditions enabling the security of their
** systems and/or data to be ensured and, more generally, to use and
** operate it in the same conditions as regards security.
**
** The fact that you are presently reading this means that you have had
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
** ViTE developers are (for version 0.* to 1.0):
**
** - COULOMB Kevin
** - FAVERGE Mathieu
** - JAZEIX Johnny
** - LAGRASSE Olivier
** - MARCOUEILLE Jule
** - NOISETTE Pascal
** - REDONDY Arthur
** - VUCHENER Clément
**
*/
#include <iostream>
#include <string>
......@@ -69,50 +69,48 @@
using namespace std;
Settings_window::Settings_window(Core *c, QWidget *parent) : QWidget(parent), _c(c) {
setupUi(this);
plugin_load_dirs_name();
reload_general_tab();
_changed=false;
// const string &tabName = tabWidget->tabText(index).toStdString();
// Need to load the current palette.
palette_list->clear();
QStringList palettes;
Session::get_palettes_name("palette", palettes);
palette_list->addItems(palettes);
string current = Session::get_current_palette("palette");
fill_table(current);
palette_list->setCurrentIndex(palette_list->findText(QString::fromStdString(current))); // Set the combobox at the good index.
reload_minimap_tab();
event_types_palette_list->clear();
Session::get_palettes_name("event_types", palettes);
event_types_palette_list->addItems(palettes);
current = Session::get_current_palette("event_types");
// Need to load the types
fill_event_types_table(current);
event_types_palette_list->setCurrentIndex(event_types_palette_list->findText(QString::fromStdString(current))); // Set the combobox at the good index.
link_types_palette_list->clear();
// QStringList palettes;
Session::get_palettes_name("link_types", palettes);
link_types_palette_list->addItems(palettes);
current = Session::get_current_palette("link_types");
// Need to load the types
fill_link_types_table(current);
link_types_palette_list->setCurrentIndex(link_types_palette_list->findText(QString::fromStdString(current))); // Set the combobox at the good index.
setupUi(this);
plugin_load_dirs_name();
reload_general_tab();
_changed=false;
// const string &tabName = tabWidget->tabText(index).toStdString();
// Need to load the current palette.
palette_list->clear();
QStringList palettes;
Session::get_palettes_name("palette", palettes);
palette_list->addItems(palettes);
string current = Session::get_current_palette("palette");
fill_table(current);
palette_list->setCurrentIndex(palette_list->findText(QString::fromStdString(current))); // Set the combobox at the good index.
reload_minimap_tab();
event_types_palette_list->clear();
Session::get_palettes_name("event_types", palettes);
event_types_palette_list->addItems(palettes);
current = Session::get_current_palette("event_types");
// Need to load the types
fill_event_types_table(current);
event_types_palette_list->setCurrentIndex(event_types_palette_list->findText(QString::fromStdString(current))); // Set the combobox at the good index.
link_types_palette_list->clear();
// QStringList palettes;
Session::get_palettes_name("link_types", palettes);
link_types_palette_list->addItems(palettes);
current = Session::get_current_palette("link_types");
// Need to load the types
fill_link_types_table(current);
link_types_palette_list->setCurrentIndex(link_types_palette_list->findText(QString::fromStdString(current))); // Set the combobox at the good index.
}
Settings_window::~Settings_window() {
}
void Settings_window::on_tabWidget_currentChanged(int ) {
}
void Settings_window::show() {
......@@ -183,8 +181,8 @@ void Settings_window::fill_table(const string &palette_name) {
int row = 0;
Palette* p=Session::get_palette("palette",palette_name);
colors = p->get_map();
if(colors.empty() ) { // Loads the colors of the current trace
if(_c->get_trace()) { // Need a trace loaded
_c->get_trace()->get_states_colors(colors);
......@@ -194,15 +192,15 @@ void Settings_window::fill_table(const string &palette_name) {
return;
}
}
for(map<string, Color *>::iterator it = colors.begin() ;
for(map<string, Color *>::iterator it = colors.begin() ;
it != colors.end() ; ++ it) {
add_state_line(row, (*it).first.c_str(), (*it).second, p->is_visible((*it).first));
}
}
void Settings_window::add_state_line(int &row, std::string st_name, Color *c, bool checked) {
......@@ -221,12 +219,12 @@ void Settings_window::add_state_line(int &row, std::string st_name, Color *c, bo
connect(color_widget, SIGNAL(colorChanged(const QColor &)), this, SLOT(state_color_changed(const QColor &)));
states_table->setCellWidget(row, 1, color_widget);
QCheckBox *cb = new QCheckBox();
cb->setChecked(checked);
states_table->setCellWidget(row, 2, cb);
row ++;
}
......@@ -265,38 +263,38 @@ QString Settings_window::copy_palette(QTableWidget* , QComboBox* list, const std
if(QMessageBox::warning(this, tr("ViTE"), tr("Palette already exists.\nAre you sure you want to erase it?"), QMessageBox::Ok | QMessageBox::Cancel) != QMessageBox::Ok) {
return "default";
}
// Save
// We remove the existing one
Session::remove_palette(type,text.toStdString());
}
else { // Adding if not existing in the list
list->addItem(text);
}
list->addItem(text);
}
//write the current palette to the file before copying it
//remove it and then rewrite it (default might have been used with another trace and not be the same)
/* Session::remove_palette(type,current);
Session::create_palette(type,current);
for (int i=0; i<table->rowCount(); i++)
{
if(table->cellWidget(i, 2) && qobject_cast<QCheckBox *>(table->cellWidget(i, 2))->checkState()== Qt::Checked) {
QColor qc= qobject_cast<QtColorPicker *>(table->cellWidget(i, 1))->currentColor();
Color* color= new Color(qc.red()/255., qc.green()/255., qc.blue()/255.);
Session::add_state_to_palette(type, current, table->item(i, 0)->text().toStdString(), *color);
}
}*/
/* Session::remove_palette(type,current);
Session::create_palette(type,current);
for (int i=0; i<table->rowCount(); i++)
{
if(table->cellWidget(i, 2) && qobject_cast<QCheckBox *>(table->cellWidget(i, 2))->checkState()== Qt::Checked) {
QColor qc= qobject_cast<QtColorPicker *>(table->cellWidget(i, 1))->currentColor();
Color* color= new Color(qc.red()/255., qc.green()/255., qc.blue()/255.);
Session::add_state_to_palette(type, current, table->item(i, 0)->text().toStdString(), *color);
}
}*/
//now we can copy the palette
Session::copy_palette(type,current, text.toStdString());
list->setCurrentIndex(list->findText(text));
}
return text;
}
}
void Settings_window::on_copy_palette_btn_clicked() {
QString text= copy_palette(states_table, palette_list, "palette");
......@@ -325,8 +323,7 @@ void Settings_window::on_reload_states_btn_clicked(){
map<string, Color *> colors;
int row = 0;
if(_c->get_trace()) { // Need a trace loaded
_c->get_trace()->get_states_colors(colors);
}
......@@ -334,12 +331,12 @@ void Settings_window::on_reload_states_btn_clicked(){
cerr << "no trace loaded" << endl;
return;
}
for(map<string, Color *>::iterator it = colors.begin() ;
for(map<string, Color *>::iterator it = colors.begin() ;
it != colors.end() ; ++ it) {
add_state_line(row, (*it).first.c_str(), (*it).second, true);
}
}
void Settings_window::on_add_state_btn_clicked() {
......@@ -391,7 +388,7 @@ void Settings_window::state_color_changed(const QColor &qc) {
if(!states_table || !palette_list)
return;
Color color(qc.red()/255., qc.green()/255., qc.blue()/255.);
int row = 0;
while(states_table->cellWidget(row, 1) && states_table->cellWidget(row, 1) != sender()) { // Find the row of the colorPicker
row ++;
......@@ -413,7 +410,7 @@ void Settings_window::event_types_color_changed(const QColor &qc) {
if(!event_types_table || !event_types_palette_list)
return;
Color color(qc.red()/255., qc.green()/255., qc.blue()/255.);
int row = 0;
while(event_types_table->cellWidget(row, 1) && event_types_table->cellWidget(row, 1) != sender()) { // Find the row of the colorPicker
row ++;
......@@ -435,7 +432,7 @@ void Settings_window::link_types_color_changed(const QColor &qc) {
if(!link_types_table || !link_types_palette_list)
return;
Color color(qc.red()/255., qc.green()/255., qc.blue()/255.);
int row = 0;
while(link_types_table->cellWidget(row, 1) && link_types_table->cellWidget(row, 1) != sender()) { // Find the row of the colorPicker
row ++;
......@@ -464,11 +461,11 @@ void Settings_window::fill_event_types_table(const string &palette_name) {
event_types_table->removeRow(0);
}
int row = 0;
int row = 0;
Palette* p=Session::get_palette("event_types",palette_name);
map<string, Color *> colors = p->get_map();
if(colors.empty()/*palette_name == "default"*/) { // Loads the colors of the current trace
if(colors.empty()/*palette_name == "default"*/) { // Loads the colors of the current trace
const map<Name, EventType* > * event_types;
if(_c->get_trace()) { // Need a trace loaded
event_types = _c->get_trace()->get_event_types();
......@@ -477,25 +474,25 @@ void Settings_window::fill_event_types_table(const string &palette_name) {
cerr << "no trace loaded" << endl;
return;
}
for(map<Name, EventType *>::const_iterator it = event_types->begin() ;
it != event_types->end() ; ++ it) {
Color *color = NULL;
if((*it).second->get_extra_fields()!=NULL && ((*it).second->get_extra_fields()->find(string("Color")) != (*it).second->get_extra_fields()->end())) {
color = (Color *)((*it).second->get_extra_fields()->find(string("Color"))->second);
for(map<Name, EventType *>::const_iterator it = event_types->begin() ;
it != event_types->end() ; ++ it) {
Color *color = NULL;
if((*it).second->get_extra_fields()!=NULL && ((*it).second->get_extra_fields()->find(string("Color")) != (*it).second->get_extra_fields()->end())) {
color = (Color *)((*it).second->get_extra_fields()->find(string("Color"))->second);
}
add_event_type_line(row, (*it).first.to_string(), color, true);
}
add_event_type_line(row, (*it).first.to_string(), color, true);
}
}
else { // Look for the state/color pairs in Session.
for(map<string, Color *>::iterator it = colors.begin() ;
for(map<string, Color *>::iterator it = colors.begin() ;
it != colors.end() ; ++ it) {
add_event_type_line(row, (*it).first, (*it).second, p->is_visible((*it).first));
}
}
}
}
......@@ -505,7 +502,7 @@ void Settings_window::add_event_type_line(int &row, std::string st_name, Color *
event_types_table->insertRow(row);
QTableWidgetItem *name = new QTableWidgetItem(st_name.c_str());
name->setFlags(Qt::ItemIsEnabled);
event_types_table->setItem(row, 0, name);
event_types_table->setItem(row, 0, name);
QtColorPicker *color_widget = new QtColorPicker();
color_widget->setStandardColors();
if(c) {
......@@ -515,11 +512,11 @@ void Settings_window::add_event_type_line(int &row, std::string st_name, Color *
color_widget->setCurrentColor(QColor(255, 255, 255));
}
color_widget->setColorDialogEnabled(false);
connect(color_widget, SIGNAL(colorChanged(const QColor &)), this, SLOT( event_types_color_changed(const QColor &)));
event_types_table->setCellWidget(row, 1, color_widget);
event_types_table->setCellWidget(row, 1, color_widget);
QCheckBox *cb = new QCheckBox();
cb->setChecked(checked);
event_types_table->setCellWidget(row, 2, cb);
......@@ -533,12 +530,11 @@ void Settings_window::fill_link_types_table(const string &palette_name) {
link_types_table->removeRow(0);
}
int row = 0;
Palette* p= Session::get_palette("link_types",palette_name);
map<string, Color *> colors = p->get_map();
if(colors.empty()/*palette_name == "default"*/) { // Loads the colors of the current trace
const map<Name, LinkType* > * link_types;
const map<Name, LinkType* > * link_types;
if(_c->get_trace()) { // Need a trace loaded
link_types = _c->get_trace()->get_link_types();
}
......@@ -546,29 +542,29 @@ void Settings_window::fill_link_types_table(const string &palette_name) {
cerr << "no trace loaded" << endl;
return;
}
for(map<Name, LinkType *>::const_iterator it = link_types->begin() ;
it != link_types->end() ; ++ it) {
Color *color = NULL;
if((*it).second->get_extra_fields()!=NULL && ((*it).second->get_extra_fields()->find(string("Color")) != (*it).second->get_extra_fields()->end())) {
color = (Color *)((*it).second->get_extra_fields()->find(string("Color"))->second);
for(map<Name, LinkType *>::const_iterator it = link_types->begin() ;
it != link_types->end() ; ++ it) {
Color *color = NULL;
if((*it).second->get_extra_fields()!=NULL && ((*it).second->get_extra_fields()->find(string("Color")) != (*it).second->get_extra_fields()->end())) {
color = (Color *)((*it).second->get_extra_fields()->find(string("Color"))->second);
}
add_link_type_line(row, (*it).first.to_string(), color, true);
}
add_link_type_line(row, (*it).first.to_string(), color, true);
}
}
else { // Look for the state/color pairs in Session.
for(map<string, Color *>::iterator it = colors.begin() ;
it != colors.end() ; ++ it) {
for(map<string, Color *>::iterator it = colors.begin() ;
it != colors.end() ; ++ it) {
add_link_type_line(row, (*it).first, (*it).second, p->is_visible((*it).first));
}
}
}
}
......@@ -578,7 +574,7 @@ void Settings_window::add_link_type_line(int &row, std::string st_name, Color *c
link_types_table->insertRow(row);
QTableWidgetItem *name = new QTableWidgetItem(st_name.c_str());
name->setFlags(Qt::ItemIsEnabled);
link_types_table->setItem(row, 0, name);
link_types_table->setItem(row, 0, name);
QtColorPicker *color_widget = new QtColorPicker();
color_widget->setStandardColors();
if(c) {
......@@ -588,11 +584,11 @@ void Settings_window::add_link_type_line(int &row, std::string st_name, Color *c
color_widget->setCurrentColor(QColor(255, 255, 255));
}
color_widget->setColorDialogEnabled(false);
connect(color_widget, SIGNAL(colorChanged(const QColor &)), this, SLOT( link_types_color_changed(const QColor &)));
link_types_table->setCellWidget(row, 1, color_widget);
link_types_table->setCellWidget(row, 1, color_widget);
QCheckBox *cb = new QCheckBox();
cb->setChecked(checked);
link_types_table->setCellWidget(row, 2, cb);
......@@ -615,9 +611,9 @@ void Settings_window::on_reload_link_types_palette_btn_clicked() {
while(link_types_table->rowCount() > 0) { // Clear the current table
link_types_table->removeRow(0);
}
int row = 0;
int row = 0;
//add_palette(link_types_palette_list, "link_types" );
const map<Name, LinkType* > * link_types;
const map<Name, LinkType* > * link_types;
if(_c->get_trace()) { // Need a trace loaded
link_types = _c->get_trace()->get_link_types();
}
......@@ -625,19 +621,19 @@ void Settings_window::on_reload_link_types_palette_btn_clicked() {
cerr << "no trace loaded" << endl;
return;
}
for(map<Name, LinkType *>::const_iterator it = link_types->begin() ;
it != link_types->end() ; ++ it) {
for(map<Name, LinkType *>::const_iterator it = link_types->begin() ;
it != link_types->end() ; ++ it) {
Color *color = NULL;
if((*it).second->get_extra_fields()!=NULL && ((*it).second->get_extra_fields()->find(string("Color")) != (*it).second->get_extra_fields()->end())) {
color = (Color *)((*it).second->get_extra_fields()->find(string("Color"))->second);
}
add_link_type_line(row, (*it).first.to_string(), color, true);
}
}
void Settings_window::on_reload_event_types_palette_btn_clicked() {
......@@ -645,9 +641,9 @@ void Settings_window::on_reload_event_types_palette_btn_clicked() {
while(event_types_table->rowCount() > 0) { // Clear the current table
event_types_table->removeRow(0);
}
int row = 0;
int row = 0;
//add_palette(link_types_palette_list, "link_types" );
const map<Name, EventType* > * event_types;
const map<Name, EventType* > * event_types;
if(_c->get_trace()) { // Need a trace loaded
event_types = _c->get_trace()->get_event_types();
}
......@@ -655,16 +651,16 @@ void Settings_window::on_reload_event_types_palette_btn_clicked() {
cerr << "no trace loaded" << endl;
return;
}
for(map<Name, EventType *>::const_iterator it = event_types->begin() ;
it != event_types->end() ; ++ it) {
for(map<Name, EventType *>::const_iterator it = event_types->begin() ;
it != event_types->end() ; ++ it) {
Color *color = NULL;
if((*it).second->get_extra_fields()!=NULL && ((*it).second->get_extra_fields()->find(string("Color")) != (*it).second->get_extra_fields()->end())) {
color = (Color *)((*it).second->get_extra_fields()->find(string("Color"))->second);
}
add_event_type_line(row, (*it).first.to_string(), color, true);
}
}
......@@ -719,70 +715,70 @@ void Settings_window::on_apply_clicked() {
Session::set_use_palette("palette",use_palette_cb->isChecked());
Session::set_use_palette("link_types",use_palette_cb->isChecked());
Session::set_use_palette("event_types",use_palette_cb->isChecked());
// The minimap tab
minimap_hide_cb->setChecked(Session::Minimap::is_closed);
minimap_x_sb->setValue(Session::Minimap::x);
minimap_y_sb->setValue(Session::Minimap::y);
minimap_w_sb->setValue(Session::Minimap::width);
minimap_h_sb->setValue(Session::Minimap::height);
/*cout <<minimap_x_sb->value() << " " << minimap_y_sb->value() <<" " <<
minimap_w_sb->value() <<" " << minimap_h_sb->value() <<" " <<
minimap_hide_cb->isChecked() << endl;*/
/*cout <<minimap_x_sb->value() << " " << minimap_y_sb->value() <<" " <<
minimap_w_sb->value() <<" " << minimap_h_sb->value() <<" " <<
minimap_hide_cb->isChecked() << endl;*/
Session::save_minimap(minimap_x_sb->value(), minimap_y_sb->value(),
minimap_w_sb->value(), minimap_h_sb->value(),
minimap_hide_cb->isChecked());
//set the types to display
//Session::set_custom_types(true);
//Session::clear_event_type();
//Session::clear_link_type();
Session::remove_palette("palette", palette_list->currentText().toStdString());
Session::create_palette("palette", palette_list->currentText().toStdString());
Session::remove_palette("link_types", link_types_palette_list->currentText().toStdString());
Session::create_palette("link_types", link_types_palette_list->currentText().toStdString());
Session::remove_palette("event_types", event_types_palette_list->currentText().toStdString());
Session::create_palette("event_types", event_types_palette_list->currentText().toStdString());
for (int i=0; i<states_table->rowCount(); i++)
{
if(states_table->cellWidget(i, 2))
if(states_table->cellWidget(i, 2))
{
QColor qc= qobject_cast<QtColorPicker *>(states_table->cellWidget(i, 1))->currentColor();
Color* color= new Color(qc.red()/255., qc.green()/255., qc.blue()/255.);
//Session::add_link_type(states_table->item(i, 0)->text().toStdString(), *color);
Session::add_state_to_palette("palette", palette_list->currentText().toStdString(), states_table->item(i, 0)->text().toStdString(), *color, qobject_cast<QCheckBox *>(states_table->cellWidget(i, 2))->checkState()== Qt::Checked);
QColor qc= qobject_cast<QtColorPicker *>(states_table->cellWidget(i, 1))->currentColor();
Color* color= new Color(qc.red()/255., qc.green()/255., qc.blue()/255.);
//Session::add_link_type(states_table->item(i, 0)->text().toStdString(), *color);
Session::add_state_to_palette("palette", palette_list->currentText().toStdString(), states_table->item(i, 0)->text().toStdString(), *color, qobject_cast<QCheckBox *>(states_table->cellWidget(i, 2))->checkState()== Qt::Checked);
}
}
for (int i=0; i<link_types_table->rowCount(); i++)
{
if(link_types_table->cellWidget(i, 2))
if(link_types_table->cellWidget(i, 2))