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/tools | |
| 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/tools')
| -rw-r--r-- | src/ui/tools/connector-tool.cpp | 16 | ||||
| -rw-r--r-- | src/ui/tools/flood-tool.cpp | 3 | ||||
| -rw-r--r-- | src/ui/tools/measure-tool.cpp | 47 | ||||
| -rw-r--r-- | src/ui/tools/mesh-tool.cpp | 3 | ||||
| -rw-r--r-- | src/ui/tools/node-tool.cpp | 18 | ||||
| -rw-r--r-- | src/ui/tools/spray-tool.cpp | 12 | ||||
| -rw-r--r-- | src/ui/tools/text-tool.cpp | 13 | ||||
| -rw-r--r-- | src/ui/tools/tweak-tool.cpp | 4 |
8 files changed, 51 insertions, 65 deletions
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, |
