[qet] qet/qet: [5333] multi past dialog : add check box for autonum the pasted element

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 5333
Author:   blacksun
Date:     2018-04-12 19:59:05 +0200 (Thu, 12 Apr 2018)
Log Message:
-----------
multi past dialog : add check box for autonum the pasted element

Modified Paths:
--------------
    trunk/sources/autoNum/assignvariables.cpp
    trunk/sources/autoNum/assignvariables.h
    trunk/sources/qetgraphicsitem/element.cpp
    trunk/sources/ui/multipastedialog.cpp
    trunk/sources/ui/multipastedialog.ui

Modified: trunk/sources/autoNum/assignvariables.cpp
===================================================================
--- trunk/sources/autoNum/assignvariables.cpp	2018-04-12 17:58:23 UTC (rev 5332)
+++ trunk/sources/autoNum/assignvariables.cpp	2018-04-12 17:59:05 UTC (rev 5333)
@@ -138,6 +138,17 @@
 		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

Modified: trunk/sources/autoNum/assignvariables.h
===================================================================
--- trunk/sources/autoNum/assignvariables.h	2018-04-12 17:58:23 UTC (rev 5332)
+++ trunk/sources/autoNum/assignvariables.h	2018-04-12 17:59:05 UTC (rev 5333)
@@ -44,6 +44,7 @@
 
 			QDomElement toXml(QDomDocument &document, QString tag_name = QString("sequentialNumbers")) const;
 			void fromXml(const QDomElement &element);
+			void clear();
 
 			QStringList unit;
 			QStringList unit_folio;

Modified: trunk/sources/qetgraphicsitem/element.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/element.cpp	2018-04-12 17:58:23 UTC (rev 5332)
+++ trunk/sources/qetgraphicsitem/element.cpp	2018-04-12 17:59:05 UTC (rev 5333)
@@ -1182,6 +1182,7 @@
 		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());
 

Modified: trunk/sources/ui/multipastedialog.cpp
===================================================================
--- trunk/sources/ui/multipastedialog.cpp	2018-04-12 17:58:23 UTC (rev 5332)
+++ trunk/sources/ui/multipastedialog.cpp	2018-04-12 17:59:05 UTC (rev 5333)
@@ -80,6 +80,7 @@
 		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 @@
 		}
 		
 		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;
 	}

Modified: trunk/sources/ui/multipastedialog.ui
===================================================================
--- trunk/sources/ui/multipastedialog.ui	2018-04-12 17:58:23 UTC (rev 5332)
+++ trunk/sources/ui/multipastedialog.ui	2018-04-12 17:59:05 UTC (rev 5333)
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>261</width>
-    <height>110</height>
+    <height>136</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -95,6 +95,13 @@
     </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">
       <enum>Qt::Vertical</enum>


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/