diff --git a/sources/editor/elementscene.cpp b/sources/editor/elementscene.cpp index 8784f31c4..6104fab3f 100644 --- a/sources/editor/elementscene.cpp +++ b/sources/editor/elementscene.cpp @@ -1039,14 +1039,7 @@ QList ElementScene::zItems(bool include_terminals) const { } // ordonne les parties par leur zValue - QMultiMap mm; - foreach(QGraphicsItem *qgi, all_items_list) mm.insert(qgi -> zValue(), qgi); - all_items_list.clear(); - QMapIterator i(mm); - while (i.hasNext()) { - i.next(); - all_items_list << i.value(); - } + qSort(all_items_list.begin(), all_items_list.end(), ElementScene::zValueLessThan); // rajoute eventuellement les bornes if (include_terminals) all_items_list += terminals; @@ -1300,3 +1293,10 @@ void ElementScene::snapToGrid(QPointF &point) { bool ElementScene::mustSnapToGrid(QGraphicsSceneMouseEvent *e) { return(!(e -> modifiers() & Qt::ControlModifier)); } + +/** + @return true if \a item1's zValue() is less than \a item2's. +*/ +bool ElementScene::zValueLessThan(QGraphicsItem *item1, QGraphicsItem *item2) { + return(item1-> zValue() < item2 -> zValue()); +} diff --git a/sources/editor/elementscene.h b/sources/editor/elementscene.h index 659cffc39..9e8616756 100644 --- a/sources/editor/elementscene.h +++ b/sources/editor/elementscene.h @@ -159,6 +159,7 @@ class ElementScene : public QGraphicsScene { void initPasteArea(); void snapToGrid(QPointF &); bool mustSnapToGrid(QGraphicsSceneMouseEvent *); + static bool zValueLessThan(QGraphicsItem *, QGraphicsItem *); public slots: void slot_move();