From 635561194763f3cf141b52a5e0733c283e23ce0d Mon Sep 17 00:00:00 2001 From: dfochi Date: Sun, 31 Jul 2016 01:30:42 +0000 Subject: [PATCH] Copy/Paste now works with Element Label Variables git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4599 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/diagram.h | 1 + sources/diagramcommands.cpp | 5 ++++- sources/diagramview.cpp | 3 +++ sources/qetgraphicsitem/customelement.cpp | 7 +++++-- sources/qetgraphicsitem/element.cpp | 2 -- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/sources/diagram.h b/sources/diagram.h index 7af8efc93..a554a50f0 100644 --- a/sources/diagram.h +++ b/sources/diagram.h @@ -87,6 +87,7 @@ class Diagram : public QGraphicsScene QHash m_elmt_unitfolio_max; QHash m_elmt_tenfolio_max; QHash m_elmt_hundredfolio_max; + bool item_paste; private: QGraphicsLineItem *conductor_setter_; diff --git a/sources/diagramcommands.cpp b/sources/diagramcommands.cpp index 269ab3b9e..cc0e1f875 100644 --- a/sources/diagramcommands.cpp +++ b/sources/diagramcommands.cpp @@ -212,8 +212,11 @@ void PasteDiagramCommand::redo() } } else { - foreach (QGraphicsItem *item, content.items(filter)) + foreach (QGraphicsItem *item, content.items(filter)) { + diagram->item_paste = true; diagram->addItem(item); + diagram->item_paste = false; + } } foreach (QGraphicsItem *qgi, content.items()) diff --git a/sources/diagramview.cpp b/sources/diagramview.cpp index 4f42be3c1..57e7c1214 100644 --- a/sources/diagramview.cpp +++ b/sources/diagramview.cpp @@ -82,6 +82,7 @@ DiagramView::DiagramView(Diagram *diagram, QWidget *parent) : setSelectionMode(); adjustSceneRect(); updateWindowTitle(); + scene->loadElmtFolioSeq(); context_menu = new QMenu(this); paste_here = new QAction(QET::Icons::EditPaste, tr("Coller ici", "context menu action"), this); @@ -432,6 +433,7 @@ void DiagramView::paste(const QPointF &pos, QClipboard::Mode clipboard_mode) { // objet pour recuperer le contenu ajoute au schema par le coller DiagramContent content_pasted; + this->diagram()->item_paste = true; scene -> fromXml(document_xml, pos, false, &content_pasted); // si quelque chose a effectivement ete ajoute au schema, on cree un objet d'annulation @@ -440,6 +442,7 @@ void DiagramView::paste(const QPointF &pos, QClipboard::Mode clipboard_mode) { scene -> undoStack().push(new PasteDiagramCommand(scene, content_pasted)); adjustSceneRect(); } + this->diagram()->item_paste = false; } /** diff --git a/sources/qetgraphicsitem/customelement.cpp b/sources/qetgraphicsitem/customelement.cpp index 863c8851e..6f1765b9e 100644 --- a/sources/qetgraphicsitem/customelement.cpp +++ b/sources/qetgraphicsitem/customelement.cpp @@ -336,10 +336,13 @@ void CustomElement::parseLabels() { rxml.readNext(); } } - //apply formula to specific label + //apply formula to specific label - This condition specify elements which have different labels e.g KM + //that are already specified in the element label (inside .elmt file). This method is not called if elements + //are being loaded at first time or being pasted else if ((this->taggedText("label")!= NULL) && (location().projectId()!=-1) && (!location().project()->elementAutoNumFormula().isEmpty()) && - (this->linkType()!=Element::Slave) && (this->linkType()!=Element::Terminale)) { + (this->linkType()!=Element::Slave) && (this->linkType()!=Element::Terminale) && + !this->diagram()->item_paste) { QString formula = location().project()->elementAutoNumFormula(); DiagramContext &dc = this->rElementInformations(); QString prefix = this->taggedText("label")->toPlainText(); diff --git a/sources/qetgraphicsitem/element.cpp b/sources/qetgraphicsitem/element.cpp index 6ae212d56..a6029f3a4 100644 --- a/sources/qetgraphicsitem/element.cpp +++ b/sources/qetgraphicsitem/element.cpp @@ -759,8 +759,6 @@ QString Element::assignVariables(QString label, Element *elmt){ label.replace("%id", QString::number(elmt->diagram()->folioIndex()+1)); label.replace("%total", QString::number(elmt->diagram()->border_and_titleblock.folioTotal())); label.replace("%prefix", elmt->getPrefix()); - if (label.contains("%prefix")) - label.replace("%prefix",this->getPrefix()); label = assignSeq(label); return label; }