diff options
| author | Marc Jeanmougin <marc@jeanmougin.fr> | 2019-01-02 09:41:30 +0000 |
|---|---|---|
| committer | Marc Jeanmougin <marc@jeanmougin.fr> | 2019-01-02 09:41:30 +0000 |
| commit | 169dff19d4da8d76e69b8e896aa25b0013639c03 (patch) | |
| tree | a0c070fa95188b5cde708ac285e6a2db9df4a83f /src/ui | |
| parent | Avoid creating a new document before opening an old document. (diff) | |
| download | inkscape-169dff19d4da8d76e69b8e896aa25b0013639c03.tar.gz inkscape-169dff19d4da8d76e69b8e896aa25b0013639c03.zip | |
modernize loops
Diffstat (limited to 'src/ui')
63 files changed, 563 insertions, 665 deletions
diff --git a/src/ui/cache/svg_preview_cache.cpp b/src/ui/cache/svg_preview_cache.cpp index 7262b7dbe..ca1d14854 100644 --- a/src/ui/cache/svg_preview_cache.cpp +++ b/src/ui/cache/svg_preview_cache.cpp @@ -72,11 +72,10 @@ SvgPreview::SvgPreview() SvgPreview::~SvgPreview() { - for (std::map<Glib::ustring, GdkPixbuf *>::iterator i = _pixmap_cache.begin(); - i != _pixmap_cache.end(); ++i) + for (auto & i : _pixmap_cache) { - g_object_unref(i->second); - i->second = NULL; + g_object_unref(i.second); + i.second = NULL; } } diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 7f9e4b872..733d6e8d1 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -676,16 +676,14 @@ std::vector<Glib::ustring> ClipboardManagerImpl::getElementsOfType(SPDesktop *de types.push_back((Glib::ustring)"svg:use"); types.push_back((Glib::ustring)"svg:g"); types.push_back((Glib::ustring)"svg:image"); - for (auto i=types.begin();i!=types.end();++i) { - Glib::ustring type_elem = *i; + for (auto type_elem : types) { std::vector<Inkscape::XML::Node const *> reprs_found = sp_repr_lookup_name_many(root, type_elem.c_str(), maxdepth); // unlimited search depth reprs.insert(reprs.end(), reprs_found.begin(), reprs_found.end()); } } else { reprs = sp_repr_lookup_name_many(root, type, maxdepth); } - for (auto i=reprs.begin();i!=reprs.end();++i) { - Inkscape::XML::Node const * node = *i; + for (auto node : reprs) { result.emplace_back(node->attribute("id")); } if ( result.empty() ) { @@ -721,12 +719,12 @@ void ClipboardManagerImpl::_copySelection(ObjectSet *selection) //remove already copied elements from cloned_elements std::vector<SPItem*>tr; - for(std::set<SPItem*>::iterator it = cloned_elements.begin();it!=cloned_elements.end();++it){ - if(std::find(sorted_items.begin(),sorted_items.end(),*it)!=sorted_items.end()) - tr.push_back(*it); + for(auto cloned_element : cloned_elements){ + if(std::find(sorted_items.begin(),sorted_items.end(),cloned_element)!=sorted_items.end()) + tr.push_back(cloned_element); } - for(std::vector<SPItem*>::iterator it = tr.begin();it!=tr.end();++it){ - cloned_elements.erase(*it); + for(auto & it : tr){ + cloned_elements.erase(it); } sorted_items.insert(sorted_items.end(),cloned_elements.begin(),cloned_elements.end()); @@ -830,9 +828,9 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) // For shapes, copy all of the shape's markers SPShape *shape = dynamic_cast<SPShape *>(item); if (shape) { - for (int i = 0 ; i < SP_MARKER_LOC_QTY ; i++) { - if (shape->_marker[i]) { - _copyNode(shape->_marker[i]->getRepr(), _doc, _defs); + for (auto & i : shape->_marker) { + if (i) { + _copyNode(i->getRepr(), _doc, _defs); } } } @@ -887,8 +885,8 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item); if (lpeitem) { if (lpeitem->hasPathEffect()) { - for (PathEffectList::iterator it = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); ++it){ - LivePathEffectObject *lpeobj = (*it)->lpeobject; + for (auto & it : *lpeitem->path_effect_list){ + LivePathEffectObject *lpeobj = it->lpeobject; if (lpeobj) { _copyNode(lpeobj->getRepr(), _doc, _defs); } @@ -1388,11 +1386,10 @@ Glib::ustring ClipboardManagerImpl::_getBestTarget() g_message("End clipboard targets\n"); //*/ - for (std::list<Glib::ustring>::iterator i = _preferred_targets.begin() ; - i != _preferred_targets.end() ; ++i) + for (auto & _preferred_target : _preferred_targets) { - if ( std::find(targets.begin(), targets.end(), *i) != targets.end() ) { - return *i; + if ( std::find(targets.begin(), targets.end(), _preferred_target) != targets.end() ) { + return _preferred_target; } } #ifdef _WIN32 diff --git a/src/ui/contextmenu.cpp b/src/ui/contextmenu.cpp index 7d57e78a8..486af0dda 100644 --- a/src/ui/contextmenu.cpp +++ b/src/ui/contextmenu.cpp @@ -93,11 +93,11 @@ ContextMenu::ContextMenu(SPDesktop *desktop, SPItem *item) : std::vector< SPItem * > down_items = _desktop->getDocument()->getItemsPartiallyInBox( _desktop->dkey, b, true, true, true, true); bool has_down_hidden = false; bool has_down_locked = false; - for(std::vector< SPItem * >::iterator down = down_items.begin(); down != down_items.end(); ++down){ - if((*down)->isHidden()) { + for(auto & down_item : down_items){ + if(down_item->isHidden()) { has_down_hidden = true; } - if((*down)->isLocked()) { + if(down_item->isLocked()) { has_down_locked = true; } } @@ -216,10 +216,10 @@ void ContextMenu::HideSelected() void ContextMenu::UnLockBelow(std::vector<SPItem *> items) { _desktop->selection->clear(); - for(auto i=items.begin();i!=items.end(); ++i) { - if ((*i)->isLocked()) { - (*i)->setLocked(false); - _desktop->selection->add(*i); + for(auto & item : items) { + if (item->isLocked()) { + item->setLocked(false); + _desktop->selection->add(item); } } } @@ -227,10 +227,10 @@ void ContextMenu::UnLockBelow(std::vector<SPItem *> items) void ContextMenu::UnHideBelow(std::vector<SPItem *> items) { _desktop->selection->clear(); - for(auto i=items.begin();i!=items.end(); ++i) { - if ((*i)->isHidden()) { - (*i)->setHidden(false); - _desktop->selection->add(*i); + for(auto & item : items) { + if (item->isHidden()) { + item->setHidden(false); + _desktop->selection->add(item); } } } diff --git a/src/ui/control-manager.cpp b/src/ui/control-manager.cpp index 7ce30e63f..d97405f7a 100644 --- a/src/ui/control-manager.cpp +++ b/src/ui/control-manager.cpp @@ -204,10 +204,10 @@ void ControlManagerImpl::setControlSize(int size, bool force) } else if (force || (size != _size)) { _size = size; - for (std::vector<SPCanvasItem *>::iterator it = _itemList.begin(); it != _itemList.end(); ++it) + for (auto & it : _itemList) { - if (*it) { - updateItem(*it); + if (it) { + updateItem(it); } } diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 0bae88103..b43afe179 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -190,11 +190,9 @@ void ActionAlign::do_action(SPDesktop *desktop, int index) //Move each item in the selected list separately bool changed = false; - for (std::vector<SPItem*>::iterator it(selected.begin()); - it != selected.end(); ++it) + for (auto item : selected) { - SPItem* item= *it; - desktop->getDocument()->ensureUpToDate(); + desktop->getDocument()->ensureUpToDate(); if (!sel_as_group) b = (item)->desktopPreferredBounds(); if (b && (!focus || (item) != focus)) { @@ -316,10 +314,7 @@ private : Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int prefs_bbox = prefs->getBool("/tools/bounding_box"); std::vector< BBoxSort > sorted; - for (std::vector<SPItem*>::iterator it(selected.begin()); - it != selected.end(); - ++it){ - SPItem *item = *it; + for (auto item : selected){ Geom::OptRect bbox = !prefs_bbox ? (item)->desktopVisualBounds() : (item)->desktopGeometricBounds(); if (bbox) { sorted.emplace_back(item, *bbox, _orientation, kBegin, kEnd); @@ -713,12 +708,9 @@ private : int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); - for (std::vector<SPItem*>::iterator it(selected.begin()); - it != selected.end(); - ++it) + for (auto item : selected) { - SPItem* item = *it; - desktop->getDocument()->ensureUpToDate(); + desktop->getDocument()->ensureUpToDate(); Geom::OptRect item_box = !prefs_bbox ? (item)->desktopVisualBounds() : (item)->desktopGeometricBounds(); if (item_box) { // find new center, staying within bbox @@ -793,12 +785,9 @@ private : std::vector<Baselines> sorted; - for (std::vector<SPItem*>::iterator it(selected.begin()); - it != selected.end(); - ++it) + for (auto item : selected) { - SPItem* item = *it; - if (SP_IS_TEXT (item) || SP_IS_FLOWTEXT (item)) { + if (SP_IS_TEXT (item) || SP_IS_FLOWTEXT (item)) { Inkscape::Text::Layout const *layout = te_get_layout(item); boost::optional<Geom::Point> pt = layout->baselineAnchorPoint(); if (pt) { @@ -881,12 +870,9 @@ private : ref_point = b->min(); } - for (std::vector<SPItem*>::iterator it(selected.begin()); - it != selected.end(); - ++it) + for (auto item : selected) { - SPItem* item = *it; - if (SP_IS_TEXT (item) || SP_IS_FLOWTEXT (item)) { + if (SP_IS_TEXT (item) || SP_IS_FLOWTEXT (item)) { Inkscape::Text::Layout const *layout = te_get_layout(item); boost::optional<Geom::Point> pt = layout->baselineAnchorPoint(); if (pt) { @@ -1151,9 +1137,8 @@ AlignAndDistribute::AlignAndDistribute() AlignAndDistribute::~AlignAndDistribute() { - for (std::list<Action *>::iterator it = _actionList.begin(); - it != _actionList.end(); ++it) { - delete *it; + for (auto & it : _actionList) { + delete it; } _toolChangeConn.disconnect(); diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index e179d3692..550e20b45 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -142,9 +142,7 @@ CloneTiler::CloneTiler () : GTK_CELL_RENDERER(cell_list->data), "markup", 0, NULL); - for (unsigned j = 0; j < G_N_ELEMENTS(sym_groups); ++j) { - SymGroups const &sg = sym_groups[j]; - + for (const auto & sg : sym_groups) { // Add the description of the symgroup to a new row combo->append(sg.label); } diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp index ad355f8d2..acec954fe 100644 --- a/src/ui/dialog/color-item.cpp +++ b/src/ui/dialog/color-item.cpp @@ -416,22 +416,22 @@ void ColorItem::_updatePreviews() } } - for ( std::vector<ColorItem*>::iterator it = _listeners.begin(); it != _listeners.end(); ++it ) { + for (auto & _listener : _listeners) { guint r = def.getR(); guint g = def.getG(); guint b = def.getB(); - if ( (*it)->_linkIsTone ) { - r = ( ((*it)->_linkPercent * (*it)->_linkGray) + ((100 - (*it)->_linkPercent) * r) ) / 100; - g = ( ((*it)->_linkPercent * (*it)->_linkGray) + ((100 - (*it)->_linkPercent) * g) ) / 100; - b = ( ((*it)->_linkPercent * (*it)->_linkGray) + ((100 - (*it)->_linkPercent) * b) ) / 100; + if ( _listener->_linkIsTone ) { + r = ( (_listener->_linkPercent * _listener->_linkGray) + ((100 - _listener->_linkPercent) * r) ) / 100; + g = ( (_listener->_linkPercent * _listener->_linkGray) + ((100 - _listener->_linkPercent) * g) ) / 100; + b = ( (_listener->_linkPercent * _listener->_linkGray) + ((100 - _listener->_linkPercent) * b) ) / 100; } else { - r = ( ((*it)->_linkPercent * 255) + ((100 - (*it)->_linkPercent) * r) ) / 100; - g = ( ((*it)->_linkPercent * 255) + ((100 - (*it)->_linkPercent) * g) ) / 100; - b = ( ((*it)->_linkPercent * 255) + ((100 - (*it)->_linkPercent) * b) ) / 100; + r = ( (_listener->_linkPercent * 255) + ((100 - _listener->_linkPercent) * r) ) / 100; + g = ( (_listener->_linkPercent * 255) + ((100 - _listener->_linkPercent) * g) ) / 100; + b = ( (_listener->_linkPercent * 255) + ((100 - _listener->_linkPercent) * b) ) / 100; } - (*it)->def.setRGB( r, g, b ); + _listener->def.setRGB( r, g, b ); } diff --git a/src/ui/dialog/document-metadata.cpp b/src/ui/dialog/document-metadata.cpp index 8513e94a6..c93572a1a 100644 --- a/src/ui/dialog/document-metadata.cpp +++ b/src/ui/dialog/document-metadata.cpp @@ -98,8 +98,8 @@ DocumentMetadata::~DocumentMetadata() Inkscape::XML::Node *repr = getDesktop()->getNamedView()->getRepr(); repr->removeListenerByData (this); - for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); ++it) - delete (*it); + for (auto & it : _rdflist) + delete it; } void @@ -172,8 +172,8 @@ void DocumentMetadata::update() //-----------------------------------------------------------meta pages /* update the RDF entities */ - for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); ++it) - (*it)->update (SP_ACTIVE_DOCUMENT); + for (auto & it : _rdflist) + it->update (SP_ACTIVE_DOCUMENT); _licensor.update (SP_ACTIVE_DOCUMENT); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 3153e2ac5..ba101921b 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -199,8 +199,8 @@ DocumentProperties::~DocumentProperties() Inkscape::XML::Node *root = getDesktop()->getDocument()->getRoot()->getRepr(); root->removeListenerByData (this); - for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); ++it) - delete (*it); + for (auto & it : _rdflist) + delete it; } //======================================================================== @@ -1495,8 +1495,8 @@ void DocumentProperties::update() //-----------------------------------------------------------meta pages /* update the RDF entities */ - for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); ++it) - (*it)->update (SP_ACTIVE_DOCUMENT); + for (auto & it : _rdflist) + it->update (SP_ACTIVE_DOCUMENT); _licensor.update (SP_ACTIVE_DOCUMENT); @@ -1540,16 +1540,16 @@ void DocumentProperties::on_response (int id) void DocumentProperties::load_default_metadata() { /* Get the data RDF entities data from preferences*/ - for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); ++it) { - (*it)->load_from_preferences (); + for (auto & it : _rdflist) { + it->load_from_preferences (); } } void DocumentProperties::save_default_metadata() { /* Save these RDF entities to preferences*/ - for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); ++it) { - (*it)->save_to_preferences (SP_ACTIVE_DOCUMENT); + for (auto & it : _rdflist) { + it->save_to_preferences (SP_ACTIVE_DOCUMENT); } } diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 95b85471f..e59db92f4 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -332,13 +332,13 @@ Export::Export () : Gtk::Label *label_advanced = Gtk::manage(new Gtk::Label(_("Advanced"),true)); expander.set_label_widget(*label_advanced); const char* const modes_list[]={"Gray_1", "Gray_2","Gray_4","Gray_8","Gray_16","RGB_8","RGB_16","GrayAlpha_8","GrayAlpha_16","RGBA_8","RGBA_16"}; - for(int i=0; i<11; ++i) - bitdepth_cb.append(modes_list[i]); + for(auto i : modes_list) + bitdepth_cb.append(i); bitdepth_cb.set_active_text("RGBA_8"); bitdepth_cb.set_hexpand(); const char* const zlist[]={"Z_NO_COMPRESSION","Z_BEST_SPEED","2","3","4","5","Z_DEFAULT_COMPRESSION","7","8","Z_BEST_COMPRESSION"}; - for(int i=0; i<10; ++i) - zlib_compression.append(zlist[i]); + for(auto i : zlist) + zlib_compression.append(i); zlib_compression.set_active_text("Z_DEFAULT_COMPRESSION"); pHYs_adj = Gtk::Adjustment::create(0, 0, 100000, 0.1, 1.0, 0); pHYs_sb.set_adjustment(pHYs_adj); @@ -346,8 +346,8 @@ Export::Export () : pHYs_sb.set_tooltip_text( _("Will force-set the physical dpi for the png file. Set this to 72 if you're planning to work on your png with Photoshop") ); zlib_compression.set_hexpand(); const char* const antialising_list[] = {"CAIRO_ANTIALIAS_NONE","CAIRO_ANTIALIAS_FAST","CAIRO_ANTIALIAS_GOOD (default)","CAIRO_ANTIALIAS_BEST"}; - for(int i=0; i<4; ++i) - antialiasing_cb.append(antialising_list[i]); + for(auto i : antialising_list) + antialiasing_cb.append(i); antialiasing_cb.set_active_text(antialising_list[2]); auto table = new Gtk::Grid(); gtk_container_add(GTK_CONTAINER(expander.gobj()), (GtkWidget*)(table->gobj())); diff --git a/src/ui/dialog/filedialog.cpp b/src/ui/dialog/filedialog.cpp index 683a66106..f98e129eb 100644 --- a/src/ui/dialog/filedialog.cpp +++ b/src/ui/dialog/filedialog.cpp @@ -64,13 +64,11 @@ bool hasSuffix(const Glib::ustring &str, const Glib::ustring &ext) bool isValidImageFile(const Glib::ustring &fileName) { std::vector<Gdk::PixbufFormat>formats = Gdk::Pixbuf::get_formats(); - for (unsigned int i=0; i<formats.size(); i++) + for (auto format : formats) { - Gdk::PixbufFormat format = formats[i]; std::vector<Glib::ustring>extensions = format.get_extensions(); - for (unsigned int j=0; j<extensions.size(); j++) + for (auto ext : extensions) { - Glib::ustring ext = extensions[j]; if (hasSuffix(fileName, ext)) return true; } diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index 8652be3a8..7b2867458 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -67,8 +67,7 @@ namespace Dialog { void fileDialogExtensionToPattern(Glib::ustring &pattern, Glib::ustring &extension) { - for (unsigned int i = 0; i < extension.length(); ++i) { - Glib::ustring::value_type ch = extension[i]; + for (unsigned int ch : extension) { if (Glib::Unicode::isalpha(ch)) { pattern += '['; pattern += Glib::Unicode::toupper(ch); @@ -87,8 +86,7 @@ void findEntryWidgets(Gtk::Container *parent, std::vector<Gtk::Entry *> &result) return; } std::vector<Gtk::Widget *> children = parent->get_children(); - for (unsigned int i = 0; i < children.size(); ++i) { - Gtk::Widget *child = children[i]; + for (auto child : children) { GtkWidget *wid = child->gobj(); if (GTK_IS_ENTRY(wid)) result.push_back(dynamic_cast<Gtk::Entry *>(child)); @@ -102,8 +100,7 @@ void findExpanderWidgets(Gtk::Container *parent, std::vector<Gtk::Expander *> &r if (!parent) return; std::vector<Gtk::Widget *> children = parent->get_children(); - for (unsigned int i = 0; i < children.size(); ++i) { - Gtk::Widget *child = children[i]; + for (auto child : children) { GtkWidget *wid = child->gobj(); if (GTK_IS_EXPANDER(wid)) result.push_back(dynamic_cast<Gtk::Expander *>(child)); @@ -742,11 +739,8 @@ void FileOpenDialogImplGtk::createFilterMenu() Inkscape::Extension::DB::InputList extension_list; Inkscape::Extension::db.get_input_list(extension_list); - for (Inkscape::Extension::DB::InputList::iterator current_item = extension_list.begin(); - current_item != extension_list.end(); ++current_item) + for (auto imod : extension_list) { - Inkscape::Extension::Input *imod = *current_item; - // FIXME: would be nice to grey them out instead of not listing them if (imod->deactivated()) continue; @@ -1091,10 +1085,7 @@ void FileSaveDialogImplGtk::createFileTypeMenu() Inkscape::Extension::db.get_output_list(extension_list); knownExtensions.clear(); - for (Inkscape::Extension::DB::OutputList::iterator current_item = extension_list.begin(); - current_item != extension_list.end(); ++current_item) { - Inkscape::Extension::Output *omod = *current_item; - + for (auto omod : extension_list) { // FIXME: would be nice to grey them out instead of not listing them if (omod->deactivated()) continue; diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index d49f6d08c..8a246de62 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -215,8 +215,8 @@ public: ~MultiSpinButton() override { - for(unsigned i = 0; i < _spins.size(); ++i) - delete _spins[i]; + for(auto & _spin : _spins) + delete _spin; } std::vector<SpinButtonAttr*>& get_spinbuttons() @@ -391,10 +391,9 @@ public: std::vector<double> get_values() const { std::vector<double> vec; - for(Gtk::TreeIter iter = _model->children().begin(); - iter != _model->children().end(); ++iter) { + for(const auto & iter : _model->children()) { for(unsigned c = 0; c < _tree.get_columns().size(); ++c) - vec.push_back((*iter)[_columns.cols[c]]); + vec.push_back(iter[_columns.cols[c]]); } return vec; } @@ -402,12 +401,11 @@ public: void set_values(const std::vector<double>& v) { unsigned i = 0; - for(Gtk::TreeIter iter = _model->children().begin(); - iter != _model->children().end(); ++iter) { + for(const auto & iter : _model->children()) { for(unsigned c = 0; c < _tree.get_columns().size(); ++c) { if(i >= v.size()) return; - (*iter)[_columns.cols[c]] = v[i]; + iter[_columns.cols[c]] = v[i]; ++i; } } @@ -418,10 +416,9 @@ public: // use SVGOStringStream to output SVG-compatible doubles Inkscape::SVGOStringStream os; - for(Gtk::TreeIter iter = _model->children().begin(); - iter != _model->children().end(); ++iter) { + for(const auto & iter : _model->children()) { for(unsigned c = 0; c < _tree.get_columns().size(); ++c) { - os << (*iter)[_columns.cols[c]] << " "; + os << iter[_columns.cols[c]] << " "; } } @@ -451,8 +448,8 @@ private: MatrixColumns() { cols.resize(5); - for(unsigned i = 0; i < cols.size(); ++i) - add(cols[i]); + for(auto & col : cols) + add(col); } std::vector<Gtk::TreeModelColumn<double> > cols; }; @@ -754,8 +751,8 @@ public: { for(int i = 0; i < _max_types; ++i) { delete _groups[i]; - for(unsigned j = 0; j < _attrwidgets[i].size(); ++j) - delete _attrwidgets[i][j]; + for(auto & j : _attrwidgets[i]) + delete j; } } @@ -764,15 +761,15 @@ public: { if(t != _current_type) { type(t); - for(unsigned i = 0; i < _groups.size(); ++i) - _groups[i]->hide(); + for(auto & _group : _groups) + _group->hide(); } if(t >= 0) { _groups[t]->show(); // Do not use show_all(), it shows children than should be hidden } _dialog.set_attrs_locked(true); - for(unsigned i = 0; i < _attrwidgets[_current_type].size(); ++i) - _attrwidgets[_current_type][i]->set_from_attribute(ob); + for(auto & i : _attrwidgets[_current_type]) + i->set_from_attribute(ob); _dialog.set_attrs_locked(false); } @@ -908,8 +905,8 @@ public: MultiSpinButton* msb = new MultiSpinButton(lo, hi, step_inc, climb, digits, attrs, default_values, tips); add_widget(msb, label); - for(unsigned i = 0; i < msb->get_spinbuttons().size(); ++i) - add_attr_widget(msb->get_spinbuttons()[i]); + for(auto & i : msb->get_spinbuttons()) + add_attr_widget(i); return msb; } MultiSpinButton* add_multispinbutton(double def1, double def2, double def3, const SPAttributeEnum attr1, const SPAttributeEnum attr2, @@ -933,8 +930,8 @@ public: MultiSpinButton* msb = new MultiSpinButton(lo, hi, step_inc, climb, digits, attrs, default_values, tips); add_widget(msb, label); - for(unsigned i = 0; i < msb->get_spinbuttons().size(); ++i) - add_attr_widget(msb->get_spinbuttons()[i]); + for(auto & i : msb->get_spinbuttons()) + add_attr_widget(i); return msb; } @@ -1565,9 +1562,9 @@ void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustri void FilterEffectsDialog::FilterModifier::update_counts() { - for(Gtk::TreeModel::iterator i = _model->children().begin(); i != _model->children().end(); ++i) { - SPFilter* f = SP_FILTER((*i)[_columns.filter]); - (*i)[_columns.count] = f->getRefCount(); + for(const auto & i : _model->children()) { + SPFilter* f = SP_FILTER(i[_columns.filter]); + i[_columns.count] = f->getRefCount(); } } @@ -3074,8 +3071,8 @@ void FilterEffectsDialog::update_settings_view() //First Tab std::vector<Gtk::Widget*> vect1 = _settings_tab1.get_children(); - for(unsigned int i=0; i<vect1.size(); i++) - vect1[i]->hide(); + for(auto & i : vect1) + i->hide(); _empty_settings.show(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index 020292217..a00069d96 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -288,12 +288,12 @@ Find::Find() check_searchin_property.signal_clicked().connect(sigc::mem_fun(*this, &Find::onSearchinProperty)); check_alltypes.signal_clicked().connect(sigc::mem_fun(*this, &Find::onToggleAlltypes)); - for(size_t i = 0; i < checkProperties.size(); i++) { - checkProperties[i]->signal_clicked().connect(sigc::mem_fun(*this, &Find::onToggleCheck)); + for(auto & checkPropertie : checkProperties) { + checkPropertie->signal_clicked().connect(sigc::mem_fun(*this, &Find::onToggleCheck)); } - for(size_t i = 0; i < checkTypes.size(); i++) { - checkTypes[i]->signal_clicked().connect(sigc::mem_fun(*this, &Find::onToggleCheck)); + for(auto & checkType : checkTypes) { + checkType->signal_clicked().connect(sigc::mem_fun(*this, &Find::onToggleCheck)); } onSearchinText(); @@ -577,11 +577,11 @@ bool Find::item_font_match(SPItem *item, const gchar *text, bool exact, bool cas vFontTokenNames.emplace_back("-inkscape-font-specification:"); std::vector<Glib::ustring> vStyleTokens = Glib::Regex::split_simple(";", item_style); - for(size_t i=0; i<vStyleTokens.size(); i++) { - Glib::ustring token = vStyleTokens[i]; - for(size_t j=0; j<vFontTokenNames.size(); j++) { - if ( token.find(vFontTokenNames[j]) != std::string::npos) { - Glib::ustring font1 = Glib::ustring(vFontTokenNames[j]).append(text); + for(auto & vStyleToken : vStyleTokens) { + Glib::ustring token = vStyleToken; + for(const auto & vFontTokenName : vFontTokenNames) { + if ( token.find(vFontTokenName) != std::string::npos) { + Glib::ustring font1 = Glib::ustring(vFontTokenName).append(text); bool found = find_strcmp(token.c_str(), font1.c_str(), exact, casematch); if (found) { ret = true; @@ -591,7 +591,7 @@ bool Find::item_font_match(SPItem *item, const gchar *text, bool exact, bool cas // Exact match fails since the "font-family:" is in the token, since the find was exact it still works with false below Glib::ustring new_item_style = find_replace(orig_str, text, replace_text , false /*exact*/, casematch, true); if (new_item_style != orig_str) { - vStyleTokens.at(i) = new_item_style; + vStyleToken = new_item_style; } g_free(orig_str); g_free(replace_text); @@ -603,8 +603,8 @@ bool Find::item_font_match(SPItem *item, const gchar *text, bool exact, bool cas if (ret && _action_replace) { Glib::ustring new_item_style; - for(size_t i=0; i<vStyleTokens.size(); i++) { - new_item_style.append(vStyleTokens.at(i)).append(";"); + for(const auto & vStyleToken : vStyleTokens) { + new_item_style.append(vStyleToken).append(";"); } new_item_style.erase(new_item_style.size()-1); item->getRepr()->setAttribute("style", new_item_style.data()); @@ -968,8 +968,8 @@ void Find::onToggleCheck () propertyok = true; } else { - for(size_t i = 0; i < checkProperties.size(); i++) { - if (checkProperties[i]->get_active()) { + for(auto & checkPropertie : checkProperties) { + if (checkPropertie->get_active()) { propertyok = true; } } @@ -990,8 +990,8 @@ void Find::onToggleCheck () void Find::onToggleAlltypes () { bool all =check_alltypes.get_active(); - for(size_t i = 0; i < checkTypes.size(); i++) { - checkTypes[i]->set_sensitive(!all); + for(auto & checkType : checkTypes) { + checkType->set_sensitive(!all); } onToggleCheck(); @@ -1011,8 +1011,8 @@ void Find::onSearchinProperty () void Find::searchinToggle(bool on) { - for(size_t i = 0; i < checkProperties.size(); i++) { - checkProperties[i]->set_sensitive(on); + for(auto & checkPropertie : checkProperties) { + checkPropertie->set_sensitive(on); } } diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp index 549c3d665..bf371588a 100644 --- a/src/ui/dialog/font-substitution.cpp +++ b/src/ui/dialog/font-substitution.cpp @@ -200,8 +200,7 @@ std::vector<SPItem*> FontSubstitution::getFontReplacedItems(SPDocument* doc, Gli // CSS font fallbacks can have more that one font listed, split the font list std::vector<Glib::ustring> vFonts = Glib::Regex::split_simple("," , fonts); bool fontFound = false; - for(size_t i=0; i<vFonts.size(); i++) { - Glib::ustring font = vFonts[i]; + for(auto font : vFonts) { // trim whitespace size_t startpos = font.find_first_not_of(" \n\r\t"); size_t endpos = font.find_last_not_of(" \n\r\t"); diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index f080315ec..120e39065 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -355,9 +355,9 @@ GlyphsPanel::GlyphsPanel() : table->attach( *Gtk::manage(label), 0, row, 1, 1); scriptCombo = Gtk::manage(new Gtk::ComboBoxText()); - for (std::map<GUnicodeScript, Glib::ustring>::iterator it = getScriptToName().begin(); it != getScriptToName().end(); ++it) + for (auto & it : getScriptToName()) { - scriptCombo->append(it->second); + scriptCombo->append(it.second); } scriptCombo->set_active_text(getScriptToName()[G_UNICODE_SCRIPT_INVALID_CODE]); @@ -379,8 +379,8 @@ GlyphsPanel::GlyphsPanel() : table->attach( *Gtk::manage(label), 0, row, 1, 1); rangeCombo = Gtk::manage(new Gtk::ComboBoxText()); - for ( std::vector<NamedRange>::iterator it = getRanges().begin(); it != getRanges().end(); ++it ) { - rangeCombo->append(it->second); + for (auto & it : getRanges()) { + rangeCombo->append(it.second); } rangeCombo->set_active_text(getRanges()[1].second); @@ -463,12 +463,12 @@ GlyphsPanel::GlyphsPanel() : GlyphsPanel::~GlyphsPanel() { - for (std::vector<sigc::connection>::iterator it = instanceConns.begin(); it != instanceConns.end(); ++it) { - it->disconnect(); + for (auto & instanceConn : instanceConns) { + instanceConn.disconnect(); } instanceConns.clear(); - for (std::vector<sigc::connection>::iterator it = desktopConns.begin(); it != desktopConns.end(); ++it) { - it->disconnect(); + for (auto & desktopConn : desktopConns) { + desktopConn.disconnect(); } desktopConns.clear(); } @@ -484,8 +484,8 @@ void GlyphsPanel::setTargetDesktop(SPDesktop *desktop) { if (targetDesktop != desktop) { if (targetDesktop) { - for (std::vector<sigc::connection>::iterator it = desktopConns.begin(); it != desktopConns.end(); ++it) { - it->disconnect(); + for (auto & desktopConn : desktopConns) { + desktopConn.disconnect(); } desktopConns.clear(); } @@ -655,9 +655,9 @@ void GlyphsPanel::rebuild() GUnicodeScript script = G_UNICODE_SCRIPT_INVALID_CODE; Glib::ustring scriptName = scriptCombo->get_active_text(); std::map<GUnicodeScript, Glib::ustring> items = getScriptToName(); - for (std::map<GUnicodeScript, Glib::ustring>::iterator it = items.begin(); it != items.end(); ++it) { - if (scriptName == it->second) { - script = it->first; + for (auto & item : items) { + if (scriptName == item.second) { + script = item.first; break; } } @@ -685,12 +685,12 @@ void GlyphsPanel::rebuild() GlyphColumns *columns = getColumns(); store->clear(); - for (std::vector<gunichar>::iterator it = present.begin(); it != present.end(); ++it) + for (unsigned int & it : present) { Gtk::ListStore::iterator row = store->append(); Glib::ustring tmp; - tmp += *it; - (*row)[columns->code] = *it; + tmp += it; + (*row)[columns->code] = it; (*row)[columns->name] = tmp; } diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp index ba3df005e..2bef67d42 100644 --- a/src/ui/dialog/grid-arrange-tab.cpp +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -198,8 +198,7 @@ cnt=0; const std::vector<SPItem*> sizes(sorted); - for (std::vector<SPItem*>::const_iterator i = sizes.begin();i!=sizes.end(); ++i) { - SPItem *item = *i; + for (auto item : sizes) { Geom::OptRect b = item->documentVisualBounds(); if (b) { width = b->dimensions()[Geom::X]; diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index e3f157a2b..bec6298d5 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -111,9 +111,9 @@ IconPreviewPanel::IconPreviewPanel() : std::vector<Glib::ustring> pref_sizes = prefs->getAllDirs("/iconpreview/sizes/default"); std::vector<int> rawSizes; - for (std::vector<Glib::ustring>::iterator i = pref_sizes.begin(); i != pref_sizes.end(); ++i) { - if (prefs->getBool(*i + "/show", true)) { - int sizeVal = prefs->getInt(*i + "/value", -1); + for (auto & pref_size : pref_sizes) { + if (prefs->getBool(pref_size + "/show", true)) { + int sizeVal = prefs->getInt(pref_size + "/value", -1); if (sizeVal > 0) { rawSizes.push_back(sizeVal); } diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 2a6cb9ebe..e2be3d431 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -1385,9 +1385,9 @@ void InkscapePreferences::initPageIO() gint index = 0; _cms_display_profile.append(_("<none>")); index++; - for ( std::vector<Glib::ustring>::iterator it = names.begin(); it != names.end(); ++it ) { - _cms_display_profile.append( *it ); - Glib::ustring path = CMSSystem::getPathForProfile(*it); + for (auto & name : names) { + _cms_display_profile.append( name ); + Glib::ustring path = CMSSystem::getPathForProfile(name); if ( !path.empty() && path == current ) { _cms_display_profile.set_active(index); } @@ -1400,9 +1400,9 @@ void InkscapePreferences::initPageIO() names = ::Inkscape::CMSSystem::getSoftproofNames(); current = prefs->getString("/options/softproof/uri"); index = 0; - for ( std::vector<Glib::ustring>::iterator it = names.begin(); it != names.end(); ++it ) { - _cms_proof_profile.append( *it ); - Glib::ustring path = CMSSystem::getPathForProfile(*it); + for (auto & name : names) { + _cms_proof_profile.append( name ); + Glib::ustring path = CMSSystem::getPathForProfile(name); if ( !path.empty() && path == current ) { _cms_proof_profile.set_active(index); } @@ -2114,9 +2114,8 @@ void InkscapePreferences::onKBListKeyboardShortcuts() std::vector<Verb *>verbs = Inkscape::Verb::getList(); - for (unsigned int i = 0; i < verbs.size(); i++) { + for (auto verb : verbs) { - Inkscape::Verb* verb = verbs[i]; if (!verb) { continue; } diff --git a/src/ui/dialog/input.cpp b/src/ui/dialog/input.cpp index b1578d6dc..080a4de12 100644 --- a/src/ui/dialog/input.cpp +++ b/src/ui/dialog/input.cpp @@ -624,9 +624,9 @@ InputDialogImpl::InputDialogImpl() : { guint col = 0; guint row = 1; - for ( guint num = 0; num < G_N_ELEMENTS(testButtons); num++ ) { - testButtons[num].set(getPix(PIX_BUTTONS_NONE)); - imageTable.attach(testButtons[num], col, row, 1, 1); + for (auto & testButton : testButtons) { + testButton.set(getPix(PIX_BUTTONS_NONE)); + imageTable.attach(testButton, col, row, 1, 1); col++; if (col > 7) { col = 0; @@ -635,9 +635,9 @@ InputDialogImpl::InputDialogImpl() : } col = 0; - for ( guint num = 0; num < G_N_ELEMENTS(testAxes); num++ ) { - testAxes[num].set(getPix(PIX_AXIS_NONE)); - imageTable.attach(testAxes[num], col * 2, row, 2, 1); + for (auto & testAxe : testAxes) { + testAxe.set(getPix(PIX_AXIS_NONE)); + imageTable.attach(testAxe, col * 2, row, 2, 1); col++; if (col > 3) { col = 0; @@ -678,14 +678,14 @@ InputDialogImpl::InputDialogImpl() : axisTable.attach(devAxesCount, 1, rowNum, 1, 1); rowNum++; - for ( guint barNum = 0; barNum < static_cast<guint>(G_N_ELEMENTS(axesValues)); barNum++ ) { + for (auto & axesValue : axesValues) { lbl = Gtk::manage(new Gtk::Label(_("axis:"))); lbl->set_hexpand(); axisTable.attach(*lbl, 0, rowNum, 1, 1); - axesValues[barNum].set_hexpand(); - axisTable.attach(axesValues[barNum], 1, rowNum, 1, 1); - axesValues[barNum].set_sensitive(false); + axesValue.set_hexpand(); + axisTable.attach(axesValue, 1, rowNum, 1, 1); + axesValue.set_sensitive(false); rowNum++; @@ -760,9 +760,9 @@ static Glib::ustring getCommon( std::list<Glib::ustring> const &names ) while ( match ) { if ( names.begin()->length() > pos ) { gunichar ch = (*names.begin())[pos]; - for ( std::list<Glib::ustring>::const_iterator it = names.begin(); it != names.end(); ++it ) { - if ( (pos >= it->length()) - || ((*it)[pos] != ch) ) { + for (const auto & name : names) { + if ( (pos >= name.length()) + || (name[pos] != ch) ) { match = false; break; } @@ -810,8 +810,7 @@ void InputDialogImpl::setupTree( Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeIt std::set<Glib::ustring> consumed; // Phase 1 - figure out which tablets are present - for ( std::list<Glib::RefPtr<InputDevice const> >::iterator it = devList.begin(); it != devList.end(); ++it ) { - Glib::RefPtr<InputDevice const> dev = *it; + for (auto dev : devList) { if ( dev ) { if ( dev->getSource() != Gdk::SOURCE_MOUSE ) { consumed.insert( dev->getId() ); @@ -827,28 +826,28 @@ void InputDialogImpl::setupTree( Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeIt } // Phase 2 - build a UI for the present devices - for ( std::list<TabletTmp>::iterator it = tablets.begin(); it != tablets.end(); ++it ) { + for (auto & it : tablets) { tablet = store->prepend(/*row.children()*/); Gtk::TreeModel::Row childrow = *tablet; - if ( it->name.empty() ) { + if ( it.name.empty() ) { // Check to see if we can derive one std::list<Glib::ustring> names; - for ( std::list<Glib::RefPtr<InputDevice const> >::iterator it2 = it->devices.begin(); it2 != it->devices.end(); ++it2 ) { + for ( std::list<Glib::RefPtr<InputDevice const> >::iterator it2 = it.devices.begin(); it2 != it.devices.end(); ++it2 ) { names.push_back( (*it2)->getName() ); } Glib::ustring common = getCommon(names); if ( !common.empty() ) { - it->name = common; + it.name = common; } } - childrow[getCols().description] = it->name.empty() ? _("Tablet") : it->name ; + childrow[getCols().description] = it.name.empty() ? _("Tablet") : it.name ; childrow[getCols().thumbnail] = getPix(PIX_TABLET); // Check if there is an eraser we can link to a pen - for ( std::list<Glib::RefPtr<InputDevice const> >::iterator it2 = it->devices.begin(); it2 != it->devices.end(); ++it2 ) { + for ( std::list<Glib::RefPtr<InputDevice const> >::iterator it2 = it.devices.begin(); it2 != it.devices.end(); ++it2 ) { Glib::RefPtr<InputDevice const> dev = *it2; if ( dev->getSource() == Gdk::SOURCE_PEN ) { - for ( std::list<Glib::RefPtr<InputDevice const> >::iterator it3 = it->devices.begin(); it3 != it->devices.end(); ++it3 ) { + for ( std::list<Glib::RefPtr<InputDevice const> >::iterator it3 = it.devices.begin(); it3 != it.devices.end(); ++it3 ) { Glib::RefPtr<InputDevice const> dev2 = *it3; if ( dev2->getSource() == Gdk::SOURCE_ERASER ) { DeviceManager::getManager().setLinkedTo(dev->getId(), dev2->getId()); @@ -859,7 +858,7 @@ void InputDialogImpl::setupTree( Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeIt } } - for ( std::list<Glib::RefPtr<InputDevice const> >::iterator it2 = it->devices.begin(); it2 != it->devices.end(); ++it2 ) { + for ( std::list<Glib::RefPtr<InputDevice const> >::iterator it2 = it.devices.begin(); it2 != it.devices.end(); ++it2 ) { Glib::RefPtr<InputDevice const> dev = *it2; Gtk::TreeModel::Row deviceRow = *(store->append(childrow.children())); deviceRow[getCols().description] = dev->getName(); @@ -888,8 +887,7 @@ void InputDialogImpl::setupTree( Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeIt } } - for ( std::list<Glib::RefPtr<InputDevice const> >::iterator it = devList.begin(); it != devList.end(); ++it ) { - Glib::RefPtr<InputDevice const> dev = *it; + for (auto dev : devList) { if ( dev && (consumed.find( dev->getId() ) == consumed.end()) ) { Gtk::TreeModel::Row deviceRow = *(store->prepend(/*row.children()*/)); deviceRow[getCols().description] = dev->getName(); @@ -1188,9 +1186,9 @@ void InputDialogImpl::handleDeviceChange(Glib::RefPtr<InputDevice const> device) stores.push_back(deviceStore); stores.push_back(cfgPanel.confDeviceStore); - for (std::vector<Glib::RefPtr<Gtk::TreeStore> >::iterator it = stores.begin(); it != stores.end(); ++it) { + for (auto & store : stores) { Gtk::TreeModel::iterator deviceIter; - (*it)->foreach_iter( sigc::bind<Glib::ustring, Gtk::TreeModel::iterator*>( + store->foreach_iter( sigc::bind<Glib::ustring, Gtk::TreeModel::iterator*>( sigc::ptr_fun(&InputDialogImpl::findDevice), device->getId(), &deviceIter) ); @@ -1572,10 +1570,10 @@ void InputDialogImpl::updateTestAxes( Glib::ustring const& key, GdkDevice* dev ) } } if ( !dev ) { - for ( gint i = 0; i < static_cast<gint>(G_N_ELEMENTS(axesValues)); i++ ) { - axesValues[i].set_fraction(0.0); - axesValues[i].set_text(""); - axesValues[i].set_sensitive(false); + for (auto & axesValue : axesValues) { + axesValue.set_fraction(0.0); + axesValue.set_text(""); + axesValue.set_sensitive(false); } } } diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index 46c733bf5..79bf767c7 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -480,14 +480,14 @@ void LayersPanel::_checkTreeSelection() } - for ( std::vector<Gtk::Widget*>::iterator it = _watching.begin(); it != _watching.end(); ++it ) { - (*it)->set_sensitive( sensitive ); + for (auto & it : _watching) { + it->set_sensitive( sensitive ); } - for ( std::vector<Gtk::Widget*>::iterator it = _watchingNonTop.begin(); it != _watchingNonTop.end(); ++it ) { - (*it)->set_sensitive( sensitiveNonTop ); + for (auto & it : _watchingNonTop) { + it->set_sensitive( sensitiveNonTop ); } - for ( std::vector<Gtk::Widget*>::iterator it = _watchingNonBottom.begin(); it != _watchingNonBottom.end(); ++it ) { - (*it)->set_sensitive( sensitiveNonBottom ); + for (auto & it : _watchingNonBottom) { + it->set_sensitive( sensitiveNonBottom ); } } @@ -927,14 +927,14 @@ LayersPanel::LayersPanel() : - for ( std::vector<Gtk::Widget*>::iterator it = _watching.begin(); it != _watching.end(); ++it ) { - (*it)->set_sensitive( false ); + for (auto & it : _watching) { + it->set_sensitive( false ); } - for ( std::vector<Gtk::Widget*>::iterator it = _watchingNonTop.begin(); it != _watchingNonTop.end(); ++it ) { - (*it)->set_sensitive( false ); + for (auto & it : _watchingNonTop) { + it->set_sensitive( false ); } - for ( std::vector<Gtk::Widget*>::iterator it = _watchingNonBottom.begin(); it != _watchingNonBottom.end(); ++it ) { - (*it)->set_sensitive( false ); + for (auto & it : _watchingNonBottom) { + it->set_sensitive( false ); } setDesktop( targetDesktop ); diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index 2954ea418..9e115a2d6 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -661,14 +661,14 @@ void ObjectsPanel::_checkTreeSelection() bool sensitiveNonTop = true; bool sensitiveNonBottom = true; - for ( std::vector<Gtk::Widget*>::iterator it = _watching.begin(); it != _watching.end(); ++it ) { - (*it)->set_sensitive( sensitive ); + for (auto & it : _watching) { + it->set_sensitive( sensitive ); } - for ( std::vector<Gtk::Widget*>::iterator it = _watchingNonTop.begin(); it != _watchingNonTop.end(); ++it ) { - (*it)->set_sensitive( sensitiveNonTop ); + for (auto & it : _watchingNonTop) { + it->set_sensitive( sensitiveNonTop ); } - for ( std::vector<Gtk::Widget*>::iterator it = _watchingNonBottom.begin(); it != _watchingNonBottom.end(); ++it ) { - (*it)->set_sensitive( sensitiveNonBottom ); + for (auto & it : _watchingNonBottom) { + it->set_sensitive( sensitiveNonBottom ); } } @@ -1478,9 +1478,8 @@ void ObjectsPanel::_highlightPickerColorMod() guint32 rgba = color.toRGBA32( alpha ); //Set the highlight color for all items in the _highlight_target (all selected items) - for (std::vector<SPItem *>::iterator iter = _highlight_target.begin(); iter != _highlight_target.end(); ++iter) + for (auto target : _highlight_target) { - SPItem * target = *iter; target->setHighlightColor(rgba); target->updateRepr(SP_OBJECT_WRITE_NO_CHILDREN | SP_OBJECT_WRITE_EXT); } @@ -1929,14 +1928,14 @@ ObjectsPanel::ObjectsPanel() : // ------------------------------------------------------- //Set initial sensitivity of buttons - for ( std::vector<Gtk::Widget*>::iterator it = _watching.begin(); it != _watching.end(); ++it ) { - (*it)->set_sensitive( false ); + for (auto & it : _watching) { + it->set_sensitive( false ); } - for ( std::vector<Gtk::Widget*>::iterator it = _watchingNonTop.begin(); it != _watchingNonTop.end(); ++it ) { - (*it)->set_sensitive( false ); + for (auto & it : _watchingNonTop) { + it->set_sensitive( false ); } - for ( std::vector<Gtk::Widget*>::iterator it = _watchingNonBottom.begin(); it != _watchingNonBottom.end(); ++it ) { - (*it)->set_sensitive( false ); + for (auto & it : _watchingNonBottom) { + it->set_sensitive( false ); } //Set up the color selection dialog diff --git a/src/ui/dialog/polar-arrange-tab.cpp b/src/ui/dialog/polar-arrange-tab.cpp index 821e75ea8..de026b8d5 100644 --- a/src/ui/dialog/polar-arrange-tab.cpp +++ b/src/ui/dialog/polar-arrange-tab.cpp @@ -269,13 +269,11 @@ void PolarArrangeTab::arrange() bool arrangeOnFirstEllipse = arrangeOnEllipse && arrangeOnFirstCircleRadio.get_active(); int count = 0; - for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();++i) + for(auto item : tmp) { if(arrangeOnEllipse) { - SPItem *item = *i; - - if(arrangeOnFirstEllipse) + if(arrangeOnFirstEllipse) { // The first selected ellipse is actually the last one in the list if(SP_IS_GENERICELLIPSE(item)) @@ -338,11 +336,9 @@ void PolarArrangeTab::arrange() Geom::Point realCenter = Geom::Point(cx, cy) * transformation; int i = 0; - for(std::vector<SPItem*>::const_iterator it=tmp.begin();it!=tmp.end(); ++it) + for(auto item : tmp) { - SPItem *item = *it; - - // Ignore the reference ellipse if any + // Ignore the reference ellipse if any if(item != referenceEllipse) { float angle = calcAngle(arcBeg, arcEnd, count, i); diff --git a/src/ui/dialog/spellcheck.cpp b/src/ui/dialog/spellcheck.cpp index 2f485bcce..cffd284a1 100644 --- a/src/ui/dialog/spellcheck.cpp +++ b/src/ui/dialog/spellcheck.cpp @@ -498,8 +498,8 @@ SpellCheck::nextWord() // skip words containing digits if (_prefs->getInt(_prefs_path + "ignorenumbers") != 0) { bool digits = false; - for (unsigned int i = 0; i < _word.size(); i++) { - if (g_unichar_isdigit(_word[i])) { + for (unsigned int i : _word) { + if (g_unichar_isdigit(i)) { digits = true; break; } @@ -512,8 +512,8 @@ SpellCheck::nextWord() // skip ALL-CAPS words if (_prefs->getInt(_prefs_path + "ignoreallcaps") != 0) { bool allcaps = true; - for (unsigned int i = 0; i < _word.size(); i++) { - if (!g_unichar_isupper(_word[i])) { + for (unsigned int i : _word) { + if (!g_unichar_isupper(i)) { allcaps = false; break; } @@ -564,15 +564,15 @@ SpellCheck::nextWord() if (points.size() >= 4) { // we may not have a single quad if this is a clipped part of text on path; in that case skip drawing the rect Geom::Point tl, br; tl = br = points.front(); - for (unsigned i = 0 ; i < points.size() ; i ++) { - if (points[i][Geom::X] < tl[Geom::X]) - tl[Geom::X] = points[i][Geom::X]; - if (points[i][Geom::Y] < tl[Geom::Y]) - tl[Geom::Y] = points[i][Geom::Y]; - if (points[i][Geom::X] > br[Geom::X]) - br[Geom::X] = points[i][Geom::X]; - if (points[i][Geom::Y] > br[Geom::Y]) - br[Geom::Y] = points[i][Geom::Y]; + for (auto & point : points) { + if (point[Geom::X] < tl[Geom::X]) + tl[Geom::X] = point[Geom::X]; + if (point[Geom::Y] < tl[Geom::Y]) + tl[Geom::Y] = point[Geom::Y]; + if (point[Geom::X] > br[Geom::X]) + br[Geom::X] = point[Geom::X]; + if (point[Geom::Y] > br[Geom::Y]) + br[Geom::Y] = point[Geom::Y]; } // expand slightly diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp index f3a44f690..3fad9962e 100644 --- a/src/ui/dialog/styledialog.cpp +++ b/src/ui/dialog/styledialog.cpp @@ -853,8 +853,7 @@ void StyleDialog::_selectObjects(int eventX, int eventY) Gtk::TreeModel::Children children = row.children(); std::vector<SPObject *> objVec = row[_mColumns._colObj]; - for (unsigned i = 0; i < objVec.size(); ++i) { - SPObject *obj = objVec[i]; + for (auto obj : objVec) { getDesktop()->selection->add(obj); } } @@ -1292,13 +1291,11 @@ void StyleDialog::_selectRow() SPObject *obj = selection->objects().back(); Gtk::TreeModel::Children children = _store->children(); - for(Gtk::TreeModel::Children::iterator iter = children.begin(); - iter != children.end(); ++iter) { + for(auto row : children) { - Gtk::TreeModel::Row row = *iter; std::vector<SPObject *> objVec = row[_mColumns._colObj]; - for (unsigned i = 0; i < objVec.size(); ++i) { - if (obj->getId() == objVec[i]->getId()) { + for (auto & i : objVec) { + if (obj->getId() == i->getId()) { _treeView.get_selection()->select(row); _updateCSSPanel(); return; diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index fabbf720b..7884e39f0 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -317,8 +317,8 @@ bool colorItemHandleButtonPress(GdkEventButton* event, UI::Widget::Preview *prev if ( user_data ) { ColorItem* item = reinterpret_cast<ColorItem*>(user_data); bool show = swp && (swp->getSelectedIndex() == 0); - for ( std::vector<GtkWidget*>::iterator it = popupExtras.begin(); it != popupExtras.end(); ++ it) { - gtk_widget_set_sensitive(*it, show); + for (auto & popupExtra : popupExtras) { + gtk_widget_set_sensitive(popupExtra, show); } bounceTarget = item; @@ -625,9 +625,9 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) : first = docPalettes[nullptr]; } else { std::vector<SwatchPage*> pages = _getSwatchSets(); - for ( std::vector<SwatchPage*>::iterator iter = pages.begin(); iter != pages.end(); ++iter ) { - if ( (*iter)->_name == targetName ) { - first = *iter; + for (auto & page : pages) { + if ( page->_name == targetName ) { + first = page; break; } index++; @@ -649,8 +649,7 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) : int i = 0; std::vector<SwatchPage*> swatchSets = _getSwatchSets(); - for ( std::vector<SwatchPage*>::iterator it = swatchSets.begin(); it != swatchSets.end(); ++it) { - SwatchPage* curr = *it; + for (auto curr : swatchSets) { Gtk::RadioMenuItem* single = Gtk::manage(new Gtk::RadioMenuItem(groupOne, curr->_name)); if ( curr == first ) { hotItem = single; @@ -1076,15 +1075,13 @@ bool DocTrack::handleTimerCB() double now = timer->elapsed(); std::vector<DocTrack *> needCallback; - for (std::vector<DocTrack *>::iterator it = docTrackings.begin(); it != docTrackings.end(); ++it) { - DocTrack *track = *it; + for (auto track : docTrackings) { if ( track->updatePending && ( (now - track->lastGradientUpdate) >= DOC_UPDATE_THREASHOLD) ) { needCallback.push_back(track); } } - for (std::vector<DocTrack *>::iterator it = needCallback.begin(); it != needCallback.end(); ++it) { - DocTrack *track = *it; + for (auto track : needCallback) { if ( std::find(docTrackings.begin(), docTrackings.end(), track) != docTrackings.end() ) { // Just in case one gets deleted while we are looping // Note: calling handleDefsModified will call queueUpdateIfNeeded and thus update the time and flag. SwatchesPanel::handleDefsModified(track->doc); @@ -1097,8 +1094,7 @@ bool DocTrack::handleTimerCB() bool DocTrack::queueUpdateIfNeeded( SPDocument *doc ) { bool deferProcessing = false; - for (std::vector<DocTrack*>::iterator it = docTrackings.begin(); it != docTrackings.end(); ++it) { - DocTrack *track = *it; + for (auto track : docTrackings) { if ( track->doc == doc ) { double now = timer->elapsed(); double elapsed = now - track->lastGradientUpdate; @@ -1193,10 +1189,8 @@ static void recalcSwatchContents(SPDocument* doc, if ( !newList.empty() ) { std::reverse(newList.begin(), newList.end()); - for ( std::vector<SPGradient*>::iterator it = newList.begin(); it != newList.end(); ++it ) + for (auto grad : newList) { - SPGradient* grad = *it; - cairo_surface_t *preview = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, PREVIEW_PIXBUF_WIDTH, VBLOCK); cairo_t *ct = cairo_create(preview); @@ -1235,22 +1229,22 @@ void SwatchesPanel::handleGradientsChange(SPDocument *document) std::map<ColorItem*, SPGradient*> tmpGrads; recalcSwatchContents(document, tmpColors, tmpPrevs, tmpGrads); - for (std::map<ColorItem*, cairo_pattern_t*>::iterator it = tmpPrevs.begin(); it != tmpPrevs.end(); ++it) { - it->first->setPattern(it->second); - cairo_pattern_destroy(it->second); + for (auto & tmpPrev : tmpPrevs) { + tmpPrev.first->setPattern(tmpPrev.second); + cairo_pattern_destroy(tmpPrev.second); } - for (std::map<ColorItem*, SPGradient*>::iterator it = tmpGrads.begin(); it != tmpGrads.end(); ++it) { - it->first->setGradient(it->second); + for (auto & tmpGrad : tmpGrads) { + tmpGrad.first->setGradient(tmpGrad.second); } docPalette->_colors.swap(tmpColors); // Figure out which SwatchesPanel instances are affected and update them. - for (std::map<SwatchesPanel*, SPDocument*>::iterator it = docPerPanel.begin(); it != docPerPanel.end(); ++it) { - if (it->second == document) { - SwatchesPanel* swp = it->first; + for (auto & it : docPerPanel) { + if (it.second == document) { + SwatchesPanel* swp = it.first; std::vector<SwatchPage*> pages = swp->_getSwatchSets(); SwatchPage* curr = pages[swp->_currentIndex]; if (curr == docPalette) { @@ -1292,8 +1286,8 @@ void SwatchesPanel::handleDefsModified(SPDocument *document) } } - for (std::map<ColorItem*, cairo_pattern_t*>::iterator it = tmpPrevs.begin(); it != tmpPrevs.end(); ++it) { - cairo_pattern_destroy(it->second); + for (auto & tmpPrev : tmpPrevs) { + cairo_pattern_destroy(tmpPrev.second); } } } @@ -1385,8 +1379,8 @@ void SwatchesPanel::_updateFromSelection() } } - for ( boost::ptr_vector<ColorItem>::iterator it = docPalette->_colors.begin(); it != docPalette->_colors.end(); ++it ) { - ColorItem* item = &*it; + for (auto & _color : docPalette->_colors) { + ColorItem* item = &_color; bool isFill = (fillId == item->def.descr); bool isStroke = (strokeId == item->def.descr); item->setState( isFill, isStroke ); @@ -1406,8 +1400,8 @@ void SwatchesPanel::_rebuild() _holder->freezeUpdates(); // TODO restore once 'clear' works _holder->addPreview(_clear); _holder->addPreview(_remove); - for ( boost::ptr_vector<ColorItem>::iterator it = curr->_colors.begin(); it != curr->_colors.end(); ++it) { - _holder->addPreview(&*it); + for (auto & _color : curr->_colors) { + _holder->addPreview(&_color); } _holder->thawUpdates(); } diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index ec49a2317..fa76fc31a 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -393,8 +393,8 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : SymbolsDialog::~SymbolsDialog() { - for (std::vector<sigc::connection>::iterator it = instanceConns.begin(); it != instanceConns.end(); ++it) { - it->disconnect(); + for (auto & instanceConn : instanceConns) { + instanceConn.disconnect(); } idleconn.disconnect(); instanceConns.clear(); diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp index 4ed279444..67f196770 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -239,8 +239,7 @@ bool TagsPanel::_executeAction() { std::vector<SPObject *> todelete; _tree.get_selection()->selected_foreach_iter(sigc::bind<std::vector<SPObject *>*>(sigc::mem_fun(*this, &TagsPanel::_checkForDeleted), &todelete)); - for (std::vector<SPObject *>::iterator iter = todelete.begin(); iter != todelete.end(); ++iter) { - SPObject * obj = *iter; + for (auto obj : todelete) { if (obj && obj->parent && obj->getRepr() && obj->parent->getRepr()) { //obj->parent->getRepr()->removeChild(obj->getRepr()); obj->deleteObject(true, true); @@ -501,14 +500,14 @@ void TagsPanel::_checkTreeSelection() // } - for ( std::vector<Gtk::Widget*>::iterator it = _watching.begin(); it != _watching.end(); ++it ) { - (*it)->set_sensitive( sensitive ); + for (auto & it : _watching) { + it->set_sensitive( sensitive ); } - for ( std::vector<Gtk::Widget*>::iterator it = _watchingNonTop.begin(); it != _watchingNonTop.end(); ++it ) { - (*it)->set_sensitive( sensitiveNonTop ); + for (auto & it : _watchingNonTop) { + it->set_sensitive( sensitiveNonTop ); } - for ( std::vector<Gtk::Widget*>::iterator it = _watchingNonBottom.begin(); it != _watchingNonBottom.end(); ++it ) { - (*it)->set_sensitive( sensitiveNonBottom ); + for (auto & it : _watchingNonBottom) { + it->set_sensitive( sensitiveNonBottom ); } } @@ -537,8 +536,7 @@ bool TagsPanel::_handleKeyEvent(GdkEventKey *event) std::vector<SPObject *> todelete; _tree.get_selection()->selected_foreach_iter(sigc::bind<std::vector<SPObject *>*>(sigc::mem_fun(*this, &TagsPanel::_checkForDeleted), &todelete)); if (!todelete.empty()) { - for (std::vector<SPObject *>::iterator iter = todelete.begin(); iter != todelete.end(); ++iter) { - SPObject * obj = *iter; + for (auto obj : todelete) { if (obj && obj->parent && obj->getRepr() && obj->parent->getRepr()) { //obj->parent->getRepr()->removeChild(obj->getRepr()); obj->deleteObject(true, true); @@ -652,8 +650,7 @@ bool TagsPanel::_handleButtonEvent(GdkEventButton* event) // FIXME unnecessary use of XML tree _tree.get_selection()->selected_foreach_iter(sigc::bind<std::vector<SPObject *>*>(sigc::mem_fun(*this, &TagsPanel::_checkForDeleted), &todelete)); if (!todelete.empty()) { - for (std::vector<SPObject *>::iterator iter = todelete.begin(); iter != todelete.end(); ++iter) { - SPObject * tobj = *iter; + for (auto tobj : todelete) { if (tobj && tobj->parent && tobj->getRepr() && tobj->parent->getRepr()) { //tobj->parent->getRepr()->removeChild(tobj->getRepr()); tobj->deleteObject(true, true); @@ -788,9 +785,8 @@ bool TagsPanel::_handleDragDrop(const Glib::RefPtr<Gdk::DragContext>& /*context* void TagsPanel::_doTreeMove( ) { if (_dnd_target) { - for (std::vector<SPTag *>::iterator iter = _dnd_source.begin(); iter != _dnd_source.end(); ++iter) + for (auto src : _dnd_source) { - SPTag *src = *iter; if (src != _dnd_target) { src->moveTo(_dnd_target, _dnd_into); } @@ -1009,14 +1005,14 @@ TagsPanel::TagsPanel() : - for ( std::vector<Gtk::Widget*>::iterator it = _watching.begin(); it != _watching.end(); ++it ) { - (*it)->set_sensitive( false ); + for (auto & it : _watching) { + it->set_sensitive( false ); } - for ( std::vector<Gtk::Widget*>::iterator it = _watchingNonTop.begin(); it != _watchingNonTop.end(); ++it ) { - (*it)->set_sensitive( false ); + for (auto & it : _watchingNonTop) { + it->set_sensitive( false ); } - for ( std::vector<Gtk::Widget*>::iterator it = _watchingNonBottom.begin(); it != _watchingNonBottom.end(); ++it ) { - (*it)->set_sensitive( false ); + for (auto & it : _watchingNonBottom) { + it->set_sensitive( false ); } setDesktop( targetDesktop ); diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index c4b5b5254..ed38c27cd 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -99,8 +99,8 @@ void TemplateLoadTab::_initKeywordsList() { _keywords_combo.append(_("All")); - for (std::set<Glib::ustring>::iterator it = _keywords.begin() ; it != _keywords.end() ; ++it){ - _keywords_combo.append(*it); + for (const auto & _keyword : _keywords){ + _keywords_combo.append(_keyword); } } @@ -147,36 +147,36 @@ void TemplateLoadTab::_refreshTemplatesList() switch (_current_search_type){ case ALL :{ - for (std::map<Glib::ustring, TemplateData>::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) { + for (auto & it : _tdata) { Gtk::TreeModel::iterator iter = _tlist_store->append(); Gtk::TreeModel::Row row = *iter; - row[_columns.textValue] = it->first; + row[_columns.textValue] = it.first; } break; } case LIST_KEYWORD: { - for (std::map<Glib::ustring, TemplateData>::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) { - if (it->second.keywords.count(_current_keyword.lowercase()) != 0){ + for (auto & it : _tdata) { + if (it.second.keywords.count(_current_keyword.lowercase()) != 0){ Gtk::TreeModel::iterator iter = _tlist_store->append(); Gtk::TreeModel::Row row = *iter; - row[_columns.textValue] = it->first; + row[_columns.textValue] = it.first; } } break; } case USER_SPECIFIED : { - for (std::map<Glib::ustring, TemplateData>::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) { - if (it->second.keywords.count(_current_keyword.lowercase()) != 0 || - it->second.display_name.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos || - it->second.author.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos || - it->second.short_description.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos || - it->second.long_description.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos ) + for (auto & it : _tdata) { + if (it.second.keywords.count(_current_keyword.lowercase()) != 0 || + it.second.display_name.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos || + it.second.author.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos || + it.second.short_description.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos || + it.second.long_description.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos ) { Gtk::TreeModel::iterator iter = _tlist_store->append(); Gtk::TreeModel::Row row = *iter; - row[_columns.textValue] = it->first; + row[_columns.textValue] = it.first; } } break; diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 532ac2cdb..be94b79c0 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -128,8 +128,8 @@ void TemplateWidget::_displayTemplateDetails() message += _("Description: ") + _current_template.long_description + "\n\n"; if (!_current_template.keywords.empty()){ message += _("Keywords: "); - for (std::set<Glib::ustring>::iterator it = _current_template.keywords.begin(); it != _current_template.keywords.end(); ++it) - message += *it + " "; + for (const auto & keyword : _current_template.keywords) + message += keyword + " "; message += "\n\n"; } diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 7edacc4ce..50631a16b 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -655,12 +655,9 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) if (fabs(x) > 1e-6) { std::vector< BBoxSort > sorted; - for (std::vector<SPItem*>::iterator it(selected.begin()); - it != selected.end(); - ++it) + for (auto item : selected) { - SPItem* item = *it; - Geom::OptRect bbox = item->desktopPreferredBounds(); + Geom::OptRect bbox = item->desktopPreferredBounds(); if (bbox) { sorted.emplace_back(item, *bbox, Geom::X, x > 0? 1. : 0., x > 0? 0. : 1.); } @@ -680,12 +677,9 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) } if (fabs(y) > 1e-6) { std::vector< BBoxSort > sorted; - for (std::vector<SPItem*>::iterator it(selected.begin()); - it != selected.end(); - ++it) + for (auto item : selected) { - SPItem* item = *it; - Geom::OptRect bbox = item->desktopPreferredBounds(); + Geom::OptRect bbox = item->desktopPreferredBounds(); if (bbox) { sorted.emplace_back(item, *bbox, Geom::Y, y > 0? 1. : 0., y > 0? 0. : 1.); } diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 0ca0f0ec6..61398a788 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -209,8 +209,8 @@ sp_create_window(SPViewWidget *vw, bool editable) } int pos = nui_drop_target_entries; - for (std::vector<Glib::ustring>::iterator it = types.begin() ; it != types.end() ; ++it) { - completeDropTargets[pos].target = g_strdup((*it).c_str()); + for (auto & type : types) { + completeDropTargets[pos].target = g_strdup(type.c_str()); completeDropTargets[pos].flags = 0; completeDropTargets[pos].info = IMAGE_DATA; pos++; diff --git a/src/ui/tool/control-point-selection.cpp b/src/ui/tool/control-point-selection.cpp index 915ed2a78..fc069e5bf 100644 --- a/src/ui/tool/control-point-selection.cpp +++ b/src/ui/tool/control-point-selection.cpp @@ -136,8 +136,8 @@ void ControlPointSelection::clear() /** Select all points that this selection can contain. */ void ControlPointSelection::selectAll() { - for (set_type::iterator i = _all_points.begin(); i != _all_points.end(); ++i) { - insert(*i, false); + for (auto _all_point : _all_points) { + insert(_all_point, false); } std::vector<SelectableControlPoint *> out(_all_points.begin(), _all_points.end()); if (!out.empty()) @@ -147,10 +147,10 @@ void ControlPointSelection::selectAll() void ControlPointSelection::selectArea(Geom::Rect const &r) { std::vector<SelectableControlPoint *> out; - for (set_type::iterator i = _all_points.begin(); i != _all_points.end(); ++i) { - if (r.contains(**i)) { - insert(*i, false); - out.push_back(*i); + for (auto _all_point : _all_points) { + if (r.contains(*_all_point)) { + insert(_all_point, false); + out.push_back(_all_point); } } if (!out.empty()) @@ -160,14 +160,14 @@ void ControlPointSelection::selectArea(Geom::Rect const &r) void ControlPointSelection::invertSelection() { std::vector<SelectableControlPoint *> in, out; - for (set_type::iterator i = _all_points.begin(); i != _all_points.end(); ++i) { - if ((*i)->selected()) { - in.push_back(*i); - erase(*i); + for (auto _all_point : _all_points) { + if (_all_point->selected()) { + in.push_back(_all_point); + erase(_all_point); } else { - out.push_back(*i); - insert(*i, false); + out.push_back(_all_point); + insert(_all_point, false); } } if (!in.empty()) @@ -181,21 +181,21 @@ void ControlPointSelection::spatialGrow(SelectableControlPoint *origin, int dir) Geom::Point p = origin->position(); double best_dist = grow ? HUGE_VAL : 0; SelectableControlPoint *match = nullptr; - for (set_type::iterator i = _all_points.begin(); i != _all_points.end(); ++i) { - bool selected = (*i)->selected(); + for (auto _all_point : _all_points) { + bool selected = _all_point->selected(); if (grow && !selected) { - double dist = Geom::distance((*i)->position(), p); + double dist = Geom::distance(_all_point->position(), p); if (dist < best_dist) { best_dist = dist; - match = *i; + match = _all_point; } } if (!grow && selected) { - double dist = Geom::distance((*i)->position(), p); + double dist = Geom::distance(_all_point->position(), p); // use >= to also deselect the origin node when it's the last one selected if (dist >= best_dist) { best_dist = dist; - match = *i; + match = _all_point; } } } @@ -209,8 +209,7 @@ void ControlPointSelection::spatialGrow(SelectableControlPoint *origin, int dir) /** Transform all selected control points by the given affine transformation. */ void ControlPointSelection::transform(Geom::Affine const &m) { - for (iterator i = _points.begin(); i != _points.end(); ++i) { - SelectableControlPoint *cur = *i; + for (auto cur : _points) { cur->transform(m); } _updateBounds(); @@ -230,8 +229,8 @@ void ControlPointSelection::align(Geom::Dim2 axis) Geom::OptInterval bound; - for (iterator i = _points.begin(); i != _points.end(); ++i) { - bound.unionWith(Geom::OptInterval((*i)->position()[d])); + for (auto _point : _points) { + bound.unionWith(Geom::OptInterval(_point->position()[d])); } if (!bound) { return; } @@ -257,10 +256,10 @@ void ControlPointSelection::align(Geom::Dim2 axis) return; } - for (iterator i = _points.begin(); i != _points.end(); ++i) { - Geom::Point pos = (*i)->position(); + for (auto _point : _points) { + Geom::Point pos = _point->position(); pos[d] = new_coord; - (*i)->move(pos); + _point->move(pos); } } @@ -276,9 +275,9 @@ void ControlPointSelection::distribute(Geom::Dim2 d) Geom::OptInterval bound; // first we insert all points into a multimap keyed by the aligned coord to sort them // simultaneously we compute the extent of selection - for (iterator i = _points.begin(); i != _points.end(); ++i) { - Geom::Point pos = (*i)->position(); - sm.insert(std::make_pair(pos[d], (*i))); + for (auto _point : _points) { + Geom::Point pos = _point->position(); + sm.insert(std::make_pair(pos[d], _point)); bound.unionWith(Geom::OptInterval(pos[d])); } @@ -345,13 +344,13 @@ void ControlPointSelection::_pointGrabbed(SelectableControlPoint *point) double maxdist = 0; Geom::Affine m; m.setIdentity(); - for (iterator i = _points.begin(); i != _points.end(); ++i) { - _original_positions.insert(std::make_pair(*i, (*i)->position())); - _last_trans.insert(std::make_pair(*i, m)); - double dist = Geom::distance(*_grabbed_point, **i); + for (auto _point : _points) { + _original_positions.insert(std::make_pair(_point, _point->position())); + _last_trans.insert(std::make_pair(_point, m)); + double dist = Geom::distance(*_grabbed_point, *_point); if (dist > maxdist) { maxdist = dist; - _farthest_point = *i; + _farthest_point = _point; } } } @@ -362,8 +361,7 @@ void ControlPointSelection::_pointDragged(Geom::Point &new_pos, GdkEventMotion * double fdist = Geom::distance(_original_positions[_grabbed_point], _original_positions[_farthest_point]); if (held_only_alt(*event) && fdist > 0) { // Sculpting - for (iterator i = _points.begin(); i != _points.end(); ++i) { - SelectableControlPoint *cur = (*i); + for (auto cur : _points) { Geom::Affine trans; trans.setIdentity(); double dist = Geom::distance(_original_positions[cur], _original_positions[_grabbed_point]); @@ -410,8 +408,7 @@ void ControlPointSelection::_pointDragged(Geom::Point &new_pos, GdkEventMotion * } } else { Geom::Point delta = new_pos - _grabbed_point->position(); - for (iterator i = _points.begin(); i != _points.end(); ++i) { - SelectableControlPoint *cur = (*i); + for (auto cur : _points) { cur->move(_original_positions[cur] + abs_delta); } _handles->rotationCenter().move(_handles->rotationCenter().position() + delta); @@ -461,8 +458,7 @@ void ControlPointSelection::_updateBounds() { _rot_radius = boost::none; _bounds = Geom::OptRect(); - for (iterator i = _points.begin(); i != _points.end(); ++i) { - SelectableControlPoint *cur = (*i); + for (auto cur : _points) { Geom::Point p = cur->position(); if (!_bounds) { _bounds = Geom::Rect(p, p); @@ -719,8 +715,8 @@ bool ControlPointSelection::event(Inkscape::UI::Tools::ToolBase * /*event_contex void ControlPointSelection::getOriginalPoints(std::vector<Inkscape::SnapCandidatePoint> &pts) { pts.clear(); - for (iterator i = _points.begin(); i != _points.end(); ++i) { - pts.emplace_back(_original_positions[*i], SNAPSOURCE_NODE_HANDLE); + for (auto _point : _points) { + pts.emplace_back(_original_positions[_point], SNAPSOURCE_NODE_HANDLE); } } @@ -728,9 +724,9 @@ void ControlPointSelection::getUnselectedPoints(std::vector<Inkscape::SnapCandid { pts.clear(); ControlPointSelection::Set &nodes = this->allPoints(); - for (ControlPointSelection::Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { - if (!(*i)->selected()) { - Node *n = static_cast<Node*>(*i); + for (auto node : nodes) { + if (!node->selected()) { + Node *n = static_cast<Node*>(node); pts.push_back(n->snapCandidatePoint()); } } @@ -739,8 +735,8 @@ void ControlPointSelection::getUnselectedPoints(std::vector<Inkscape::SnapCandid void ControlPointSelection::setOriginalPoints() { _original_positions.clear(); - for (iterator i = _points.begin(); i != _points.end(); ++i) { - _original_positions.insert(std::make_pair(*i, (*i)->position())); + for (auto _point : _points) { + _original_positions.insert(std::make_pair(_point, _point->position())); } } diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index b107ab359..08114ac03 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -58,8 +58,8 @@ void find_join_iterators(ControlPointSelection &sel, IterPairList &pairs) IterSet join_iters; // find all endnodes in selection - for (ControlPointSelection::iterator i = sel.begin(); i != sel.end(); ++i) { - Node *node = dynamic_cast<Node*>(*i); + for (auto i : sel) { + Node *node = dynamic_cast<Node*>(i); if (!node) continue; NodeList::iterator iter = NodeList::get_iterator(node); if (!iter.next() || !iter.prev()) join_iters.insert(iter); @@ -181,8 +181,7 @@ void MultiPathManipulator::setItems(std::set<ShapeRecord> const &s) } // add newly selected items - for (std::set<ShapeRecord>::iterator i = shapes.begin(); i != shapes.end(); ++i) { - ShapeRecord const &r = *i; + for (const auto & r : shapes) { if (!SP_IS_PATH(r.item) && !IS_LIVEPATHEFFECT(r.item)) continue; std::shared_ptr<PathManipulator> newpm(new PathManipulator(*this, (SPPath*) r.item, r.edit_transform, _getOutlineColor(r.role, r.item), r.lpe_key)); @@ -297,8 +296,8 @@ void MultiPathManipulator::setNodeType(NodeType type) // When all selected nodes are already cusp, retract their handles bool retract_handles = (type == NODE_CUSP); - for (ControlPointSelection::iterator i = _selection.begin(); i != _selection.end(); ++i) { - Node *node = dynamic_cast<Node*>(*i); + for (auto i : _selection) { + Node *node = dynamic_cast<Node*>(i); if (node) { retract_handles &= (node->type() == NODE_CUSP); node->setType(type); @@ -306,8 +305,8 @@ void MultiPathManipulator::setNodeType(NodeType type) } if (retract_handles) { - for (ControlPointSelection::iterator i = _selection.begin(); i != _selection.end(); ++i) { - Node *node = dynamic_cast<Node*>(*i); + for (auto i : _selection) { + Node *node = dynamic_cast<Node*>(i); if (node) { node->front()->retract(); node->back()->retract(); @@ -371,37 +370,37 @@ void MultiPathManipulator::joinNodes() } find_join_iterators(_selection, joins); - for (IterPairList::iterator i = joins.begin(); i != joins.end(); ++i) { - bool same_path = prepare_join(*i); - NodeList &sp_first = NodeList::get(i->first); - NodeList &sp_second = NodeList::get(i->second); - i->first->setType(NODE_CUSP, false); + for (auto & join : joins) { + bool same_path = prepare_join(join); + NodeList &sp_first = NodeList::get(join.first); + NodeList &sp_second = NodeList::get(join.second); + join.first->setType(NODE_CUSP, false); Geom::Point joined_pos, pos_handle_front, pos_handle_back; - pos_handle_front = *i->second->front(); - pos_handle_back = *i->first->back(); + pos_handle_front = *join.second->front(); + pos_handle_back = *join.first->back(); // When we encounter the mouseover node, we unset the iterator - it will be invalidated - if (i->first == preserve_pos) { - joined_pos = *i->first; + if (join.first == preserve_pos) { + joined_pos = *join.first; preserve_pos = NodeList::iterator(); - } else if (i->second == preserve_pos) { - joined_pos = *i->second; + } else if (join.second == preserve_pos) { + joined_pos = *join.second; preserve_pos = NodeList::iterator(); } else { - joined_pos = Geom::middle_point(*i->first, *i->second); + joined_pos = Geom::middle_point(*join.first, *join.second); } // if the handles aren't degenerate, don't move them - i->first->move(joined_pos); - Node *joined_node = i->first.ptr(); - if (!i->second->front()->isDegenerate()) { + join.first->move(joined_pos); + Node *joined_node = join.first.ptr(); + if (!join.second->front()->isDegenerate()) { joined_node->front()->setPosition(pos_handle_front); } - if (!i->first->back()->isDegenerate()) { + if (!join.first->back()->isDegenerate()) { joined_node->back()->setPosition(pos_handle_back); } - sp_second.erase(i->second); + sp_second.erase(join.second); if (same_path) { sp_first.setClosed(true); @@ -409,7 +408,7 @@ void MultiPathManipulator::joinNodes() sp_first.splice(sp_first.end(), sp_second); sp_second.kill(); } - _selection.insert(i->first.ptr()); + _selection.insert(join.first.ptr()); } if (joins.empty()) { @@ -441,12 +440,12 @@ void MultiPathManipulator::joinSegments() IterPairList joins; find_join_iterators(_selection, joins); - for (IterPairList::iterator i = joins.begin(); i != joins.end(); ++i) { - bool same_path = prepare_join(*i); - NodeList &sp_first = NodeList::get(i->first); - NodeList &sp_second = NodeList::get(i->second); - i->first->setType(NODE_CUSP, false); - i->second->setType(NODE_CUSP, false); + for (auto & join : joins) { + bool same_path = prepare_join(join); + NodeList &sp_first = NodeList::get(join.first); + NodeList &sp_second = NodeList::get(join.second); + join.first->setType(NODE_CUSP, false); + join.second->setType(NODE_CUSP, false); if (same_path) { sp_first.setClosed(true); } else { @@ -510,9 +509,9 @@ void MultiPathManipulator::move(Geom::Point const &delta) void MultiPathManipulator::showOutline(bool show) { - for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) { + for (auto & i : _mmap) { // always show outlines for clipping paths and masks - i->second->showOutline(show || i->first.role != SHAPE_ROLE_NORMAL); + i.second->showOutline(show || i.first.role != SHAPE_ROLE_NORMAL); } _show_outline = show; } @@ -759,8 +758,8 @@ bool MultiPathManipulator::event(Inkscape::UI::Tools::ToolBase *event_context, G break; case GDK_MOTION_NOTIFY: combine_motion_events(_desktop->canvas, event->motion, 0); - for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) { - if (i->second->event(event_context, event)) return true; + for (auto & i : _mmap) { + if (i.second->event(event_context, event)) return true; } break; default: break; diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 4321963b9..78c359609 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -381,8 +381,8 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) //if the snap adjustment is activated and it is not bspline if (snap && !_pm()._isBSpline()) { ControlPointSelection::Set &nodes = _parent->_selection.allPoints(); - for (ControlPointSelection::Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { - Node *n = static_cast<Node*>(*i); + for (auto node : nodes) { + Node *n = static_cast<Node*>(node); unselected.push_back(n->snapCandidatePoint()); } sm.setupIgnoreSelection(_desktop, true, &unselected); @@ -1225,9 +1225,9 @@ void Node::dragged(Geom::Point &new_pos, GdkEventMotion *event) // Build the list of unselected nodes. typedef ControlPointSelection::Set Set; Set &nodes = _selection.allPoints(); - for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { - if (!(*i)->selected()) { - Node *n = static_cast<Node*>(*i); + for (auto node : nodes) { + if (!node->selected()) { + Node *n = static_cast<Node*>(node); Inkscape::SnapCandidatePoint p(n->position(), n->_snapSourceType(), n->_snapTargetType()); unselected.push_back(p); } diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index a2390f3a9..83c177297 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -220,8 +220,8 @@ void PathManipulator::clear() /** Select all nodes in subpaths that have something selected. */ void PathManipulator::selectSubpaths() { - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - NodeList::iterator sp_start = (*i)->begin(), sp_end = (*i)->end(); + for (auto & _subpath : _subpaths) { + NodeList::iterator sp_start = _subpath->begin(), sp_end = _subpath->end(); for (NodeList::iterator j = sp_start; j != sp_end; ++j) { if (j->selected()) { // if at least one of the nodes from this subpath is selected, @@ -237,11 +237,11 @@ void PathManipulator::selectSubpaths() /** Invert selection in the selected subpaths. */ void PathManipulator::invertSelectionInSubpaths() { - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { if (j->selected()) { // found selected node - invert selection in this subpath - for (NodeList::iterator k = (*i)->begin(); k != (*i)->end(); ++k) { + for (NodeList::iterator k = _subpath->begin(); k != _subpath->end(); ++k) { if (k->selected()) _selection.erase(k.ptr()); else _selection.insert(k.ptr()); } @@ -257,8 +257,8 @@ void PathManipulator::insertNodes() { if (_num_selected < 2) return; - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { NodeList::iterator k = j.next(); if (k && j->selected() && k->selected()) { j = subdivideSegment(j, 0.5); @@ -312,11 +312,11 @@ void PathManipulator::insertNodeAtExtremum(ExtremumType extremum) double sign = (extremum == EXTR_MIN_X || extremum == EXTR_MIN_Y) ? -1. : 1.; Geom::Dim2 dim = (extremum == EXTR_MIN_X || extremum == EXTR_MAX_X) ? Geom::X : Geom::Y; - for (SubpathList::iterator subp = _subpaths.begin(); subp != _subpaths.end(); ++subp) { + for (auto & _subpath : _subpaths) { Geom::Coord extrvalue = - Geom::infinity(); std::vector< std::pair<NodeList::iterator, double> > extremum_vector; - for (NodeList::iterator first = (*subp)->begin(); first != (*subp)->end(); ++first) { + for (NodeList::iterator first = _subpath->begin(); first != _subpath->end(); ++first) { NodeList::iterator second = first.next(); if (second && first->selected() && second->selected()) { add_or_replace_if_extremum(extremum_vector, extrvalue, sign * first->position()[dim], first, 0.); @@ -331,19 +331,19 @@ void PathManipulator::insertNodeAtExtremum(ExtremumType extremum) // and determine extremum Geom::Bezier deriv1d = derivative(temp1d); std::vector<double> rs = deriv1d.roots(); - for (std::vector<double>::iterator it = rs.begin(); it != rs.end(); ++it) { - add_or_replace_if_extremum(extremum_vector, extrvalue, sign * temp1d.valueAt(*it), first, *it); + for (double & r : rs) { + add_or_replace_if_extremum(extremum_vector, extrvalue, sign * temp1d.valueAt(r), first, r); } } } } - for (unsigned i = 0; i < extremum_vector.size(); ++i) { + for (auto & i : extremum_vector) { // don't insert node at the start or end of a segment, i.e. round values for extr_t - double t = extremum_vector[i].second; + double t = i.second; if ( !Geom::are_near(t - std::floor(t+0.5),0.) ) // std::floor(t+0.5) is another way of writing round(t) { - _selection.insert( subdivideSegment(extremum_vector[i].first, t).ptr() ); + _selection.insert( subdivideSegment(i.first, t).ptr() ); } } } @@ -356,8 +356,8 @@ void PathManipulator::duplicateNodes() { if (_num_selected == 0) return; - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { if (j->selected()) { NodeList::iterator k = j.next(); Node *n = new Node(_multi_path_manipulator._path_data.node_data, *j); @@ -372,7 +372,7 @@ void PathManipulator::duplicateNodes() n->front()->setPosition(*j->front()); j->front()->retract(); j->setType(NODE_CUSP, false); - (*i)->insert(k, n); + _subpath->insert(k, n); if (k) { // We need to manually call the selection change callback to refresh @@ -399,11 +399,10 @@ void PathManipulator::weldNodes(NodeList::iterator preserve_pos) hideDragPoint(); bool pos_valid = preserve_pos; - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - SubpathPtr sp = *i; + for (auto sp : _subpaths) { unsigned num_selected = 0, num_unselected = 0; - for (NodeList::iterator j = sp->begin(); j != sp->end(); ++j) { - if (j->selected()) ++num_selected; + for (auto & j : *sp) { + if (j.selected()) ++num_selected; else ++num_unselected; } if (num_selected < 2) continue; @@ -474,11 +473,10 @@ void PathManipulator::weldSegments() if (_num_selected < 2) return; hideDragPoint(); - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - SubpathPtr sp = *i; + for (auto sp : _subpaths) { unsigned num_selected = 0, num_unselected = 0; - for (NodeList::iterator j = sp->begin(); j != sp->end(); ++j) { - if (j->selected()) ++num_selected; + for (auto & j : *sp) { + if (j.selected()) ++num_selected; else ++num_unselected; } @@ -588,8 +586,8 @@ void PathManipulator::deleteNodes(bool keep_shape) // If there are less than 2 unselected nodes in an open subpath or no unselected nodes // in a closed one, delete entire subpath. unsigned num_unselected = 0, num_selected = 0; - for (NodeList::iterator j = sp->begin(); j != sp->end(); ++j) { - if (j->selected()) ++num_selected; + for (auto & j : *sp) { + if (j.selected()) ++num_selected; else ++num_unselected; } if (num_selected == 0) { @@ -709,8 +707,8 @@ void PathManipulator::deleteSegments() SubpathPtr sp = *i; bool has_unselected = false; unsigned num_selected = 0; - for (NodeList::iterator j = sp->begin(); j != sp->end(); ++j) { - if (j->selected()) { + for (auto & j : *sp) { + if (j.selected()) { ++num_selected; } else { has_unselected = true; @@ -779,16 +777,16 @@ void PathManipulator::deleteSegments() * will be reversed. Otherwise all subpaths will be reversed. */ void PathManipulator::reverseSubpaths(bool selected_only) { - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { + for (auto & _subpath : _subpaths) { if (selected_only) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { if (j->selected()) { - (*i)->reverse(); + _subpath->reverse(); break; // continue with the next subpath } } } else { - (*i)->reverse(); + _subpath->reverse(); } } } @@ -797,8 +795,8 @@ void PathManipulator::reverseSubpaths(bool selected_only) void PathManipulator::setSegmentType(SegmentType type) { if (_num_selected == 0) return; - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { NodeList::iterator k = j.next(); if (!(k && j->selected() && k->selected())) continue; switch (type) { @@ -908,8 +906,8 @@ void PathManipulator::showHandles(bool show) { if (show == _show_handles) return; if (show) { - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { if (!j->selected()) continue; j->showHandles(true); if (j.prev()) j.prev()->showHandles(true); @@ -917,8 +915,8 @@ void PathManipulator::showHandles(bool show) } } } else { - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { j->showHandles(false); } } @@ -953,8 +951,8 @@ void PathManipulator::setLiveObjects(bool set) void PathManipulator::updateHandles() { - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { j->updateHandles(); } } @@ -964,8 +962,8 @@ void PathManipulator::setControlsTransform(Geom::Affine const &tnew) { Geom::Affine delta = _i2d_transform.inverse() * _edit_transform.inverse() * tnew * _i2d_transform; _edit_transform = tnew; - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { j->transform(delta); } } @@ -1068,8 +1066,8 @@ NodeList::iterator PathManipulator::extremeNode(NodeList::iterator origin, bool double extr_dist = closest ? HUGE_VAL : -HUGE_VAL; if (_num_selected == 0 && !search_unselected) return match; - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { if(j->selected()) { if (!search_selected) continue; } else { @@ -1098,8 +1096,8 @@ void PathManipulator::_externalChange(unsigned type) // ugly: stored offsets of selected nodes in a vector // vector<bool> should be specialized so that it takes only 1 bit per value std::vector<bool> selpos; - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { selpos.push_back(j->selected()); } } @@ -1107,8 +1105,8 @@ void PathManipulator::_externalChange(unsigned type) _createControlPointsFromGeometry(); - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { if (curpos >= size) goto end_restore; if (selpos[curpos]) _selection.insert(j.ptr()); ++curpos; @@ -1123,8 +1121,8 @@ void PathManipulator::_externalChange(unsigned type) _i2d_transform = _path->i2dt_affine(); _d2i_transform = _i2d_transform.inverse(); i2d_change *= _i2d_transform; - for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { j->transform(i2d_change); } } @@ -1160,22 +1158,22 @@ void PathManipulator::_createControlPointsFromGeometry() pathv *= (_edit_transform * _i2d_transform); // in this loop, we know that there are no zero-segment subpaths - for (Geom::PathVector::iterator pit = pathv.begin(); pit != pathv.end(); ++pit) { + for (auto & pit : pathv) { // prepare new subpath SubpathPtr subpath(new NodeList(_subpaths)); _subpaths.push_back(subpath); - Node *previous_node = new Node(_multi_path_manipulator._path_data.node_data, pit->initialPoint()); + Node *previous_node = new Node(_multi_path_manipulator._path_data.node_data, pit.initialPoint()); subpath->push_back(previous_node); - bool closed = pit->closed(); + bool closed = pit.closed(); - for (Geom::Path::iterator cit = pit->begin(); cit != pit->end(); ++cit) { + for (Geom::Path::iterator cit = pit.begin(); cit != pit.end(); ++cit) { Geom::Point pos = cit->finalPoint(); Node *current_node; // if the closing segment is degenerate and the path is closed, we need to move // the handle of the first node instead of creating a new one - if (closed && cit == --(pit->end())) { + if (closed && cit == --(pit.end())) { current_node = subpath->begin().get_pointer(); } else { /* regardless of segment type, create a new node at the end @@ -1197,7 +1195,7 @@ void PathManipulator::_createControlPointsFromGeometry() previous_node = current_node; } // If the path is closed, make the list cyclic - if (pit->closed()) subpath->setClosed(true); + if (pit.closed()) subpath->setClosed(true); } // we need to set the nodetypes after all the handles are in place, @@ -1224,14 +1222,14 @@ void PathManipulator::_createControlPointsFromGeometry() nodetype_string.append(nodetype_len - nodetype_string.size(), 'b'); } std::string::iterator tsi = nodetype_string.begin(); - for (std::list<SubpathPtr>::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { j->setType(Node::parse_nodetype(*tsi++), false); } - if ((*i)->closed()) { + if (_subpath->closed()) { // STUPIDITY ALERT: it seems we need to use the duplicate type symbol instead of // the first one to remain backward compatible. - (*i)->begin()->setType(Node::parse_nodetype(*tsi++), false); + _subpath->begin()->setType(Node::parse_nodetype(*tsi++), false); } } } @@ -1419,12 +1417,12 @@ std::string PathManipulator::_createTypeString() { // precondition: no single-node subpaths std::stringstream tstr; - for (std::list<SubpathPtr>::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { tstr << j->type(); } // nodestring format peculiarity: first node is counted twice for closed paths - if ((*i)->closed()) tstr << (*i)->begin()->type(); + if (_subpath->closed()) tstr << _subpath->begin()->type(); } return tstr.str(); } @@ -1448,8 +1446,7 @@ void PathManipulator::_updateOutline() // of little 'harpoons' that show the direction of the subpaths. auto rot_scale_w2d = Geom::Rotate(210.0 / 180.0 * M_PI) * Geom::Scale(10.0) * _desktop->w2d(); Geom::PathVector arrows; - for (Geom::PathVector::iterator i = pv.begin(); i != pv.end(); ++i) { - Geom::Path &path = *i; + for (auto & path : pv) { for (Geom::Path::iterator j = path.begin(); j != path.end_default(); ++j) { Geom::Point at = j->pointAt(0.5); Geom::Point ut = j->unitTangentAt(0.5); @@ -1600,8 +1597,8 @@ bool PathManipulator::_handleClicked(Handle *h, GdkEventButton *event) } void PathManipulator::_selectionChangedM(std::vector<SelectableControlPoint *> pvec, bool selected) { - for (size_t n = 0, e = pvec.size(); n < e; ++n) { - _selectionChanged(pvec[n], selected); + for (auto & n : pvec) { + _selectionChanged(n, selected); } } @@ -1650,8 +1647,8 @@ void PathManipulator::_selectionChanged(SelectableControlPoint *p, bool selected void PathManipulator::_removeNodesFromSelection() { // remove this manipulator's nodes from selection - for (std::list<SubpathPtr>::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { - for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + for (auto & _subpath : _subpaths) { + for (NodeList::iterator j = _subpath->begin(); j != _subpath->end(); ++j) { _selection.erase(j.get_pointer()); } } diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index 781675a99..c1d6692bc 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -154,8 +154,8 @@ bool TransformHandle::grabbed(GdkEventMotion *) _all_snap_sources_sorted = _snap_points; // Calculate and store the distance to the reference point for each snap candidate point - for(std::vector<Inkscape::SnapCandidatePoint>::iterator i = _all_snap_sources_sorted.begin(); i != _all_snap_sources_sorted.end(); ++i) { - (*i).setDistance(Geom::L2((*i).getPoint() - _origin)); + for(auto & i : _all_snap_sources_sorted) { + i.setDistance(Geom::L2(i.getPoint() - _origin)); } // Sort them ascending, using the distance calculated above as the single criteria @@ -724,8 +724,8 @@ TransformHandleSet::TransformHandleSet(SPDesktop *d, SPCanvasGroup *th_group) TransformHandleSet::~TransformHandleSet() { - for (unsigned i = 0; i < 17; ++i) { - delete _handles[i]; + for (auto & _handle : _handles) { + delete _handle; } } @@ -844,9 +844,9 @@ void TransformHandleSet::_updateVisibility(bool v) _center->setVisible(show_rotate /*&& bp[Geom::X] > handle_size[Geom::X] && bp[Geom::Y] > handle_size[Geom::Y]*/); } else { - for (unsigned i = 0; i < 17; ++i) { - if (_handles[i] != _active) - _handles[i]->setVisible(false); + for (auto & _handle : _handles) { + if (_handle != _active) + _handle->setVisible(false); } } diff --git a/src/ui/toolbar/calligraphy-toolbar.cpp b/src/ui/toolbar/calligraphy-toolbar.cpp index 85afa9872..2a9d7b0d9 100644 --- a/src/ui/toolbar/calligraphy-toolbar.cpp +++ b/src/ui/toolbar/calligraphy-toolbar.cpp @@ -74,8 +74,8 @@ void update_presets_list(GObject *tbl) bool match = true; std::vector<Inkscape::Preferences::Entry> preset = prefs->getAllEntries(*i); - for (std::vector<Inkscape::Preferences::Entry>::iterator j = preset.begin(); j != preset.end(); ++j) { - Glib::ustring entry_name = j->getEntryName(); + for (auto & j : preset) { + Glib::ustring entry_name = j.getEntryName(); if (entry_name == "id" || entry_name == "name") { continue; } @@ -83,7 +83,7 @@ void update_presets_list(GObject *tbl) void *widget = g_object_get_data(tbl, entry_name.data()); if (widget) { if (GTK_IS_ADJUSTMENT(widget)) { - double v = j->getDouble(); + double v = j.getDouble(); GtkAdjustment* adj = static_cast<GtkAdjustment *>(widget); //std::cout << "compared adj " << attr_name << gtk_adjustment_get_value(adj) << " to " << v << "\n"; if (fabs(gtk_adjustment_get_value(adj) - v) > 1e-6) { @@ -91,7 +91,7 @@ void update_presets_list(GObject *tbl) break; } } else if (GTK_IS_TOGGLE_ACTION(widget)) { - bool v = j->getBool(); + bool v = j.getBool(); GtkToggleAction* toggle = static_cast<GtkToggleAction *>(widget); //std::cout << "compared toggle " << attr_name << gtk_toggle_action_get_active(toggle) << " to " << v << "\n"; if ( static_cast<bool>(gtk_toggle_action_get_active(toggle)) != v ) { @@ -218,9 +218,9 @@ static void sp_dcc_build_presets_list(GObject *tbl) std::vector<Glib::ustring> presets = get_presets_list(); int ii=1; - for (std::vector<Glib::ustring>::iterator i = presets.begin(); i != presets.end(); ++i) { + for (auto & preset : presets) { GtkTreeIter iter; - Glib::ustring preset_name = prefs->getString(*i + "/name"); + Glib::ustring preset_name = prefs->getString(preset + "/name"); if (!preset_name.empty()) { row = *(store->append()); @@ -303,8 +303,7 @@ static void sp_dcc_save_profile(GtkWidget * /*widget*/, GObject *tbl) g_free(profile_id); } - for (unsigned i = 0; i < G_N_ELEMENTS(widget_names); ++i) { - gchar const *const widget_name = widget_names[i]; + for (auto widget_name : widget_names) { void *widget = g_object_get_data(tbl, widget_name); if (widget) { if (GTK_IS_ADJUSTMENT(widget)) { @@ -351,8 +350,8 @@ static void sp_ddc_change_profile(GObject* tbl, int mode) std::vector<Inkscape::Preferences::Entry> preset = prefs->getAllEntries(preset_path); // Shouldn't this be std::map? - for (std::vector<Inkscape::Preferences::Entry>::iterator i = preset.begin(); i != preset.end(); ++i) { - Glib::ustring entry_name = i->getEntryName(); + for (auto & i : preset) { + Glib::ustring entry_name = i.getEntryName(); if (entry_name == "id" || entry_name == "name") { continue; } @@ -360,11 +359,11 @@ static void sp_ddc_change_profile(GObject* tbl, int mode) if (widget) { if (GTK_IS_ADJUSTMENT(widget)) { GtkAdjustment* adj = static_cast<GtkAdjustment *>(widget); - gtk_adjustment_set_value(adj, i->getDouble()); + gtk_adjustment_set_value(adj, i.getDouble()); //std::cout << "set adj " << attr_name << " to " << v << "\n"; } else if (GTK_IS_TOGGLE_ACTION(widget)) { GtkToggleAction* toggle = static_cast<GtkToggleAction *>(widget); - gtk_toggle_action_set_active(toggle, i->getBool()); + gtk_toggle_action_set_active(toggle, i.getBool()); //std::cout << "set toggle " << attr_name << " to " << v << "\n"; } else { g_warning("Unknown widget type for preset: %s\n", entry_name.data()); diff --git a/src/ui/toolbar/gradient-toolbar.cpp b/src/ui/toolbar/gradient-toolbar.cpp index be23d9e98..cf14be7c3 100644 --- a/src/ui/toolbar/gradient-toolbar.cpp +++ b/src/ui/toolbar/gradient-toolbar.cpp @@ -608,14 +608,10 @@ static void select_stop_by_draggers(SPGradient *gradient, ToolBase *ev, GObject int selected = -1; // For all selected draggers - for(auto i = drag->selected.begin(); i != drag->selected.end(); ++i) { - - GrDragger *dragger = *i; + for(auto dragger : drag->selected) { // For all draggables of dragger - for(auto j = dragger->draggables.begin(); j != dragger->draggables.end(); ++j) { - - GrDraggable *draggable = *j; + for(auto draggable : dragger->draggables) { if (draggable->point_type != POINT_RG_FOCUS) { n++; diff --git a/src/ui/toolbar/mesh-toolbar.cpp b/src/ui/toolbar/mesh-toolbar.cpp index af0e1e5ea..6dad5a189 100644 --- a/src/ui/toolbar/mesh-toolbar.cpp +++ b/src/ui/toolbar/mesh-toolbar.cpp @@ -117,16 +117,16 @@ void ms_read_selection( Inkscape::Selection *selection, // Read desktop selection, taking into account fill/stroke toggles std::vector<SPMeshGradient *> meshes = ms_get_dt_selected_gradients( selection ); - for (auto i = meshes.begin(); i != meshes.end(); ++i) { + for (auto & meshe : meshes) { if (first) { - ms_selected = (*i); - ms_type = (*i)->type; + ms_selected = meshe; + ms_type = meshe->type; first = false; } else { - if (ms_selected != (*i)) { + if (ms_selected != meshe) { ms_selected_multi = true; } - if (ms_type != (*i)->type) { + if (ms_type != meshe->type) { ms_type_multi = true; } } @@ -261,10 +261,10 @@ static void ms_type_changed( GObject *tbl, int mode ) std::vector<SPMeshGradient *> meshes = ms_get_dt_selected_gradients(selection); SPMeshType type = (SPMeshType) mode; - for (auto i = meshes.begin(); i != meshes.end(); ++i) { - (*i)->type = type; - (*i)->type_set = true; - (*i)->updateRepr(); + for (auto & meshe : meshes) { + meshe->type = type; + meshe->type_set = true; + meshe->updateRepr(); } if (!meshes.empty() ) { DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH,_("Set mesh type")); diff --git a/src/ui/toolbar/paintbucket-toolbar.cpp b/src/ui/toolbar/paintbucket-toolbar.cpp index b23c9561a..81a240262 100644 --- a/src/ui/toolbar/paintbucket-toolbar.cpp +++ b/src/ui/toolbar/paintbucket-toolbar.cpp @@ -95,8 +95,7 @@ static void paintbucket_defaults(GtkWidget *, GObject *tbl) {"offset", 0.0} }; - for (unsigned i = 0; i < G_N_ELEMENTS(key_values); ++i) { - KeyValue const &kv = key_values[i]; + for (auto kv : key_values) { GtkAdjustment* adj = static_cast<GtkAdjustment *>(g_object_get_data(tbl, kv.key)); if ( adj ) { gtk_adjustment_set_value(adj, kv.value); diff --git a/src/ui/toolbar/pencil-toolbar.cpp b/src/ui/toolbar/pencil-toolbar.cpp index 8002969ee..52cc32637 100644 --- a/src/ui/toolbar/pencil-toolbar.cpp +++ b/src/ui/toolbar/pencil-toolbar.cpp @@ -442,8 +442,8 @@ static void sp_pencil_tb_tolerance_value_changed(GtkAdjustment *adj, GObject *tb guint curve_length = sp_shape->getCurve()->get_segment_count(); std::vector<Geom::Point> ts = lpe_powerstroke->offset_points.data(); double factor = (double)curve_length/ (double)previous_curve_length; - for (size_t i = 0; i < ts.size(); i++) { - ts[i][Geom::X] = ts[i][Geom::X] * factor; + for (auto & t : ts) { + t[Geom::X] = t[Geom::X] * factor; } lpe_powerstroke->offset_points.param_setValue(ts); } diff --git a/src/ui/toolbar/select-toolbar.cpp b/src/ui/toolbar/select-toolbar.cpp index 9da07b43d..0e1ad9c1b 100644 --- a/src/ui/toolbar/select-toolbar.cpp +++ b/src/ui/toolbar/select-toolbar.cpp @@ -84,15 +84,15 @@ sp_selection_layout_widget_update(SPWidget *spw, Inkscape::Selection *sel) if (unit->type == Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) { double const val = unit->factor * 100; - for (unsigned i = 0; i < G_N_ELEMENTS(keyval); ++i) { - GtkAdjustment *a = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(spw), keyval[i].key)); + for (auto i : keyval) { + GtkAdjustment *a = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(spw), i.key)); gtk_adjustment_set_value(a, val); - tracker->setFullVal( a, keyval[i].val ); + tracker->setFullVal( a, i.val ); } } else { - for (unsigned i = 0; i < G_N_ELEMENTS(keyval); ++i) { - GtkAdjustment *a = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(spw), keyval[i].key)); - gtk_adjustment_set_value(a, Quantity::convert(keyval[i].val, "px", unit)); + for (auto i : keyval) { + GtkAdjustment *a = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(spw), i.key)); + gtk_adjustment_set_value(a, Quantity::convert(i.val, "px", unit)); } } } @@ -123,10 +123,9 @@ sp_selection_layout_widget_change_selection(SPWidget *spw, Inkscape::Selection * gboolean setActive = (selection && !selection->isEmpty()); std::vector<GtkAction*> *contextActions = reinterpret_cast<std::vector<GtkAction*> *>(g_object_get_data(G_OBJECT(spw), "contextActions")); if ( contextActions ) { - for ( std::vector<GtkAction*>::iterator iter = contextActions->begin(); - iter != contextActions->end(); ++iter) { - if ( setActive != gtk_action_is_sensitive(*iter) ) { - gtk_action_set_sensitive( *iter, setActive ); + for (auto & contextAction : *contextActions) { + if ( setActive != gtk_action_is_sensitive(contextAction) ) { + gtk_action_set_sensitive( contextAction, setActive ); } } } @@ -536,10 +535,9 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb // Update now. sp_selection_layout_widget_update(SP_WIDGET(spw), SP_ACTIVE_DESKTOP ? SP_ACTIVE_DESKTOP->getSelection() : nullptr); - for ( std::vector<GtkAction*>::iterator iter = contextActions->begin(); - iter != contextActions->end(); ++iter) { - if ( gtk_action_is_sensitive(*iter) ) { - gtk_action_set_sensitive( *iter, FALSE ); + for (auto & contextAction : *contextActions) { + if ( gtk_action_is_sensitive(contextAction) ) { + gtk_action_set_sensitive( contextAction, FALSE ); } } diff --git a/src/ui/toolbar/text-toolbar.cpp b/src/ui/toolbar/text-toolbar.cpp index 341188fb2..fc3e8cd7d 100644 --- a/src/ui/toolbar/text-toolbar.cpp +++ b/src/ui/toolbar/text-toolbar.cpp @@ -1416,9 +1416,9 @@ static void sp_text_set_sizes(GtkListStore* model_size, int unit) // Array must be same length as SPCSSUnit in style.h float ratios[] = {1, 1, 1, 10, 4, 40, 100, 16, 8, 0.16}; - for( unsigned int i = 0; i < G_N_ELEMENTS(sizes); ++i ) { + for(int i : sizes) { GtkTreeIter iter; - Glib::ustring size = Glib::ustring::format(sizes[i] / (float)ratios[unit]); + Glib::ustring size = Glib::ustring::format(i / (float)ratios[unit]); gtk_list_store_append( model_size, &iter ); gtk_list_store_set( model_size, &iter, 0, size.c_str(), -1 ); } diff --git a/src/ui/toolbar/tweak-toolbar.cpp b/src/ui/toolbar/tweak-toolbar.cpp index 3b275601e..47a90910a 100644 --- a/src/ui/toolbar/tweak-toolbar.cpp +++ b/src/ui/toolbar/tweak-toolbar.cpp @@ -80,8 +80,8 @@ static void sp_tweak_mode_changed( GObject *tbl, int mode ) static gchar const* names[] = {"tweak_doh", "tweak_dos", "tweak_dol", "tweak_doo", "tweak_channels_label"}; bool flag = ((mode == Inkscape::UI::Tools::TWEAK_MODE_COLORPAINT) || (mode == Inkscape::UI::Tools::TWEAK_MODE_COLORJITTER)); - for (size_t i = 0; i < G_N_ELEMENTS(names); ++i) { - GtkAction *act = GTK_ACTION(g_object_get_data( tbl, names[i] )); + for (auto & name : names) { + GtkAction *act = GTK_ACTION(g_object_get_data( tbl, name )); if (act) { gtk_action_set_visible(act, flag); } diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index 95b13f92c..5a1654e2f 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -190,11 +190,11 @@ ConnectorTool::~ConnectorTool() { this->sel_changed_connection.disconnect(); - for (int i = 0; i < 2; ++i) { + for (auto & i : this->endpt_handle) { if (this->endpt_handle[1]) { //g_object_unref(this->endpt_handle[i]); - knot_unref(this->endpt_handle[i]); - this->endpt_handle[i] = nullptr; + knot_unref(i); + i = nullptr; } } @@ -313,8 +313,8 @@ static void cc_clear_active_knots(SPKnotList k) { // Hide the connection points if they exist. if (k.size()) { - for (SPKnotList::iterator it = k.begin(); it != k.end(); ++it) { - it->first->hide(); + for (auto & it : k) { + it.first->hide(); } } } @@ -335,9 +335,9 @@ void ConnectorTool::cc_clear_active_conn() } // Hide the endpoint handles. - for (int i = 0; i < 2; ++i) { - if (this->endpt_handle[i]) { - this->endpt_handle[i]->hide(); + for (auto & i : this->endpt_handle) { + if (i) { + i->hide(); } } } diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp index 37091ea01..6db530917 100644 --- a/src/ui/tools/flood-tool.cpp +++ b/src/ui/tools/flood-tool.cpp @@ -392,8 +392,7 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto Inkscape::Preferences *prefs = Inkscape::Preferences::get(); double offset = prefs->getDouble("/tools/paintbucket/offset", 0.0); - for (unsigned int i=0 ; i<results.size() ; i++) { - Inkscape::Trace::TracingEngineResult result = results[i]; + for (auto result : results) { totalNodeCount += result.getNodeCount(); Inkscape::XML::Node *pathRepr = xml_doc->createElement("svg:path"); diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index eee108bc0..f8c8517c9 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -383,16 +383,16 @@ MeasureTool::~MeasureTool() /* unref should call destroy */ knot_unref(this->knot_start); knot_unref(this->knot_end); - for (size_t idx = 0; idx < measure_tmp_items.size(); ++idx) { - sp_canvas_item_destroy(measure_tmp_items[idx]); + for (auto & measure_tmp_item : measure_tmp_items) { + sp_canvas_item_destroy(measure_tmp_item); } measure_tmp_items.clear(); - for (size_t idx = 0; idx < measure_item.size(); ++idx) { - sp_canvas_item_destroy(measure_item[idx]); + for (auto & idx : measure_item) { + sp_canvas_item_destroy(idx); } measure_item.clear(); - for (size_t idx = 0; idx < measure_phantom_items.size(); ++idx) { - sp_canvas_item_destroy(measure_phantom_items[idx]); + for (auto & measure_phantom_item : measure_phantom_items) { + sp_canvas_item_destroy(measure_phantom_item); } measure_phantom_items.clear(); } @@ -594,8 +594,8 @@ bool MeasureTool::root_handler(GdkEvent* event) } else { SPDesktop *desktop = SP_ACTIVE_DESKTOP; //Inkscape::Util::Unit const * unit = desktop->getNamedView()->getDisplayUnit(); - for (size_t idx = 0; idx < measure_item.size(); ++idx) { - sp_canvas_item_destroy(measure_item[idx]); + for (auto & idx : measure_item) { + sp_canvas_item_destroy(idx); } measure_item.clear(); ret = TRUE; @@ -757,12 +757,12 @@ void MeasureTool::toPhantom() return; } SPDocument *doc = desktop->getDocument(); - for (size_t idx = 0; idx < measure_phantom_items.size(); ++idx) { - sp_canvas_item_destroy(measure_phantom_items[idx]); + for (auto & measure_phantom_item : measure_phantom_items) { + sp_canvas_item_destroy(measure_phantom_item); } measure_phantom_items.clear(); - for (size_t idx = 0; idx < measure_tmp_items.size(); ++idx) { - sp_canvas_item_destroy(measure_tmp_items[idx]); + for (auto & measure_tmp_item : measure_tmp_items) { + sp_canvas_item_destroy(measure_tmp_item); } measure_tmp_items.clear(); showCanvasItems(false, false, true); @@ -1029,8 +1029,8 @@ void MeasureTool::reset() { this->knot_start->hide(); this->knot_end->hide(); - for (size_t idx = 0; idx < measure_tmp_items.size(); ++idx) { - sp_canvas_item_destroy(measure_tmp_items[idx]); + for (auto & measure_tmp_item : measure_tmp_items) { + sp_canvas_item_destroy(measure_tmp_item); } measure_tmp_items.clear(); } @@ -1148,8 +1148,8 @@ void MeasureTool::showInfoBox(Geom::Point cursor, bool into_groups) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; Inkscape::Util::Unit const * unit = desktop->getNamedView()->getDisplayUnit(); - for (size_t idx = 0; idx < measure_item.size(); ++idx) { - sp_canvas_item_destroy(measure_item[idx]); + for (auto & idx : measure_item) { + sp_canvas_item_destroy(idx); } measure_item.clear(); @@ -1247,8 +1247,8 @@ void MeasureTool::showCanvasItems(bool to_guides, bool to_item, bool to_phantom, writeMeasurePoint(start_p, true); writeMeasurePoint(end_p, false); //clear previous canvas items, we'll draw new ones - for (size_t idx = 0; idx < measure_tmp_items.size(); ++idx) { - sp_canvas_item_destroy(measure_tmp_items[idx]); + for (auto & measure_tmp_item : measure_tmp_items) { + sp_canvas_item_destroy(measure_tmp_item); } measure_tmp_items.clear(); //TODO:Calculate the measure area for current length and origin @@ -1334,8 +1334,8 @@ void MeasureTool::showCanvasItems(bool to_guides, bool to_item, bool to_phantom, std::vector<Geom::Point> intersections; std::sort(intersection_times.begin(), intersection_times.end()); - for (std::vector<double>::iterator iter_t = intersection_times.begin(); iter_t != intersection_times.end(); ++iter_t) { - intersections.push_back(lineseg[0].pointAt(*iter_t)); + for (double & intersection_time : intersection_times) { + intersections.push_back(lineseg[0].pointAt(intersection_time)); } if(!show_in_between && intersection_times.size() > 1) { @@ -1363,9 +1363,7 @@ void MeasureTool::showCanvasItems(bool to_guides, bool to_item, bool to_phantom, int precision = prefs->getInt("/tools/measure/precision", 2); // Adjust positions repositionOverlappingLabels(placements, desktop, windowNormal, fontsize, precision); - for (std::vector<LabelPlacement>::iterator it = placements.begin(); it != placements.end(); ++it) { - LabelPlacement &place = *it; - + for (auto & place : placements) { setMeasureCanvasText(false, precision, place.lengthVal * scale, fontsize, unit_name, place.end, 0x0000007f, TEXT_ANCHOR_CENTER, to_item, to_phantom, measure_repr); } Geom::Point angleDisplayPt = calcAngleDisplayAnchor(desktop, angle, baseAngle, @@ -1438,8 +1436,7 @@ void MeasureTool::showCanvasItems(bool to_guides, bool to_item, bool to_phantom, } // call-out lines - for (std::vector<LabelPlacement>::iterator it = placements.begin(); it != placements.end(); ++it) { - LabelPlacement &place = *it; + for (auto & place : placements) { setMeasureCanvasControlLine(place.start, place.end, to_item, to_phantom, CTLINE_SECONDARY, measure_repr); } diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 9dde149d9..a6faed5fa 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -316,8 +316,7 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) // Get list of selected draggers for each mesh. // For all selected draggers (a dragger may include draggerables from different meshes). - for (std::set<GrDragger *>::const_iterator i = drag->selected.begin(); i != drag->selected.end(); ++i) { - GrDragger *dragger = *i; + for (auto dragger : drag->selected) { // For all draggables of dragger (a draggable corresponds to a unique mesh). for (std::vector<GrDraggable *>::const_iterator j = dragger->draggables.begin(); j != dragger->draggables.end() ; ++j) { GrDraggable *d = *j; diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 99f5e4bcf..52632098f 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -302,8 +302,8 @@ void sp_update_helperpath() { Inkscape::UI::ControlPointSelection *selectionNodes = nt->_selected_nodes; std::vector<Geom::Point> selectedNodesPositions; - for (Inkscape::UI::ControlPointSelection::iterator i = selectionNodes->begin(); i != selectionNodes->end(); ++i) { - Inkscape::UI::Node *n = dynamic_cast<Inkscape::UI::Node *>(*i); + for (auto selectionNode : *selectionNodes) { + Inkscape::UI::Node *n = dynamic_cast<Inkscape::UI::Node *>(selectionNode); selectedNodesPositions.push_back(n->position()); } lpe->setSelectedNodePoints(selectedNodesPositions); @@ -311,8 +311,8 @@ void sp_update_helperpath() { SPCurve *c = new SPCurve(); SPCurve *cc = new SPCurve(); std::vector<Geom::PathVector> cs = lpe->getCanvasIndicators(SP_LPE_ITEM(selection->singleItem())); - for (std::vector<Geom::PathVector>::iterator p = cs.begin(); p != cs.end(); ++p) { - cc->set_pathvector(*p); + for (auto & p : cs) { + cc->set_pathvector(p); c->append(cc, false); cc->reset(); } @@ -441,9 +441,7 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) { } } - for (std::set<ShapeRecord>::iterator i = shapes.begin(); i != shapes.end(); ++i) { - ShapeRecord const &r = *i; - + for (const auto & r : shapes) { if ((SP_IS_SHAPE(r.item) || SP_IS_TEXT(r.item) || SP_IS_GROUP(r.item) || SP_IS_OBJECTGROUP(r.item)) && this->_shape_editors.find(r.item) == this->_shape_editors.end()) { @@ -674,9 +672,9 @@ void NodeTool::update_tip(GdkEvent *event) { // of a line going through them relative to the X axis. Inkscape::UI::ControlPointSelection::Set &selection_nodes = this->_selected_nodes->allPoints(); std::vector<Geom::Point> positions; - for (Inkscape::UI::ControlPointSelection::Set::iterator i = selection_nodes.begin(); i != selection_nodes.end(); ++i) { - if ((*i)->selected()) { - Inkscape::UI::Node *n = dynamic_cast<Inkscape::UI::Node *>(*i); + for (auto selection_node : selection_nodes) { + if (selection_node->selected()) { + Inkscape::UI::Node *n = dynamic_cast<Inkscape::UI::Node *>(selection_node); positions.push_back(n->position()); } } diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index 91dedd742..907b04a9a 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -584,8 +584,7 @@ static bool fit_item(SPDesktop *desktop, double bbox_top = bbox_down->top(); gchar const * item_down_sharp = g_strdup_printf("#%s", item_down->getId()); items_down_erased.push_back(item_down); - for (std::vector<SPItem*>::const_iterator j=items_selected.begin(); j!=items_selected.end(); ++j) { - SPItem *item_selected = *j; + for (auto item_selected : items_selected) { gchar const * spray_origin; if(!item_selected->getAttribute("inkscape:spray-origin")){ spray_origin = g_strdup_printf("#%s", item_selected->getId()); @@ -1143,14 +1142,12 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point { std::vector<SPItem*> const items(set->items().begin(), set->items().end()); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end(); ++i){ - SPItem *item = *i; + for(auto item : items){ g_assert(item != nullptr); sp_object_ref(item); } - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end(); ++i){ - SPItem *item = *i; + for(auto item : items){ g_assert(item != nullptr); if (sp_spray_recursive(desktop , set @@ -1193,8 +1190,7 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point } } - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end(); ++i){ - SPItem *item = *i; + for(auto item : items){ g_assert(item != nullptr); sp_object_unref(item); } diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index 4de0dc81f..f27f37300 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -244,10 +244,9 @@ void TextTool::finish() { this->frame = nullptr; } - for (std::vector<SPCanvasItem*>::iterator it = this->text_selection_quads.begin() ; - it != this->text_selection_quads.end() ; ++it) { - sp_canvas_item_hide(*it); - sp_canvas_item_destroy(*it); + for (auto & text_selection_quad : this->text_selection_quads) { + sp_canvas_item_hide(text_selection_quad); + sp_canvas_item_destroy(text_selection_quad); } this->text_selection_quads.clear(); @@ -1702,9 +1701,9 @@ static void sp_text_context_update_text_selection(TextTool *tc) // the selection update (can't do both atomically, alas) if (!tc->desktop) return; - for (std::vector<SPCanvasItem*>::iterator it = tc->text_selection_quads.begin() ; it != tc->text_selection_quads.end() ; ++it) { - sp_canvas_item_hide(*it); - sp_canvas_item_destroy(*it); + for (auto & text_selection_quad : tc->text_selection_quads) { + sp_canvas_item_hide(text_selection_quad); + sp_canvas_item_destroy(text_selection_quad); } tc->text_selection_quads.clear(); diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index cbc3dfd99..d8db9ceaf 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -1083,9 +1083,7 @@ sp_tweak_dilate (TweakTool *tc, Geom::Point event_p, Geom::Point p, Geom::Point // auto items= selection->items(); std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); - for(auto i=items.begin();i!=items.end(); ++i){ - SPItem *item = *i; - + for(auto item : items){ if (is_color_mode (tc->mode)) { if (do_fill || do_stroke || do_opacity) { if (sp_tweak_color_recursive (tc->mode, item, item_at_point, diff --git a/src/ui/uxmanager.cpp b/src/ui/uxmanager.cpp index 28f84dd63..8c52dafa0 100644 --- a/src/ui/uxmanager.cpp +++ b/src/ui/uxmanager.cpp @@ -151,9 +151,7 @@ gint UXManagerImpl::getDefaultTask( SPDesktop *desktop ) void UXManagerImpl::setTask(SPDesktop* dt, gint val) { - for (vector<SPDesktopWidget*>::iterator it = dtws.begin(); it != dtws.end(); ++it) { - SPDesktopWidget* dtw = *it; - + for (auto dtw : dtws) { gboolean notDone = Inkscape::Preferences::get()->getBool("/options/workarounds/dynamicnotdone", false); if (dtw->desktop == dt) { @@ -217,9 +215,7 @@ void UXManagerImpl::connectToDesktop( vector<GtkWidget *> const & toolboxes, SPD vector<GtkWidget*>& tracked = tracker.boxes; tracker.destroyConn = desktop->connectDestroy(&desktopDestructHandler); - for (vector<GtkWidget*>::const_iterator it = toolboxes.begin(); it != toolboxes.end(); ++it ) { - GtkWidget* toolbox = *it; - + for (auto toolbox : toolboxes) { ToolboxFactory::setToolboxDesktop( toolbox, desktop ); if (find(tracked.begin(), tracked.end(), toolbox) == tracked.end()) { tracked.push_back(toolbox); diff --git a/src/ui/widget/color-icc-selector.cpp b/src/ui/widget/color-icc-selector.cpp index 8d9f4a51c..f55dc5176 100644 --- a/src/ui/widget/color-icc-selector.cpp +++ b/src/ui/widget/color-icc-selector.cpp @@ -186,9 +186,9 @@ std::vector<colorspace::Component> colorspace::getColorSpaceInfo(uint32_t space) sets[cmsSigCmyData].push_back(Component(_("_M:"), _("Magenta"), 1)); sets[cmsSigCmyData].push_back(Component(_("_Y:"), _("Yellow"), 1)); - for (std::map<cmsUInt32Number, std::vector<Component> >::iterator it = sets.begin(); it != sets.end(); ++it) { - knownColorspaces.insert(it->first); - maxColorspaceComponentCount = std::max(maxColorspaceComponentCount, it->second.size()); + for (auto & set : sets) { + knownColorspaces.insert(set.first); + maxColorspaceComponentCount = std::max(maxColorspaceComponentCount, set.second.size()); } } @@ -806,10 +806,10 @@ void ColorICCSelectorImpl::_setProfile(SVGICCColor *profile) profChanged = true; } - for (size_t i = 0; i < _compUI.size(); i++) { - gtk_widget_hide(_compUI[i]._label); - _compUI[i]._slider->hide(); - gtk_widget_hide(_compUI[i]._btn); + for (auto & i : _compUI) { + gtk_widget_hide(i._label); + i._slider->hide(); + gtk_widget_hide(i._btn); } if (profile) { diff --git a/src/ui/widget/color-notebook.cpp b/src/ui/widget/color-notebook.cpp index 88573f137..f635b0665 100644 --- a/src/ui/widget/color-notebook.cpp +++ b/src/ui/widget/color-notebook.cpp @@ -289,8 +289,8 @@ void ColorNotebook::_updateICCButtons() if (prof && CMSSystem::isPrintColorSpace(prof)) { gtk_widget_show(GTK_WIDGET(_box_toomuchink)); double ink_sum = 0; - for (unsigned int i = 0; i < color.icc->colors.size(); i++) { - ink_sum += color.icc->colors[i]; + for (double i : color.icc->colors) { + ink_sum += i; } /* Some literature states that when the sum of paint values exceed 320%, it is considered to be a satured diff --git a/src/ui/widget/color-scales.cpp b/src/ui/widget/color-scales.cpp index e10b9f6a5..1229801d1 100644 --- a/src/ui/widget/color-scales.cpp +++ b/src/ui/widget/color-scales.cpp @@ -266,8 +266,8 @@ void ColorScales::setScaled(GtkAdjustment *a, gfloat v, bool constrained) void ColorScales::_setRangeLimit(gdouble upper) { _rangeLimit = upper; - for (gint i = 0; i < static_cast<gint>(G_N_ELEMENTS(_a)); i++) { - gtk_adjustment_set_upper(_a[i], upper); + for (auto & i : _a) { + gtk_adjustment_set_upper(i, upper); } } diff --git a/src/ui/widget/dash-selector.cpp b/src/ui/widget/dash-selector.cpp index 59149fb7c..81e7881b6 100644 --- a/src/ui/widget/dash-selector.cpp +++ b/src/ui/widget/dash-selector.cpp @@ -114,8 +114,8 @@ void DashSelector::init_dashes() { SPStyle style; dashes = g_new (double *, dash_prefs.size() + 2); // +1 for custom slot, +1 for terminator slot - for (std::vector<Glib::ustring>::iterator i = dash_prefs.begin(); i != dash_prefs.end(); ++i) { - style.readFromPrefs( *i ); + for (auto & dash_pref : dash_prefs) { + style.readFromPrefs( dash_pref ); if (!style.stroke_dasharray.values.empty()) { dashes[pos] = g_new (double, style.stroke_dasharray.values.size() + 1); diff --git a/src/ui/widget/font-selector.cpp b/src/ui/widget/font-selector.cpp index 5c1905752..207d508df 100644 --- a/src/ui/widget/font-selector.cpp +++ b/src/ui/widget/font-selector.cpp @@ -122,9 +122,9 @@ FontSelector::set_sizes () // PX PT PC MM CM IN EM EX % double ratios[] = {1, 1, 1, 10, 4, 40, 100, 16, 8, 0.16}; - for (unsigned int i = 0; i < G_N_ELEMENTS(sizes); ++i) + for (int i : sizes) { - double size = sizes[i]/ratios[unit]; + double size = i/ratios[unit]; size_combobox.append( Glib::ustring::format(size) ); } } diff --git a/src/ui/widget/ink-select-one-action.cpp b/src/ui/widget/ink-select-one-action.cpp index 7cff5f0be..95f38b511 100644 --- a/src/ui/widget/ink-select-one-action.cpp +++ b/src/ui/widget/ink-select-one-action.cpp @@ -105,9 +105,7 @@ Gtk::Widget* InkSelectOneAction::create_menu_item_vfunc() { Gtk::RadioButton::Group group; int index = 0; auto children = _store->children(); - for (auto iter = children.begin(); iter != children.end(); ++iter) { - Gtk::TreeModel::Row row = *iter; - + for (auto row : children) { InkSelectOneActionColumns columns; Glib::ustring label = row[columns.col_label ]; Glib::ustring icon = row[columns.col_icon ]; @@ -159,9 +157,7 @@ Gtk::Widget* InkSelectOneAction::create_tool_item_vfunc() { Gtk::RadioAction::Group group; int index = 0; auto children = _store->children(); - for (auto iter = children.begin(); iter != children.end(); ++iter) { - Gtk::TreeModel::Row row = *iter; - + for (auto row : children) { InkSelectOneActionColumns columns; Glib::ustring label = row[columns.col_label ]; Glib::ustring icon = row[columns.col_icon ]; @@ -217,8 +213,8 @@ Gtk::Widget* InkSelectOneAction::create_tool_item_vfunc() { } std::vector<Gtk::CellRenderer*> cells = _combobox->get_cells(); - for (auto iter = cells.begin(); iter!= cells.end(); ++iter) { - _combobox->add_attribute (**iter, "sensitive", columns.col_sensitive); + for (auto & cell : cells) { + _combobox->add_attribute (*cell, "sensitive", columns.col_sensitive); } _combobox->set_active (_active); diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 92c460c03..149b70f6f 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -1128,8 +1128,8 @@ void SelectedStyle::opacity_1() {_opacity_sb.set_value(100);} void SelectedStyle::on_opacity_menu (Gtk::Menu *menu) { Glib::ListHandle<Gtk::Widget *> children = menu->get_children(); - for (Glib::ListHandle<Gtk::Widget *>::iterator iter = children.begin(); iter != children.end(); ++iter) { - menu->remove(*(*iter)); + for (auto iter : children) { + menu->remove(*iter); } { diff --git a/src/ui/widget/unit-menu.cpp b/src/ui/widget/unit-menu.cpp index 7be848aac..938851265 100644 --- a/src/ui/widget/unit-menu.cpp +++ b/src/ui/widget/unit-menu.cpp @@ -30,8 +30,8 @@ bool UnitMenu::setUnitType(UnitType unit_type) // Expand the unit widget with unit entries from the unit table UnitTable::UnitMap m = unit_table.units(unit_type); - for (UnitTable::UnitMap::iterator i = m.begin(); i != m.end(); ++i) { - append(i->first); + for (auto & i : m) { + append(i.first); } _type = unit_type; set_active_text(unit_table.primary(unit_type)); diff --git a/src/ui/widget/unit-tracker.cpp b/src/ui/widget/unit-tracker.cpp index 9a4ff8268..4114ed378 100644 --- a/src/ui/widget/unit-tracker.cpp +++ b/src/ui/widget/unit-tracker.cpp @@ -45,9 +45,9 @@ UnitTracker::UnitTracker(UnitType unit_type) : _store = Gtk::ListStore::create(columns); Gtk::TreeModel::Row row; - for (UnitTable::UnitMap::iterator m_iter = m.begin(); m_iter != m.end(); ++m_iter) { + for (auto & m_iter : m) { - Glib::ustring unit = m_iter->first; + Glib::ustring unit = m_iter.first; row = *(_store->append()); row[columns.col_label ] = unit; |
