diff --git a/sources/diagramcontent.cpp b/sources/diagramcontent.cpp index 8bb9983e4..7e68d2c2d 100644 --- a/sources/diagramcontent.cpp +++ b/sources/diagramcontent.cpp @@ -80,6 +80,25 @@ void DiagramContent::clear() { otherConductors.clear(); } +/** + * @brief DiagramContent::removeNonMovableItems + * Remove all non movable item. + * @return : return the numbers of removed item + */ +int DiagramContent::removeNonMovableItems() +{ + int count_ = 0; + + foreach(Element *elmt, elements) + if (!elmt->isMovable()) elements.remove(elmt); ++count_; + foreach(DiagramImageItem *img, images) + if (!img->isMovable()) images.remove(img); ++count_; + foreach (QetShapeItem *shape, shapes) + if (!shape->isMovable()) shapes.remove(shape); ++count_; + + return count_; +} + /** @param filter Types desires @return la liste des items formant le contenu du schema diff --git a/sources/diagramcontent.h b/sources/diagramcontent.h index 64a198199..ca63f9fef 100644 --- a/sources/diagramcontent.h +++ b/sources/diagramcontent.h @@ -78,6 +78,7 @@ class DiagramContent { QString sentence(int = All) const; int count(int = All) const; void clear(); + int removeNonMovableItems(); }; QDebug &operator<<(QDebug, DiagramContent &); #endif diff --git a/sources/elementsmover.cpp b/sources/elementsmover.cpp index 4183bf780..e321ef06e 100644 --- a/sources/elementsmover.cpp +++ b/sources/elementsmover.cpp @@ -76,6 +76,7 @@ int ElementsMover::beginMovement(Diagram *diagram, QGraphicsItem *driver_item) { current_movement_ = QPointF(0.0, 0.0); moved_content_ = diagram -> selectedContent(); + moved_content_.removeNonMovableItems(); if (!moved_content_.count()) return(-1);