Commit be838038 authored by Mathieu Faverge's avatar Mathieu Faverge

Apply patch 9 from issue #13 - modernize loop convert

parent 68d76d81
...@@ -13,9 +13,8 @@ Palette::Palette(const std::string &name) : _name(name) { ...@@ -13,9 +13,8 @@ Palette::Palette(const std::string &name) : _name(name) {
} }
Palette::~Palette() { Palette::~Palette() {
for(std::map<std::string, Color *>::iterator it = _pairs.begin() ; for(auto & _pair : _pairs) {
it != _pairs.end() ; ++ it) { Color *c = _pair.second;
Color *c = (*it).second;
delete c; delete c;
} }
} }
......
...@@ -93,7 +93,7 @@ bool convert_to_double(const std::string &arg, double *val) { ...@@ -93,7 +93,7 @@ bool convert_to_double(const std::string &arg, double *val) {
} }
} }
double clockGet (void) double clockGet ()
{ {
#if (defined X_ARCHalpha_compaq_osf1) || (defined X_ARCHi686_mac) #if (defined X_ARCHalpha_compaq_osf1) || (defined X_ARCHi686_mac)
struct rusage data; struct rusage data;
......
...@@ -66,6 +66,6 @@ bool convert_to_double(const std::string &arg, double *val); ...@@ -66,6 +66,6 @@ bool convert_to_double(const std::string &arg, double *val);
Uses different timing routines depending on the machine architecture. Uses different timing routines depending on the machine architecture.
\return Returns the time ellapsed since 'clockStart'. \return Returns the time ellapsed since 'clockStart'.
*/ */
double clockGet (void); double clockGet ();
#endif // TOOLS_HPP #endif // TOOLS_HPP
...@@ -930,16 +930,12 @@ void Core::launch_action(int state, void* arg) { ...@@ -930,16 +930,12 @@ void Core::launch_action(int state, void* arg) {
const Container::Vector *root_containers = _trace->get_view_root_containers(); const Container::Vector *root_containers = _trace->get_view_root_containers();
if(root_containers->empty())root_containers= _trace->get_root_containers(); if(root_containers->empty())root_containers= _trace->get_root_containers();
if (!root_containers->empty()){ if (!root_containers->empty()){
for (Container::VectorIt i = root_containers->begin(); for (const auto &root_container : *root_containers)
i != root_containers->end(); if ((container = buf.search_container_by_position(root_container, yr)))
i++)
if ((container = buf.search_container_by_position(*i, yr)))
break; break;
for (Container::VectorIt i = root_containers->begin(); for (const auto &root_container : *root_containers)
i != root_containers->end(); if ((container2 = buf.search_container_by_position(root_container, yr2)))
i++)
if ((container2 = buf.search_container_by_position(*i, yr2)))
break; break;
...@@ -1159,11 +1155,9 @@ void Core::export_variable(Variable *var, const string &filename) { ...@@ -1159,11 +1155,9 @@ void Core::export_variable(Variable *var, const string &filename) {
const double min = var->get_min().get_value(); const double min = var->get_min().get_value();
const double max = var->get_max().get_value(); const double max = var->get_max().get_value();
for(list<pair<Date, Double> >::const_iterator value = variable_values->begin(); for(const auto & variable_value : *variable_values) {
value != variable_values->end(); first_value = variable_value.first.get_value();
value++) { second_value =(variable_value.second.get_value()-min)/(max-min) ;
first_value = (*value).first.get_value();
second_value =((*value).second.get_value()-min)/(max-min) ;
file << first_value << "\t" << second_value << endl; file << first_value << "\t" << second_value << endl;
} }
......
...@@ -235,8 +235,8 @@ void Interface_graphic::load_windows(){ ...@@ -235,8 +235,8 @@ void Interface_graphic::load_windows(){
_ui_help_window, SLOT(close())); _ui_help_window, SLOT(close()));
// For the recent files menu // For the recent files menu
for (int i = 0 ; i < Session::_MAX_NB_RECENT_FILES ; ++ i) { for (auto & _recent_file_action : _recent_file_actions) {
_recent_file_actions[i] = nullptr; _recent_file_action = nullptr;
} }
update_recent_files_menu(); update_recent_files_menu();
...@@ -601,9 +601,9 @@ void Interface_graphic::open_recent_file() { ...@@ -601,9 +601,9 @@ void Interface_graphic::open_recent_file() {
void Interface_graphic::on_clear_recent_files_triggered() { void Interface_graphic::on_clear_recent_files_triggered() {
Session::clear_recent_files(); Session::clear_recent_files();
// We remove the elements from the menu // We remove the elements from the menu
for(int i = 0 ; i < Session::_MAX_NB_RECENT_FILES ; ++ i) { for(auto & _recent_file_action : _recent_file_actions) {
if(_recent_file_actions[i] != nullptr) { if(_recent_file_action != nullptr) {
_ui_recent_files_menu->removeAction(_recent_file_actions[i]); _ui_recent_files_menu->removeAction(_recent_file_action);
} }
} }
} }
......
...@@ -101,17 +101,15 @@ void Node_select::set_initial_container_names(){ ...@@ -101,17 +101,15 @@ void Node_select::set_initial_container_names(){
// Add the root container names // Add the root container names
QList<QTreeWidgetItem *> items; QList<QTreeWidgetItem *> items;
QFlags<Qt::ItemFlag> flg; QFlags<Qt::ItemFlag> flg;
for (Container::VectorIt it = root_containers->begin(); for (const auto &root_container : *root_containers) {
it != root_containers->end(); string name = root_container->get_Name().to_string();
it ++) {
string name = (*it)->get_Name().to_string();
QStringList temp(QString::fromStdString(name)); QStringList temp(QString::fromStdString(name));
QTreeWidgetItem *current_node = new QTreeWidgetItem((QTreeWidgetItem *)nullptr, temp); QTreeWidgetItem *current_node = new QTreeWidgetItem((QTreeWidgetItem *)nullptr, temp);
current_node->setData(0,Qt::UserRole,qVariantFromValue(*it));//store the pointer to the container in the Data field current_node->setData(0,Qt::UserRole,qVariantFromValue(root_container));//store the pointer to the container in the Data field
items.append(current_node); items.append(current_node);
// Recursivity to add the children names // Recursivity to add the children names
set_container_names_rec(current_node, (*it), flg, false); set_container_names_rec(current_node, root_container, flg, false);
} }
_nodes_original->insertTopLevelItems(0, items); _nodes_original->insertTopLevelItems(0, items);
...@@ -136,20 +134,18 @@ void Node_select::set_displayed_container_names(){ ...@@ -136,20 +134,18 @@ void Node_select::set_displayed_container_names(){
// Add the root container names // Add the root container names
QList<QTreeWidgetItem *> items; QList<QTreeWidgetItem *> items;
QFlags<Qt::ItemFlag> flg= Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsTristate; QFlags<Qt::ItemFlag> flg= Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsTristate;
for (Container::VectorIt it = root_containers->begin(); for (const auto &root_container : *root_containers) {
it != root_containers->end(); string name = root_container->get_Name().to_string();
it ++) {
string name = (*it)->get_Name().to_string();
QStringList temp(QString::fromStdString(name)); QStringList temp(QString::fromStdString(name));
QTreeWidgetItem *current_node = new QTreeWidgetItem((QTreeWidgetItem *)nullptr, temp); QTreeWidgetItem *current_node = new QTreeWidgetItem((QTreeWidgetItem *)nullptr, temp);
current_node->setFlags(flg); current_node->setFlags(flg);
current_node->setCheckState(0,Qt::Checked); current_node->setCheckState(0,Qt::Checked);
current_node->setData(0,Qt::UserRole,qVariantFromValue(*it));//store the pointer to the container in the Data field current_node->setData(0,Qt::UserRole,qVariantFromValue(root_container));//store the pointer to the container in the Data field
items.append(current_node); items.append(current_node);
// Recursivity to add the children names // Recursivity to add the children names
set_container_names_rec(current_node, (*it), flg, true); set_container_names_rec(current_node, root_container, flg, true);
} }
_nodes_displayed->insertTopLevelItems(0, items); _nodes_displayed->insertTopLevelItems(0, items);
...@@ -170,18 +166,16 @@ void Node_select::set_container_names_rec(QTreeWidgetItem *current_node, Contain ...@@ -170,18 +166,16 @@ void Node_select::set_container_names_rec(QTreeWidgetItem *current_node, Contain
if(load_view==false || children->empty())children = current_container->get_children(); if(load_view==false || children->empty())children = current_container->get_children();
//QFlags<Qt::ItemFlag> flg= Qt::ItemIsDragEnabled; //QFlags<Qt::ItemFlag> flg= Qt::ItemIsDragEnabled;
for (Container::VectorIt it = children->begin(); for (const auto &child : *children) {
it != children->end();
it ++) {
// We create the node and we do the recursivity // We create the node and we do the recursivity
string name = (*it)->get_Name().to_string(); string name = child->get_Name().to_string();
QStringList temp(QString::fromStdString(name)); QStringList temp(QString::fromStdString(name));
QTreeWidgetItem *node = new QTreeWidgetItem(current_node, temp); QTreeWidgetItem *node = new QTreeWidgetItem(current_node, temp);
node->setFlags(flg); node->setFlags(flg);
node->setData(0,Qt::UserRole, qVariantFromValue(*it));//store the pointer to the container in the Data field node->setData(0,Qt::UserRole, qVariantFromValue(child));//store the pointer to the container in the Data field
if(flg & Qt::ItemIsUserCheckable)node->setCheckState(0,Qt::Checked); if(flg & Qt::ItemIsUserCheckable)node->setCheckState(0,Qt::Checked);
set_container_names_rec(node ,(*it), flg, load_view); set_container_names_rec(node ,child, flg, load_view);
} }
} }
......
...@@ -30,10 +30,7 @@ ...@@ -30,10 +30,7 @@
#include <QStylePainter> #include <QStylePainter>
#include <QStyleOptionSlider> #include <QStyleOptionSlider>
QxtSpanSliderPrivate::QxtSpanSliderPrivate() QxtSpanSliderPrivate::QxtSpanSliderPrivate() = default;
{
}
void QxtSpanSliderPrivate::initStyleOption(QStyleOptionSlider* option, QxtSpanSlider::SpanHandle handle) const void QxtSpanSliderPrivate::initStyleOption(QStyleOptionSlider* option, QxtSpanSlider::SpanHandle handle) const
{ {
......
...@@ -107,12 +107,11 @@ void ParserVite::parse(Trace &trace, ...@@ -107,12 +107,11 @@ void ParserVite::parse(Trace &trace,
/* Loop over root containers to add them in the stack */ /* Loop over root containers to add them in the stack */
root_containers = trace.get_root_containers(); root_containers = trace.get_root_containers();
for (Container::VectorIt it = root_containers->begin(); for (const auto &root_container : *root_containers) {
it != root_containers->end(); it++) {
#ifdef DBG_PARSER_VITE #ifdef DBG_PARSER_VITE
std::cerr << "+"; std::cerr << "+";
#endif #endif
CTstack.push(*it); CTstack.push(root_container);
} }
#ifdef DBG_PARSER_VITE #ifdef DBG_PARSER_VITE
......
...@@ -180,10 +180,8 @@ void Command_window::set_container_names() { ...@@ -180,10 +180,8 @@ void Command_window::set_container_names() {
QList<QTreeWidgetItem *> items; QList<QTreeWidgetItem *> items;
QFlags<Qt::ItemFlag> flg=Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsTristate; QFlags<Qt::ItemFlag> flg=Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsTristate;
for (Container::VectorIt it = root_containers->begin(); for (const auto &root_container : *root_containers) {
it != root_containers->end(); string name = root_container->get_Name().to_string();
it ++) {
string name = (*it)->get_Name().to_string();
QStringList temp(QString::fromStdString(name)); QStringList temp(QString::fromStdString(name));
QTreeWidgetItem *current_node = new QTreeWidgetItem((QTreeWidgetItem *)nullptr, temp); QTreeWidgetItem *current_node = new QTreeWidgetItem((QTreeWidgetItem *)nullptr, temp);
...@@ -192,7 +190,7 @@ void Command_window::set_container_names() { ...@@ -192,7 +190,7 @@ void Command_window::set_container_names() {
items.append(current_node); items.append(current_node);
// Recursivity to add the children names // Recursivity to add the children names
set_container_names_rec(current_node, (*it)); set_container_names_rec(current_node, root_container);
} }
(*(items.begin()))->setExpanded(true); (*(items.begin()))->setExpanded(true);
...@@ -203,16 +201,14 @@ void Command_window::set_container_names_rec(QTreeWidgetItem *current_node, cons ...@@ -203,16 +201,14 @@ void Command_window::set_container_names_rec(QTreeWidgetItem *current_node, cons
const Container::Vector *children = current_container->get_children(); const Container::Vector *children = current_container->get_children();
QFlags<Qt::ItemFlag> flg = Qt::ItemIsUserCheckable | Qt::ItemIsSelectable | Qt::ItemIsEnabled/* | Qt::ItemIsTristate*/; QFlags<Qt::ItemFlag> flg = Qt::ItemIsUserCheckable | Qt::ItemIsSelectable | Qt::ItemIsEnabled/* | Qt::ItemIsTristate*/;
for (Container::VectorIt it = children->begin(); for (const auto &it : *children) {
it != children->end();
it ++) {
// We create the node and we do the recursivity // We create the node and we do the recursivity
string name = (*it)->get_Name().to_string(); string name = it->get_Name().to_string();
QStringList temp(QString::fromStdString(name)); QStringList temp(QString::fromStdString(name));
QTreeWidgetItem *node = new QTreeWidgetItem(current_node, temp); QTreeWidgetItem *node = new QTreeWidgetItem(current_node, temp);
node->setFlags(flg); node->setFlags(flg);
node->setCheckState(0,Qt::Unchecked); node->setCheckState(0,Qt::Unchecked);
set_container_names_rec(node ,(*it)); set_container_names_rec(node ,it);
} }
} }
......
...@@ -110,9 +110,9 @@ Plugin_window::Plugin_window(Core *c, QWidget *parent) ...@@ -110,9 +110,9 @@ Plugin_window::Plugin_window(Core *c, QWidget *parent)
Plugin_window::~Plugin_window() { Plugin_window::~Plugin_window() {
_plugin_directories.clear(); _plugin_directories.clear();
for(unsigned int i = 0 ; i < _plugins.size() ; i ++) { for(auto & _plugin : _plugins) {
delete _plugins[i]; delete _plugin;
_plugins[i] = nullptr; _plugin = nullptr;
} }
_plugins.clear(); _plugins.clear();
} }
...@@ -134,8 +134,7 @@ void Plugin_window::load_shared_plugins() { ...@@ -134,8 +134,7 @@ void Plugin_window::load_shared_plugins() {
QFileInfoList list = dir.entryInfoList(); QFileInfoList list = dir.entryInfoList();
for (int i = 0 ; i < list.size() ; ++ i) { for (const auto & fileInfo : list) {
const QFileInfo &fileInfo = list.at(i);
QString filename = fileInfo.absoluteFilePath(); QString filename = fileInfo.absoluteFilePath();
if(!QLibrary::isLibrary(filename)) { if(!QLibrary::isLibrary(filename)) {
...@@ -144,7 +143,7 @@ void Plugin_window::load_shared_plugins() { ...@@ -144,7 +143,7 @@ void Plugin_window::load_shared_plugins() {
QLibrary current_plugin(filename); QLibrary current_plugin(filename);
Plugin *(*f)(void) = (Plugin *(*)(void)) current_plugin.resolve("create"); Plugin *(*f)() = (Plugin *(*)()) current_plugin.resolve("create");
if(!f) { if(!f) {
cerr << "Unable to load " << current_plugin.errorString().toStdString() <<endl; cerr << "Unable to load " << current_plugin.errorString().toStdString() <<endl;
} }
...@@ -194,10 +193,8 @@ void Plugin_window::execute_plugin() { ...@@ -194,10 +193,8 @@ void Plugin_window::execute_plugin() {
} }
void Plugin_window::clear_plugins() { void Plugin_window::clear_plugins() {
for(vector<Plugin *>::iterator it = _plugins.begin() ; for(Plugin *plugin : _plugins) {
it < _plugins.end() ; plugin->clear();
++ it) {
(*it)->clear();
} }
} }
...@@ -205,9 +202,9 @@ void Plugin_window::reload_plugins() { ...@@ -205,9 +202,9 @@ void Plugin_window::reload_plugins() {
// Temporary disconnection for delete current plugins // Temporary disconnection for delete current plugins
disconnect(_tab_widget, SIGNAL(currentChanged(int)), this, SLOT(reload_plugin(int))); disconnect(_tab_widget, SIGNAL(currentChanged(int)), this, SLOT(reload_plugin(int)));
_plugin_directories.clear(); _plugin_directories.clear();
for(unsigned int i = 0 ; i < _plugins.size() ; i ++) { for(auto & _plugin : _plugins) {
delete _plugins[i]; delete _plugin;
_plugins[i] = nullptr; _plugin = nullptr;
} }
_plugins.clear(); _plugins.clear();
connect(_tab_widget, SIGNAL(currentChanged(int)), this, SLOT(reload_plugin(int))); connect(_tab_widget, SIGNAL(currentChanged(int)), this, SLOT(reload_plugin(int)));
......
...@@ -218,13 +218,13 @@ public: ...@@ -218,13 +218,13 @@ public:
/* Before calling start_draw_container(), Info::Container::y_max should have a correct value */ /* Before calling start_draw_container(), Info::Container::y_max should have a correct value */
_render->start_draw_containers(); _render->start_draw_containers();
for (unsigned int i=0 ; i<_containers.size() ; i++){ for (const auto & _container : _containers){
_render->set_color(0, 0, j); _render->set_color(0, 0, j);
_render->draw_quad(_containers[i].x * coeffx, _render->draw_quad(_container.x * coeffx,
trace_to_render_y(_containers[i].y), trace_to_render_y(_container.y),
_z_container, _z_container,
_containers[i].w * coeffx, _container.w * coeffx,
_containers[i].h * coeffy); _container.h * coeffy);
} }
for (unsigned int i=0 ; i<_container_texts.size() ; i++){ for (unsigned int i=0 ; i<_container_texts.size() ; i++){
......
...@@ -115,10 +115,8 @@ public: ...@@ -115,10 +115,8 @@ public:
for(int i = 0 ; i < nbcont ; i ++) { for(int i = 0 ; i < nbcont ; i ++) {
const std::map<VariableType *, Variable *> *variables = this->_containers_to_print[i]->get_variables(); const std::map<VariableType *, Variable *> *variables = this->_containers_to_print[i]->get_variables();
// We print each variable // We print each variable
for(std::map<VariableType *, Variable *>::const_iterator it = variables->begin() ; for(const auto &variable : *variables) {
it != variables->end() ; draw_diagram(draw_object, i, variable.second);
it ++) {
draw_diagram(draw_object, i, (*it).second);
_nb_variables_already_print ++; _nb_variables_already_print ++;
} }
} }
...@@ -229,11 +227,9 @@ public: ...@@ -229,11 +227,9 @@ public:
bool is_last_value = false; // If we get a time bigger than the end_time bool is_last_value = false; // If we get a time bigger than the end_time
if(max_value != min_value) { if(max_value != min_value) {
for (std::list<std::pair<Date, Double> >::const_iterator it = values->begin(); for (const auto & it : *values) {
it != values->end(); time = it.first.get_value();
it ++) { value = it.second.get_value();
time = (*it).first.get_value();
value = (*it).second.get_value();
if(time < this->_start_time) { if(time < this->_start_time) {
continue; continue;
......
...@@ -180,11 +180,9 @@ public: ...@@ -180,11 +180,9 @@ public:
ctname); ctname);
// Draw the stats // Draw the stats
for (std::map<const EntityValue *, stats *>::iterator it = temp_states.begin(); for (auto & temp_state : temp_states)
it != temp_states.end();
it ++)
{ {
double length = (*it).second->_total_length; double length = temp_state.second->_total_length;
double percent = length / duration ; double percent = length / duration ;
double width = percent * _graph_width; double width = percent * _graph_width;
double red = 0.7; double red = 0.7;
...@@ -192,9 +190,9 @@ public: ...@@ -192,9 +190,9 @@ public:
double blue = 0.75; double blue = 0.75;
// We search for a color // We search for a color
if((*it).first->get_extra_fields()->find(std::string("Color")) != (*it).first->get_extra_fields()->end()) if(temp_state.first->get_extra_fields()->find(std::string("Color")) != temp_state.first->get_extra_fields()->end())
{ {
const Color *color = (const Color *)(*it).first->get_extra_fields()->find(std::string("Color"))->second; const Color *color = (const Color *)temp_state.first->get_extra_fields()->find(std::string("Color"))->second;
red = color->get_red(); red = color->get_red();
green = color->get_green(); green = color->get_green();
blue = color->get_blue(); blue = color->get_blue();
...@@ -210,7 +208,7 @@ public: ...@@ -210,7 +208,7 @@ public:
QString::number(percent*100., 'f', 1).toStdString()+"%"); QString::number(percent*100., 'f', 1).toStdString()+"%");
pos_x += width; pos_x += width;
this->_setstates.insert((*it).first); this->_setstates.insert(temp_state.first);
} }
......
...@@ -196,11 +196,9 @@ public: ...@@ -196,11 +196,9 @@ public:
virtual double get_max_percentage(std::map<const EntityValue*, stats*> &temp_states) const { virtual double get_max_percentage(std::map<const EntityValue*, stats*> &temp_states) const {
double value; double value;
double max_length = 0.; double max_length = 0.;
for (std::map<const EntityValue *, stats *>::iterator it = temp_states.begin(); for (auto & temp_state : temp_states) {
it != temp_states.end(); if(temp_state.second->_total_length >= max_length) {
it ++) { max_length = temp_state.second->_total_length;
if((*it).second->_total_length >= max_length) {
max_length = (*it).second->_total_length;
} }
} }
value = max_length/(_end_time-_start_time); value = max_length/(_end_time-_start_time);
......
...@@ -143,17 +143,15 @@ public: ...@@ -143,17 +143,15 @@ public:
// Draw the stats // Draw the stats
for (std::map<const EntityValue *, stats *>::iterator it = temp_states.begin(); for (auto & temp_state : temp_states) {
it != temp_states.end();
it ++) {
// We have to convert the percentage in a rectangle and print it // We have to convert the percentage in a rectangle and print it
const double length = (*it).second->_total_length; const double length = temp_state.second->_total_length;
const double height = length*100.*this->_percentage_height_default/(this->_end_time-this->_start_time); const double height = length*100.*this->_percentage_height_default/(this->_end_time-this->_start_time);
// We search for a color // We search for a color
if((*it).first->get_extra_fields()->find(std::string("Color")) != (*it).first->get_extra_fields()->end()) { if(temp_state.first->get_extra_fields()->find(std::string("Color")) != temp_state.first->get_extra_fields()->end()) {
const Color *color = (const Color *)(*it).first->get_extra_fields()->find(std::string("Color"))->second; const Color *color = (const Color *)temp_state.first->get_extra_fields()->find(std::string("Color"))->second;
draw_object->draw_rect(pos_x, pos_y, _WIDTH_HISTOGRAM_DEFAULT, height/max_percentage, color->get_red(), color->get_green(), color->get_blue()); draw_object->draw_rect(pos_x, pos_y, _WIDTH_HISTOGRAM_DEFAULT, height/max_percentage, color->get_red(), color->get_green(), color->get_blue());
} }
else { else {
......
...@@ -64,10 +64,8 @@ Statistic::Statistic(){ ...@@ -64,10 +64,8 @@ Statistic::Statistic(){
Statistic::~Statistic(){ Statistic::~Statistic(){
// Delete states // Delete states
for (map<const EntityValue *, stats *>::iterator it = _states.begin(); for (auto & _state : _states) {
it != _states.end(); delete _state.second;
it ++) {
delete (*it).second;
} }
} }
......
...@@ -111,11 +111,9 @@ void Stats_window::set_container_names() { ...@@ -111,11 +111,9 @@ void Stats_window::set_container_names() {
QList<QTreeWidgetItem *> items; QList<QTreeWidgetItem *> items;
QFlags<Qt::ItemFlag> flg=Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsTristate; QFlags<Qt::ItemFlag> flg=Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsTristate;
for (Container::VectorIt it = root_containers->begin(); for (const auto &root_container : *root_containers) {
it != root_containers->end(); string name = root_container->get_name();
it ++) { string alias = root_container->get_alias();
string name = (*it)->get_name();
string alias = (*it)->get_alias();
QStringList str_name(QString::fromStdString(name)); QStringList str_name(QString::fromStdString(name));
QString str_alias(QString::fromStdString(alias)); QString str_alias(QString::fromStdString(alias));
QTreeWidgetItem *current_node = new QTreeWidgetItem((QTreeWidgetItem *)nullptr, str_name); QTreeWidgetItem *current_node = new QTreeWidgetItem((QTreeWidgetItem *)nullptr, str_name);
...@@ -126,7 +124,7 @@ void Stats_window::set_container_names() { ...@@ -126,7 +124,7 @@ void Stats_window::set_container_names() {
items.append(current_node); items.append(current_node);
// Recursivity to add the children names // Recursivity to add the children names
set_container_names_rec(current_node, (*it)); set_container_names_rec(current_node, root_container);
} }
(*(items.begin()))->setExpanded(true); (*(items.begin()))->setExpanded(true);
...@@ -137,20 +135,18 @@ void Stats_window::set_container_names_rec(QTreeWidgetItem *current_node, Contai ...@@ -137,20 +135,18 @@ void Stats_window::set_container_names_rec(QTreeWidgetItem *current_node, Contai
const Container::Vector *children = current_container->get_children(); const Container::Vector *children = current_container->get_children();
QFlags<Qt::ItemFlag> flg = Qt::ItemIsUserCheckable | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsTristate; QFlags<Qt::ItemFlag> flg = Qt::ItemIsUserCheckable | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsTristate;
for (Container::VectorIt it = children->begin(); for (const auto &it : *children)
it != children->end();
it ++)
{ {
// We create the node and we do the recursivity // We create the node and we do the recursivity
string name = (*it)->get_name(); string name = it->get_name();
string alias = (*it)->get_alias(); string alias = it->get_alias();
QStringList str_name(QString::fromStdString(name)); QStringList str_name(QString::fromStdString(name));
QString str_alias(QString::fromStdString(alias)); QString str_alias(QString::fromStdString(alias));
QTreeWidgetItem *node = new QTreeWidgetItem(current_node, str_name); QTreeWidgetItem *node = new QTreeWidgetItem(current_node, str_name);
node->setFlags(flg); node->setFlags(flg);
node->setCheckState(0,Qt::Checked); node->setCheckState(0,Qt::Checked);
node->setText(1, str_alias); node->setText(1, str_alias);
set_container_names_rec(node ,(*it)); set_container_names_rec(node ,it);
} }
} }
......
...@@ -134,10 +134,8 @@ Container::~Container() ...@@ -134,10 +134,8 @@ Container::~Container()
_links.pop_front(); _links.pop_front();
} }
// Delete variables // Delete variables
for(map<VariableType *, Variable *>::iterator it = _variables.begin(); for(auto & _variable : _variables){
it != _variables.end(); delete _variable.second;
it++){
delete (*it).second;
} }
_variables.clear(); _variables.clear();
#endif #endif
......
This diff is collapsed.
...@@ -63,7 +63,7 @@ Entity::Entity(Container *container, map<std::string, Value *> opt): _container( ...@@ -63,7 +63,7 @@ Entity::Entity(Container *container, map<std::string, Value *> opt): _container(
} }
Entity::Entity(){} Entity::Entity()= default;
const Container *Entity::get_container() const { const Container *Entity::get_container() const {
return _container; return _container;
...@@ -74,14 +74,7 @@ const map<std::string, Value *> *Entity::get_extra_fields() const { ...@@ -74,14 +74,7 @@ const map<std::string, Value *> *Entity::get_extra_fields() const {
} }
Entity::~Entity(){ Entity::~Entity() = default;
// for(map<std::string, Value *>::iterator it = _extra_fields.begin();
// it != _extra_fields.end();
// it++){
// delete (*it).second;
// (*it).second = NULL;