@@ -88,7 +88,7 @@ void MainTreeModel::insertLayer(int row) {
8888 QModelIndex parent = createIndex (TopLevelItem::LAYERS , 0 , ItemType::TOPLEVEL );
8989 beginInsertRows (parent, row, row);
9090
91- auto position = bow->section .layers .begin () + row;
91+ auto position = std::next ( bow->section .layers .begin (), row) ;
9292 bow->section .layers .insert (position, layer);
9393
9494 endInsertRows ();
@@ -120,7 +120,7 @@ void MainTreeModel::insertSegment(int row, SegmentType type) {
120120 QModelIndex parent = createIndex (TopLevelItem::PROFILE , 0 , ItemType::TOPLEVEL );
121121 beginInsertRows (parent, row, row);
122122
123- auto position = bow->profile .segments .begin () + row;
123+ auto position = std::next ( bow->profile .segments .begin (), row) ;
124124 bow->profile .segments .insert (position, createDefaultSegment (type));
125125
126126 endInsertRows ();
@@ -188,7 +188,7 @@ void MainTreeModel::removeLayer(int row) {
188188
189189 // Remove layer
190190 // Bow will become invalid when the last layer is removed
191- auto position = bow->section .layers .begin () + row;
191+ auto position = std::next ( bow->section .layers .begin (), row) ;
192192 bow->section .layers .erase (position);
193193
194194 endRemoveRows ();
@@ -204,7 +204,7 @@ void MainTreeModel::removeSegment(int row) {
204204
205205 // Remove segment
206206 // Bow will become invalis when the last segment is removed
207- auto position = bow->profile .segments .begin () + row;
207+ auto position = std::next ( bow->profile .segments .begin (), row) ;
208208 bow->profile .segments .erase (position);
209209
210210 endRemoveRows ();
@@ -348,7 +348,7 @@ void MainTreeModel::swapLayers(int i, int j) {
348348 beginMoveRows (parent, j, j, parent, i);
349349
350350 // Swap the two layers
351- std::swap (bow->section .layers [i], bow-> section . layers [j] );
351+ swapListNodes (bow->section .layers , i, j );
352352
353353 endMoveRows ();
354354}
@@ -363,7 +363,7 @@ void MainTreeModel::swapSegments(int i, int j) {
363363 beginMoveRows (parent, j, j, parent, i);
364364
365365 // Swap the two segments
366- std::swap (bow->profile .segments [i], bow-> profile . segments [j] );
366+ swapListNodes (bow->profile .segments , i, j );
367367
368368 endMoveRows ();
369369}
@@ -479,7 +479,7 @@ QVariant MainTreeModel::data(const QModelIndex &index, int role) const {
479479 }
480480
481481 if (index.parent ().row () == TopLevelItem::LAYERS ) {
482- auto & layer = bow->section .layers [ index.row ()] ;
482+ auto & layer = * std::next ( bow->section .layers . begin (), index.row ()) ;
483483 switch (role) {
484484 case Qt::DisplayRole: case Qt::EditRole: return QString::fromStdString (layer.name );
485485 case Qt::ToolTipRole: return " User-defined layer \" " + QString::fromStdString (layer.name ) + " \" " ;
@@ -535,7 +535,7 @@ bool MainTreeModel::setData(const QModelIndex &index, const QVariant &value, int
535535 return false ;
536536 }
537537
538- bow->section .layers [ index.row ()]. name = name;
538+ std::next ( bow->section .layers . begin (), index.row ())-> name = name;
539539 emit dataChanged (index, index);
540540 return true ;
541541 }
@@ -592,7 +592,7 @@ QIcon MainTreeModel::topLevelItemIcon(int row) const {
592592}
593593
594594QString MainTreeModel::segmentName (int row) const {
595- ProfileSegment segment = bow->profile .segments [ row] ;
595+ ProfileSegment& segment = * std::next ( bow->profile .segments . begin (), row) ;
596596
597597 if (std::holds_alternative<Line>(segment)) {
598598 return " Line" ;
@@ -611,7 +611,7 @@ QString MainTreeModel::segmentName(int row) const {
611611}
612612
613613QString MainTreeModel::segmentTooltip (int row) const {
614- ProfileSegment segment = bow->profile .segments [ row] ;
614+ ProfileSegment& segment = * std::next ( bow->profile .segments . begin (), row) ;
615615
616616 if (std::holds_alternative<Line>(segment)) {
617617 return " Line segment defined by a single length" ;
@@ -631,7 +631,7 @@ QString MainTreeModel::segmentTooltip(int row) const {
631631}
632632
633633QIcon MainTreeModel::segmentIcon (int row) const {
634- ProfileSegment segment = bow->profile .segments [ row] ;
634+ ProfileSegment& segment = * std::next ( bow->profile .segments . begin (), row) ;
635635
636636 if (std::holds_alternative<Line>(segment)) {
637637 return QIcon (" :/icons/segment-line.svg" );
0 commit comments