diff options
Diffstat (limited to 'src/ui/dialog')
27 files changed, 254 insertions, 314 deletions
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.); } |
