Mise à jour terminée. Pour connaître les apports de la version 13.8.4 par rapport à notre ancienne version vous pouvez lire les "Release Notes" suivantes :
https://about.gitlab.com/releases/2021/02/11/security-release-gitlab-13-8-4-released/
https://about.gitlab.com/releases/2021/02/05/gitlab-13-8-3-released/

Commit 96eac179 authored by Mathieu Faverge's avatar Mathieu Faverge

Code factorization

parent 9b08933a
......@@ -208,11 +208,11 @@ void Settings_window::fill_table(const string &palette_name) {
for(it = colors_settings.begin();
it != colors_settings.end(); ++it)
{
add_state_line(row, it->first, it->second, p->is_visible( it->first ));
add_state_line(states_table, row, it->first, it->second, p->is_visible( it->first ));
}
}
void Settings_window::add_state_line(int &row, string st_name, Color *c, bool checked) {
void Settings_window::add_state_line(QTableWidget *table, int &row, string st_name, Color *c, bool checked) {
/* Name */
QTableWidgetItem *name = new QTableWidgetItem(st_name.c_str());
name->setFlags(Qt::ItemIsEnabled);
......@@ -226,16 +226,18 @@ void Settings_window::add_state_line(int &row, string st_name, Color *c, bool ch
else { // \todo check the default color value -> put this in Palette as static member
color_widget->setCurrentColor(QColor(0, 244, 222));
}
connect(color_widget, SIGNAL(colorChanged(const QColor &)), this, SLOT(state_color_changed(const QColor &)));
color_widget->setColorDialogEnabled(true);
connect(color_widget, SIGNAL(colorChanged(const QColor &)),
this, SLOT(state_color_changed(const QColor &)));
/* 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);
table->insertRow(row);
table->setItem(row, 0, name);
table->setCellWidget(row, 1, color_widget);
table->setCellWidget(row, 2, cb);
row ++;
}
......@@ -348,7 +350,7 @@ void Settings_window::on_reload_states_btn_clicked(){
for(map<string, Color *>::iterator it = colors.begin() ;
it != colors.end() ; ++ it) {
add_state_line(row, (*it).first.c_str(), (*it).second, true);
add_state_line(states_table, row, (*it).first.c_str(), (*it).second, true);
}
}
......@@ -397,78 +399,49 @@ void Settings_window::on_rm_state_btn_clicked() {
}
}
void Settings_window::state_color_changed(const QColor &qc) {
_changed=true;
if(!states_table || !palette_list)
void Settings_window::color_changed(string name, QTableWidget *table, const QColor &qc) {
_changed = true;
if( !table || !palette_list)
return;
Color color(qc.red()/255., qc.green()/255., qc.blue()/255.);
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
while(table->cellWidget(row, 1) &&
table->cellWidget(row, 1) != sender()) { // Find the row of the colorPicker
row ++;
}
if(!states_table->cellWidget(row, 1))
if(!table->cellWidget(row, 1))
return; // epic fail...
std::string palette_name = palette_list->currentText().toStdString();
std::string state_name = states_table->item(row, 0)->text().toStdString();
Session &S = Session::getSession();
Palette *p = S.get_palette("palette",palette_name);
std::string state_name = table->item(row, 0)->text().toStdString();
S.add_state_to_palette("palette",palette_name, state_name, color, qobject_cast<QCheckBox *>(states_table->cellWidget(row, 2))->checkState()== Qt::Checked);
p->add_state(state_name, color, qobject_cast<QCheckBox *>(states_table->cellWidget(row, 2))->checkState()== Qt::Checked);
}
Session &S = Session::getSession();
Palette *p = S.get_palette(name, palette_name);
void Settings_window::event_types_color_changed(const QColor &qc) {
_changed=true;
if(!event_types_table || !event_types_palette_list)
return;
Color color(qc.red()/255., qc.green()/255., qc.blue()/255.);
bool checked = qobject_cast<QCheckBox *>(table->cellWidget(row, 2))->checkState()== Qt::Checked;
int row = 0;
while(event_types_table->cellWidget(row, 1) && event_types_table->cellWidget(row, 1) != sender()) { // Find the row of the colorPicker
row ++;
}
S.add_state_to_palette(name, palette_name, state_name, color, checked );
p->add_state(state_name, color, checked );
return;
}
if(!event_types_table->cellWidget(row, 1))
return; // epic fail...
std::string palette_name = event_types_palette_list->currentText().toStdString();
std::string state_name = event_types_table->item(row, 0)->text().toStdString();
Session &S = Session::getSession();
Palette *p = S.get_palette("event_types",palette_name);
void Settings_window::state_color_changed(const QColor &qc) {
color_changed("palette", states_table, qc);
}
S.add_state_to_palette("event_types",palette_name, state_name, color, qobject_cast<QCheckBox *>(event_types_table->cellWidget(row, 2))->checkState()== Qt::Checked);
p->add_state(state_name, color, qobject_cast<QCheckBox *>(event_types_table->cellWidget(row, 2))->checkState()== Qt::Checked);
void Settings_window::event_types_color_changed(const QColor &qc) {
color_changed("event_types", event_types_table, qc);
}
void Settings_window::link_types_color_changed(const QColor &qc) {
Session &S = Session::getSession();
_changed=true;
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 ++;
}
if(!link_types_table->cellWidget(row, 1))
return; // epic fail...
std::string palette_name = link_types_palette_list->currentText().toStdString();
std::string state_name = link_types_table->item(row, 0)->text().toStdString();
Palette *p = S.get_palette("link_types",palette_name);
S.add_state_to_palette("link_types",palette_name, state_name, color, qobject_cast<QCheckBox *>(link_types_table->cellWidget(row, 2))->checkState()== Qt::Checked);
p->add_state(state_name, color, qobject_cast<QCheckBox *>(link_types_table->cellWidget(row, 2))->checkState()== Qt::Checked);
color_changed("link_types", link_types_table, qc);
}
/*************************/
/****** Types tab. ******/
/*************************/
......@@ -502,7 +475,7 @@ void Settings_window::fill_event_types_table(const string &palette_name) {
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(event_types_table, row, (*it).first.to_string(), color, true);
}
}
else { // Look for the state/color pairs in Session.
......@@ -510,18 +483,19 @@ void Settings_window::fill_event_types_table(const string &palette_name) {
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));
add_event_type_line(event_types_table, row, (*it).first, (*it).second, p->is_visible((*it).first));
}
}
}
void Settings_window::add_event_type_line(int &row, std::string st_name, Color *c, bool checked) {
event_types_table->insertRow(row);
void Settings_window::add_event_type_line(QTableWidget *table, int &row, std::string st_name, Color *c, bool checked) {
/* Name */
QTableWidgetItem *name = new QTableWidgetItem(st_name.c_str());
name->setFlags(Qt::ItemIsEnabled);
event_types_table->setItem(row, 0, name);
/* Color */
QtColorPicker *color_widget = new QtColorPicker();
color_widget->setStandardColors();
if(c) {
......@@ -531,14 +505,17 @@ 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 &)));
connect(color_widget, SIGNAL(colorChanged(const QColor &)), this, SLOT( event_types_color_changed(const QColor &)));
event_types_table->setCellWidget(row, 1, color_widget);
/* Visible */
QCheckBox *cb = new QCheckBox();
cb->setChecked(checked);
event_types_table->setCellWidget(row, 2, cb);
table->insertRow(row);
table->setItem(row, 0, name);
table->setCellWidget(row, 1, color_widget);
table->setCellWidget(row, 2, cb);
row ++;
}
......@@ -572,7 +549,7 @@ void Settings_window::fill_link_types_table(const string &palette_name) {
}
add_link_type_line(row, (*it).first.to_string(), color, true);
add_link_type_line(link_types_table, row, (*it).first.to_string(), color, true);
}
}
......@@ -581,7 +558,7 @@ void Settings_window::fill_link_types_table(const string &palette_name) {
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));
add_link_type_line(link_types_table, row, (*it).first, (*it).second, p->is_visible((*it).first));
}
}
......@@ -589,12 +566,12 @@ void Settings_window::fill_link_types_table(const string &palette_name) {
}
void Settings_window::add_link_type_line(int &row, std::string st_name, Color *c, bool checked) {
link_types_table->insertRow(row);
void Settings_window::add_link_type_line(QTableWidget *table, int &row, string st_name, Color *c, bool checked) {
/* Name */
QTableWidgetItem *name = new QTableWidgetItem(st_name.c_str());
name->setFlags(Qt::ItemIsEnabled);
link_types_table->setItem(row, 0, name);
/* Color */
QtColorPicker *color_widget = new QtColorPicker();
color_widget->setStandardColors();
if(c) {
......@@ -604,14 +581,17 @@ 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 &)));
connect(color_widget, SIGNAL(colorChanged(const QColor &)), this, SLOT( link_types_color_changed(const QColor &)));
link_types_table->setCellWidget(row, 1, color_widget);
/* Visible */
QCheckBox *cb = new QCheckBox();
cb->setChecked(checked);
link_types_table->setCellWidget(row, 2, cb);
table->insertRow(row);
table->setItem(row, 0, name);
table->setCellWidget(row, 1, color_widget);
table->setCellWidget(row, 2, cb);
row ++;
}
......@@ -651,7 +631,7 @@ void Settings_window::on_reload_link_types_palette_btn_clicked() {
}
add_link_type_line(row, (*it).first.to_string(), color, true);
add_link_type_line(link_types_table, row, (*it).first.to_string(), color, true);
}
}
......@@ -681,7 +661,7 @@ void Settings_window::on_reload_event_types_palette_btn_clicked() {
}
add_event_type_line(row, (*it).first.to_string(), color, true);
add_event_type_line(event_types_table, row, (*it).first.to_string(), color, true);
}
}
......
......@@ -85,7 +85,7 @@ private:
* \brief Fill a new row to the state table.
* row is incremented at the end of the function.
*/
void add_state_line(int &row, std::string st_name, Color *c, bool checked = true);
void add_state_line(QTableWidget *table, int &row, std::string st_name, Color *c, bool checked = true);
/*!
* \brief Reload the general tab.
......@@ -105,7 +105,7 @@ private:
/*!
* \brief add an event type to the table
*/
void add_event_type_line(int&, std::string, Color*, bool);
void add_event_type_line(QTableWidget *table, int&, std::string, Color*, bool);
/*!
* \brief Fill the link types table
......@@ -115,7 +115,7 @@ private:
/*!
* \brief add a link type to the table
*/
void add_link_type_line(int&, std::string, Color*, bool);
void add_link_type_line(QTableWidget *table, int&, std::string, Color*, bool);
/*!
* \brief add a palette to the list, for a given type
......@@ -132,6 +132,8 @@ private:
*/
QString copy_palette(QTableWidget* table, QComboBox* list, const std::string type);
void color_changed(std::string name, QTableWidget *table, const QColor &qc);
public:
/*!
* Default constructor
......
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