[qet] [2801] When link report, check if all text of the potential is equal.

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


Revision: 2801
Author:   blacksun
Date:     2014-02-04 19:03:02 +0100 (Tue, 04 Feb 2014)
Log Message:
-----------
When link report, check if all text of the potential is equal.
If not ask user what must to do.

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

Modified: trunk/sources/conductorautonumerotation.cpp
===================================================================
--- trunk/sources/conductorautonumerotation.cpp	2014-02-04 16:29:32 UTC (rev 2800)
+++ trunk/sources/conductorautonumerotation.cpp	2014-02-04 18:03:02 UTC (rev 2801)
@@ -1,5 +1,5 @@
 /*
-	Copyright 2006-2014 The QElectroTech Team
+	Copyright 2006-2014 The QElectroTech team
 	This file is part of QElectroTech.
 
 	QElectroTech is free software: you can redistribute it and/or modify
@@ -80,6 +80,30 @@
 }
 
 /**
+ * @brief ConductorAutoNumerotation::checkPotential
+ * Check if text of this potential is identical.
+ * If not, ask user how to numerate
+ * @param conductor
+ * One conductor of this potential.
+ */
+void ConductorAutoNumerotation::checkPotential(Conductor *conductor) {
+	//fill list of potential
+	QSet <Conductor *> c_list = conductor->relatedPotentialConductors();
+	c_list << conductor;
+	//fill list of text
+	QStringList strl;
+	foreach (const Conductor *c, c_list) strl<<(c->text());
+
+	//check text list, isn't same in potential, ask user what to do
+	if (!eachIsEqual(strl)) {
+		ConductorAutoNumerotationWidget *canw = new ConductorAutoNumerotationWidget(conductor, c_list, conductor -> diagramEditor());
+		ConductorAutoNumerotation can(conductor);
+		connect(canw, SIGNAL(textIsSelected(QString)), &can, SLOT(applyText(QString)));
+		canw -> exec();
+	}
+}
+
+/**
  * @brief ConductorAutoNumerotation::applyText
  * apply the text @t to @conductor_ and all conductors at the same potential
  */

Modified: trunk/sources/conductorautonumerotation.h
===================================================================
--- trunk/sources/conductorautonumerotation.h	2014-02-04 16:29:32 UTC (rev 2800)
+++ trunk/sources/conductorautonumerotation.h	2014-02-04 18:03:02 UTC (rev 2801)
@@ -1,5 +1,5 @@
 /*
-	Copyright 2006-2014 The QElectroTech Team
+	Copyright 2006-2014 The QElectroTech team
 	This file is part of QElectroTech.
 
 	QElectroTech is free software: you can redistribute it and/or modify
@@ -34,6 +34,7 @@
 	void numerate();
 	void numerateDiagram();
 	void removeNumOfDiagram();
+	static void checkPotential(Conductor *);
 
 	public slots:
 	void applyText(QString);

Modified: trunk/sources/qetgraphicsitem/reportelement.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/reportelement.cpp	2014-02-04 16:29:32 UTC (rev 2800)
+++ trunk/sources/qetgraphicsitem/reportelement.cpp	2014-02-04 18:03:02 UTC (rev 2801)
@@ -19,6 +19,7 @@
 #include "elementtextitem.h"
 #include "diagramposition.h"
 #include "qetproject.h"
+#include "conductorautonumerotation.h"
 
 ReportElement::ReportElement(const ElementsLocation &location, QString link_type,QGraphicsItem *qgi, Diagram *s, int *state) :
 	CustomElement(location, qgi, s, state)
@@ -56,8 +57,11 @@
 		connect(elmt, SIGNAL(positionChange(QPointF)), this, SLOT(updateLabel()));
 		connect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
 		updateLabel();
-		tmp_uuids_link.removeAll(elmt->uuid());
 		elmt->linkToElement(this);
+		//Check if text of this potential is identical.
+		if (conductors().count() && elmt->conductors().count()) {
+			ConductorAutoNumerotation::checkPotential(conductors().first());
+		}
 	}
 }
 
@@ -117,14 +121,16 @@
  * ie the folio and position of the linked folio report
  */
 void ReportElement::updateLabel() {
+	ElementTextItem *text = texts().first();
+
 	if (!connected_elements.isEmpty()){
 		Element *elmt = connected_elements.at(0);
 		QString label = label_;
 		label.replace("%f", QString::number(elmt->diagram()->folioIndex()+1));
 		label.replace("%c", QString::number(elmt->diagram() -> convertPosition(elmt -> scenePos()).number()));
 		label.replace("%l", elmt->diagram() -> convertPosition(elmt -> scenePos()).letter());
-		texts().at(0)->setPlainText(label);
+		text->setPlainText(label);
 	} else {
-		texts().at(0)->setPlainText("_");
+		text->setPlainText("_");
 	}
 }


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