From c3042460e2d0b8a64425da716fa4e5f4ce1495fb Mon Sep 17 00:00:00 2001 From: blacksun Date: Tue, 28 Jan 2014 10:45:45 +0000 Subject: [PATCH] Bug fix: Paste element, make new uuid for the element. In previous version, uuid are same whith copied and paste element. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2784 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/diagramcommands.cpp | 9 +++++++-- sources/qetgraphicsitem/element.h | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sources/diagramcommands.cpp b/sources/diagramcommands.cpp index cd02637f1..60a3c3f9e 100644 --- a/sources/diagramcommands.cpp +++ b/sources/diagramcommands.cpp @@ -301,10 +301,15 @@ void PasteDiagramCommand::undo() { /// refait le coller void PasteDiagramCommand::redo() { diagram -> showMe(); - if (first_redo) first_redo = false; + if (first_redo) { + first_redo = false; + //this is the first paste, we make new uuid for each element + //because old uuid are the uuid of the copied element + foreach(Element *e, content.elements) e->newUuid(); + } else { // paste the elements - foreach(Element *e, content.elements) diagram -> addElement(e); + foreach(Element *e, content.elements) diagram -> addElement(e); // paste the conductors foreach(Conductor *c, content.conductorsToMove) diagram -> addConductor(c); diff --git a/sources/qetgraphicsitem/element.h b/sources/qetgraphicsitem/element.h index b39bff407..9212d29c3 100644 --- a/sources/qetgraphicsitem/element.h +++ b/sources/qetgraphicsitem/element.h @@ -105,6 +105,8 @@ class Element : public QetGraphicsItem { virtual void unlinkElement(Element *elmt) {} void initLink(QETProject *); QList linkedElements () const; + //create new uuid for this element + void newUuid() {uuid_ = QUuid::createUuid();} /** Draw this element