[qet] [3240] foret file from previous comit.

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


Revision: 3240
Author:   blacksun
Date:     2014-07-31 21:44:25 +0200 (Thu, 31 Jul 2014)
Log Message:
-----------
foret file from previous comit.

Modified Paths:
--------------
    trunk/sources/conductorautonumerotation.cpp
    trunk/sources/conductorautonumerotation.h

Modified: trunk/sources/conductorautonumerotation.cpp
===================================================================
--- trunk/sources/conductorautonumerotation.cpp	2014-07-31 10:02:33 UTC (rev 3239)
+++ trunk/sources/conductorautonumerotation.cpp	2014-07-31 19:44:25 UTC (rev 3240)
@@ -20,39 +20,20 @@
 #include "diagramcommands.h"
 #include "numerotationcontextcommands.h"
 #include "qetdiagrameditor.h"
+#include "conductor.h"
+#include "diagram.h"
 
 /**
  *Constructor
  * @param c the conductor to apply automatic numerotation
  */
 ConductorAutoNumerotation::ConductorAutoNumerotation(Conductor *c) :
-	AutoNumerotation (c -> diagram()),
-	conductor_ (c),
-	conductor_list(c -> relatedPotentialConductors())
-{
-	num_context = diagram_ -> getNumerotation(Diagram::Conductors);
-}
-
-/**
- * Constructor
- * @param d a diagram to apply automatic numerotation
- */
-ConductorAutoNumerotation::ConductorAutoNumerotation(Diagram *d) :
-	AutoNumerotation (d),
-	conductor_ (NULL)
+	m_diagram      (c -> diagram()),
+	conductor_     (c),
+	conductor_list (c -> relatedPotentialConductors())
 {}
 
 /**
- * @param c the conductor to apply automatic numerotation
- */
-void ConductorAutoNumerotation::setConductor(Conductor *c) {
-	conductor_ = c;
-	diagram_ = c -> diagram();
-	conductor_list = c -> relatedPotentialConductors();
-	num_context = diagram_ -> getNumerotation(Diagram::Conductors);
-}
-
-/**
  * @brief ConductorAutoNumerotation::numerate
  * execute the automatic numerotation
  */
@@ -60,27 +41,9 @@
 	if (!conductor_) return;
 	if (conductor_list.size() >= 1 ) numeratePotential();
 	else if (conductor_ -> properties().type == ConductorProperties::Multi) numerateNewConductor();
-	else return;
 }
 
 /**
- * @brief ConductorAutoNumerotation::numerateDiagram
- * Numerate all conductor in diagram
- */
-void ConductorAutoNumerotation::numerateDiagram() {
-	if (!diagram_) return;
-	//Get all potentials presents in diagram
-	QList <QSet <Conductor *> > potential_list = diagram_ -> potentials();
-	//Browse all potentials and set new numerotation
-	for (int i=0; i < potential_list.size(); ++i) {
-		setConductor (potential_list.at(i).toList().first());
-		NumerotationContextCommands ncc(diagram_, num_context);
-		applyText(ncc.toRepresentedString());
-		diagram_ -> setNumerotation(Diagram::Conductors, ncc.next());
-	}
-}
-
-/**
  * @brief ConductorAutoNumerotation::checkPotential
  * Check if text of this potential is identical.
  * If not, ask user how to numerate
@@ -99,7 +62,7 @@
 	if (!eachIsEqual(strl)) {
 		ConductorAutoNumerotationWidget canw(c_list, conductor -> diagramEditor());
 		ConductorAutoNumerotation can(conductor);
-		connect(&canw, SIGNAL(textIsSelected(QString)), &can, SLOT(applyText(QString)));
+		//connect(&canw, SIGNAL(textIsSelected(QString)), &can, SLOT(applyText(QString)));
 		canw.exec();
 	}
 }
@@ -117,7 +80,7 @@
 		ConductorProperties cp = conductor_ -> properties();
 		cp.text = t;
 		ccpc -> setNewSettings(cp);
-		diagram_ -> undoStack().push(ccpc);
+		m_diagram -> undoStack().push(ccpc);
 	}
 	else {
 		QList <Conductor *> clist = conductor_list.toList();
@@ -135,25 +98,11 @@
 		ChangeSeveralConductorsPropertiesCommand *cscpc = new ChangeSeveralConductorsPropertiesCommand(clist);
 		cscpc -> setOldSettings(old_properties);
 		cscpc -> setNewSettings(new_properties);
-		diagram_ -> undoStack().push(cscpc);
+		m_diagram -> undoStack().push(cscpc);
 	}
 }
 
 /**
- * @brief Set the default text to all potentials of the diagram
- */
-void ConductorAutoNumerotation::removeNumOfDiagram() {
-	if (!diagram_) return;
-	//Get all potentials presents in diagram
-	QList <QSet <Conductor *> > potential_list = diagram_ -> potentials();
-	//Browse all potentials and set the default text
-	for (int i=0; i < potential_list.size(); i++) {
-		setConductor (potential_list.at(i).toList().first());
-		applyText (diagram_ -> defaultConductorProperties.text);
-	}
-}
-
-/**
  * @brief ConductorAutoNumerotation::numeratePotential
  * Numerate a conductor on an existing potential
  */
@@ -170,8 +119,8 @@
 	//the texts isn't identicals
 	else {
 		ConductorAutoNumerotationWidget *canw = new ConductorAutoNumerotationWidget(conductor_list, conductor_ -> diagramEditor());
-		connect(canw, SIGNAL(textIsSelected(QString)),
-				this, SLOT(applyText(QString)));
+		/*connect(canw, SIGNAL(textIsSelected(QString)),
+				this, SLOT(applyText(QString)));*/
 		canw -> exec();
 	}
 }
@@ -181,11 +130,12 @@
  * create and apply a new numerotation to @conductor_
  */
 void ConductorAutoNumerotation::numerateNewConductor() {
-	if (!conductor_ || num_context.isEmpty()) return;
+	if (!conductor_ || m_diagram->conductorsAutonumName().isEmpty()) return;
 
-	NumerotationContextCommands ncc (diagram_, num_context);
+	QString name = m_diagram -> conductorsAutonumName();
+	NumerotationContextCommands ncc (m_diagram, m_diagram->project()->conductorAutoNum(name));
 	applyText(ncc.toRepresentedString());
-	diagram_-> setNumerotation(Diagram::Conductors, ncc.next());
+	m_diagram->project()->addConductorAutoNum(name, ncc.next());
 }
 
 /**

Modified: trunk/sources/conductorautonumerotation.h
===================================================================
--- trunk/sources/conductorautonumerotation.h	2014-07-31 10:02:33 UTC (rev 3239)
+++ trunk/sources/conductorautonumerotation.h	2014-07-31 19:44:25 UTC (rev 3240)
@@ -18,25 +18,19 @@
 #ifndef CONDUCTORAUTONUMEROTATION_H
 #define CONDUCTORAUTONUMEROTATION_H
 
-#include "qetgraphicsitem/conductor.h"
-#include "numerotationcontext.h"
-#include "autonumerotation.h"
+#include <QSet>
 
-class ConductorAutoNumerotation: public AutoNumerotation
-{
+class Diagram;
+class Conductor;
+
+class ConductorAutoNumerotation {
 	public:
 	//constructors & destructor
 	ConductorAutoNumerotation (Conductor *);
-	ConductorAutoNumerotation (Diagram *);
 
 	//methods
-	void setConductor(Conductor *);
 	void numerate();
-	void numerateDiagram();
-	void removeNumOfDiagram();
 	static void checkPotential(Conductor *);
-
-	public slots:
 	void applyText(QString);
 
 	private:
@@ -45,7 +39,8 @@
 	void numerateNewConductor ();
 
 	//attributes
-	Conductor *conductor_;
+	Diagram           *m_diagram;
+	Conductor         *conductor_;
 	QSet <Conductor *> conductor_list;
 };
 


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