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
This commit is contained in:
blacksun
2018-04-12 17:59:05 +00:00
parent 845fa934b7
commit e3930df5b5
5 changed files with 49 additions and 1 deletions

View File

@@ -139,6 +139,17 @@ namespace autonum
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
* Return the @formula with variable assigned (ready to be displayed)

View File

@@ -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;

View File

@@ -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());

View File

@@ -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 <QString, NumerotationContext> autonums = m_diagram->project()->elementAutoNum();
QHashIterator<QString, NumerotationContext> 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;
}

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>261</width>
<height>110</height>
<height>136</height>
</rect>
</property>
<property name="windowTitle">
@@ -94,6 +94,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="m_auto_num_cb">
<property name="text">
<string>Auto-numérotation des éléments (experimental)</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">