Commit 9b08933a authored by Mathieu Faverge's avatar Mathieu Faverge

States from the trace are now visible in settings windows. Now I need to make...

States from the trace are now visible in settings windows. Now I need to make it available at startup
parent c59e67b4
......@@ -29,8 +29,10 @@ Color *Palette::get_color(const std::string &state_name) {
}
bool Palette::is_visible(const std::string &state_name){
return _visible[state_name];
if (_visible.count(state_name) > 0)
return _visible[state_name];
else
return true;
}
void Palette::add_state(const std::string &state, Color &c, bool visible) {
......
......@@ -22,7 +22,6 @@ public:
~Palette();
//static std::string *getAvailableList() const;
Color *get_color(const std::string &state_name);
......
......@@ -50,6 +50,7 @@
#include <QColorDialog>
#include <QInputDialog>
#include <QMessageBox>
#include <QMap>
/* -- */
#include <qtcolorpicker.h>
/* -- */
......@@ -178,37 +179,45 @@ void Settings_window::plugin_load_dirs_name() {
/************************/
void Settings_window::fill_table(const string &palette_name) {
map<string, Color *> colors_settings;
map<string, Color *> colors_trace;
int row = 0;
/* Clean the table before insertion */
while(states_table->rowCount() > 0) { // Clear the current table
states_table->removeRow(0);
}
map<string, Color *> colors;
int row = 0;
Palette* p = Session::getSession().get_palette("palette",palette_name);
colors = p->get_map();
/* Get the list form settings */
Palette *p = Session::getSession().get_palette("palette",palette_name);
colors_settings = 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);
}
else {
cerr << "no trace loaded" << endl;
return;
}
/* Get the list from trace */
if(_c->get_trace()) { // Need a trace loaded
_c->get_trace()->get_states_colors(colors_trace);
}
else {
//cerr << "no trace loaded" << endl;
return;
}
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));
map<string, Color *>::const_iterator it;
colors_settings.insert( colors_trace.begin(), colors_trace.end() );
for(it = colors_settings.begin();
it != colors_settings.end(); ++it)
{
add_state_line(row, it->first, it->second, p->is_visible( it->first ));
}
}
void Settings_window::add_state_line(int &row, std::string st_name, Color *c, bool checked) {
states_table->insertRow(row);
void Settings_window::add_state_line(int &row, string st_name, Color *c, bool checked) {
/* Name */
QTableWidgetItem *name = new QTableWidgetItem(st_name.c_str());
name->setFlags(Qt::ItemIsEnabled);
states_table->setItem(row, 0, name);
/* Color */
QtColorPicker *color_widget = new QtColorPicker();
color_widget->setStandardColors();
if(c) {
......@@ -219,14 +228,15 @@ 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);
/* Visible */
QCheckBox *cb = new QCheckBox();
cb->setChecked(checked);
states_table->insertRow(row);
states_table->setItem(row, 0, name);
states_table->setCellWidget(row, 1, color_widget);
states_table->setCellWidget(row, 2, cb);
row ++;
}
void Settings_window::on_palette_list_currentIndexChanged(const QString & text) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment