From e3930df5b5f8e78aea64eebde50844ca6e063ea0 Mon Sep 17 00:00:00 2001 From: blacksun Date: Thu, 12 Apr 2018 17:59:05 +0000 Subject: [PATCH] multi past dialog : add check box for autonum the pasted element git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5333 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/autoNum/assignvariables.cpp | 11 +++++++++++ sources/autoNum/assignvariables.h | 1 + sources/qetgraphicsitem/element.cpp | 1 + sources/ui/multipastedialog.cpp | 28 ++++++++++++++++++++++++++++ sources/ui/multipastedialog.ui | 9 ++++++++- 5 files changed, 49 insertions(+), 1 deletion(-) diff --git a/sources/autoNum/assignvariables.cpp b/sources/autoNum/assignvariables.cpp index 158bd645d..c25d817ea 100644 --- a/sources/autoNum/assignvariables.cpp +++ b/sources/autoNum/assignvariables.cpp @@ -138,6 +138,17 @@ namespace autonum from = element.firstChildElement("hundredFolio"); hundred_folio = from.text().split(";"); } + + //Clear this sequence + void sequentialNumbers::clear() + { + unit.clear(); + unit_folio.clear(); + ten.clear(); + ten_folio.clear(); + hundred.clear(); + hundred_folio.clear(); + } /** * @brief AssignVariables::formulaToLabel diff --git a/sources/autoNum/assignvariables.h b/sources/autoNum/assignvariables.h index dbdee8b31..bec69e40d 100644 --- a/sources/autoNum/assignvariables.h +++ b/sources/autoNum/assignvariables.h @@ -44,6 +44,7 @@ namespace autonum QDomElement toXml(QDomDocument &document, QString tag_name = QString("sequentialNumbers")) const; void fromXml(const QDomElement &element); + void clear(); QStringList unit; QStringList unit_folio; diff --git a/sources/qetgraphicsitem/element.cpp b/sources/qetgraphicsitem/element.cpp index f716ccb37..baa7f483f 100644 --- a/sources/qetgraphicsitem/element.cpp +++ b/sources/qetgraphicsitem/element.cpp @@ -1182,6 +1182,7 @@ void Element::setUpFormula(bool code_letter) NumerotationContext nc = diagram()->project()->elementAutoNum(element_currentAutoNum); NumerotationContextCommands ncc (nc); + m_autoNum_seq.clear(); autonum::setSequential(formula, m_autoNum_seq, nc, diagram(), element_currentAutoNum); diagram()->project()->addElementAutoNum(element_currentAutoNum, ncc.next()); diff --git a/sources/ui/multipastedialog.cpp b/sources/ui/multipastedialog.cpp index 02c06cade..1ef19e235 100644 --- a/sources/ui/multipastedialog.cpp +++ b/sources/ui/multipastedialog.cpp @@ -80,6 +80,7 @@ void MultiPasteDialog::on_m_button_box_accepted() QUndoCommand *undo = new QUndoCommand(tr("Multi-collage")); new PasteDiagramCommand(m_diagram, m_pasted_content, undo); + //Auto-connection if(ui->m_auto_connection_cb->isChecked()) { for(Element *elmt : m_pasted_content.m_elements) @@ -102,6 +103,33 @@ void MultiPasteDialog::on_m_button_box_accepted() } m_diagram->undoStack().push(undo); + + //Set up the label of element + //Instead of use the current autonum of project, + //we try to fetch the same formula of the pasted element, in the several autonum of the project + //for apply the good formula for each elements + if(ui->m_auto_num_cb->isChecked()) + { + for(Element *elmt : m_pasted_content.m_elements) + { + QString formula = elmt->elementInformations()["formula"].toString(); + if(!formula.isEmpty()) + { + QHash autonums = m_diagram->project()->elementAutoNum(); + QHashIterator hash_iterator(autonums); + + while(hash_iterator.hasNext()) + { + hash_iterator.next(); + if(autonum::numerotationContextToFormula(hash_iterator.value()) == formula) + { + m_diagram->project()->setCurrrentElementAutonum(hash_iterator.key()); + elmt->setUpFormula(); + } + } + } + } + } m_diagram->adjustSceneRect(); m_accept = true; } diff --git a/sources/ui/multipastedialog.ui b/sources/ui/multipastedialog.ui index f3e34c999..9e359d67b 100644 --- a/sources/ui/multipastedialog.ui +++ b/sources/ui/multipastedialog.ui @@ -7,7 +7,7 @@ 0 0 261 - 110 + 136 @@ -94,6 +94,13 @@ + + + + Auto-numérotation des éléments (experimental) + + +