[qet] [3568] Remove all information about internal connection in element ( obselete since internal connection is always allowed)

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


Revision: 3568
Author:   blacksun
Date:     2014-12-23 20:00:37 +0100 (Tue, 23 Dec 2014)
Log Message:
-----------
Remove all information about internal connection in element (obselete since internal connection is always allowed)

Modified Paths:
--------------
    trunk/sources/diagram.cpp
    trunk/sources/qetgraphicsitem/customelement.cpp
    trunk/sources/qetgraphicsitem/element.cpp
    trunk/sources/qetgraphicsitem/element.h
    trunk/sources/qetgraphicsitem/ghostelement.cpp
    trunk/sources/qetgraphicsitem/terminal.cpp

Modified: trunk/sources/diagram.cpp
===================================================================
--- trunk/sources/diagram.cpp	2014-12-23 02:06:36 UTC (rev 3567)
+++ trunk/sources/diagram.cpp	2014-12-23 19:00:37 UTC (rev 3568)
@@ -599,33 +599,28 @@
 		added_shapes << dii;
 	}
 
-	// Load conductor
+		// Load conductor
 	QList<Conductor *> added_conductors;
-	foreach (QDomElement f, QET::findInDomElement(root, "conductors", "conductor")) {
+	foreach (QDomElement f, QET::findInDomElement(root, "conductors", "conductor"))
+	{
 		if (!Conductor::valideXml(f)) continue;
-		// verifie que les bornes que le conducteur relie sont connues
+
+			//Check if terminal that conductor must be linked is know
 		int id_p1 = f.attribute("terminal1").toInt();
 		int id_p2 = f.attribute("terminal2").toInt();
-		if (table_adr_id.contains(id_p1) && table_adr_id.contains(id_p2)) {
-			// pose le conducteur... si c'est possible
+		if (table_adr_id.contains(id_p1) && table_adr_id.contains(id_p2))
+		{
 			Terminal *p1 = table_adr_id.value(id_p1);
 			Terminal *p2 = table_adr_id.value(id_p2);
-			if (p1 != p2) {
-				bool can_add_conductor = true;
-				bool cia = ((Element *)p2 -> parentItem()) -> internalConnections();
-				if (!cia) {
-					foreach(QGraphicsItem *item, p2 -> parentItem() -> children()) {
-						if (item == p1) can_add_conductor = false;
-					}
-				}
-				if (can_add_conductor) {
-					Conductor *c = new Conductor(table_adr_id.value(id_p1), table_adr_id.value(id_p2));
-					addItem(c);
-					c -> fromXml(f);
-					added_conductors << c;
-				}
+			if (p1 != p2)
+			{
+				Conductor *c = new Conductor(table_adr_id.value(id_p1), table_adr_id.value(id_p2));
+				addItem(c);
+				c -> fromXml(f);
+				added_conductors << c;
 			}
-		} else qDebug() << "Diagram::fromXml() : Le chargement du conducteur" << id_p1 << id_p2 << "a echoue";
+		}
+		else qDebug() << "Diagram::fromXml() : Le chargement du conducteur" << id_p1 << id_p2 << "a echoue";
 	}
 
 	//Translate items if a new position was given in parameter

Modified: trunk/sources/qetgraphicsitem/customelement.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/customelement.cpp	2014-12-23 02:06:36 UTC (rev 3567)
+++ trunk/sources/qetgraphicsitem/customelement.cpp	2014-12-23 19:00:37 UTC (rev 3568)
@@ -137,13 +137,12 @@
 		return(false);
 	}
 	
-	// on peut d'ores et deja specifier la taille et le hotspot
 	setSize(w, h);
 	setHotspot(QPoint(hot_x, hot_y));
-	setInternalConnections(xml_def_elmt.attribute("ic") == "true");
 	
-	// la definition est supposee avoir des enfants
-	if (xml_def_elmt.firstChild().isNull()) {
+		//the definition must have childs
+	if (xml_def_elmt.firstChild().isNull())
+	{
 		if (state) *state = 6;
 		return(false);
 	}

Modified: trunk/sources/qetgraphicsitem/element.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/element.cpp	2014-12-23 02:06:36 UTC (rev 3567)
+++ trunk/sources/qetgraphicsitem/element.cpp	2014-12-23 19:00:37 UTC (rev 3568)
@@ -32,7 +32,6 @@
 */
 Element::Element(QGraphicsItem *parent) :
 	QetGraphicsItem(parent),
-	internal_connections_(false),
 	must_highlight_(false),
 	m_mouse_over(false)
 {

Modified: trunk/sources/qetgraphicsitem/element.h
===================================================================
--- trunk/sources/qetgraphicsitem/element.h	2014-12-23 02:06:36 UTC (rev 3567)
+++ trunk/sources/qetgraphicsitem/element.h	2014-12-23 19:00:37 UTC (rev 3568)
@@ -160,9 +160,6 @@
 	void select();
 	void deselect();	
 	
-	// methods related to internal connections
-	bool internalConnections();
-	void setInternalConnections(bool);
 	virtual void rotateBy(const qreal &);
 	virtual void editProperty();
 	
@@ -179,7 +176,6 @@
 		void drawAxes(QPainter *, const QStyleOptionGraphicsItem *);
 	
 	private:
-		bool internal_connections_;
 		bool must_highlight_;
 		void drawSelection(QPainter *, const QStyleOptionGraphicsItem *);
 		void drawHighlight(QPainter *, const QStyleOptionGraphicsItem *);
@@ -200,24 +196,6 @@
 }
 
 /**
-	Indicate whether this element allows internal connections, i.e. whether its
-	terminals can be linked together using a conductor.
-	@return true if internal connections are accepted, false otherwise
-*/
-inline bool Element::internalConnections() {
-	return(internal_connections_);
-}
-
-/**
-	Specify whether this element allows internal connections, i.e. whether its
-	terminals can be linked together using a conductor.
-	@return true for internal connections to be accepted, false otherwise
-*/
-inline void Element::setInternalConnections(bool ic) {
-	internal_connections_ = ic;
-}
-
-/**
 	Indicate the current orientation of this element
 	O = 0°
 	1 = 90°

Modified: trunk/sources/qetgraphicsitem/ghostelement.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/ghostelement.cpp	2014-12-23 02:06:36 UTC (rev 3567)
+++ trunk/sources/qetgraphicsitem/ghostelement.cpp	2014-12-23 19:00:37 UTC (rev 3568)
@@ -73,7 +73,6 @@
 	QRect final_bounding_rect = minimalBoundingRect().united(childrenBoundingRect()).toAlignedRect();
 	setSize(final_bounding_rect.width(), final_bounding_rect.height());
 	setHotspot(QPoint() - final_bounding_rect.topLeft());
-	setInternalConnections(true);
 	
 	// on peut desormais confectionner le rendu de l'element
 	generateDrawings();

Modified: trunk/sources/qetgraphicsitem/terminal.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/terminal.cpp	2014-12-23 02:06:36 UTC (rev 3567)
+++ trunk/sources/qetgraphicsitem/terminal.cpp	2014-12-23 19:00:37 UTC (rev 3568)
@@ -442,22 +442,17 @@
 }
 
 /**
-	@param other_terminal Autre borne
-	@return true si cette borne peut etre reliee a other_terminal, false sion
-*/
-bool Terminal::canBeLinkedTo(Terminal *other_terminal) {
-	if (other_terminal == this) return(false);
-	
-	// l'autre borne appartient-elle au meme element ?
-	bool same_element = other_terminal -> parentElement() == parentElement();
-	// les connexions internes sont-elles autorisees ?
-	bool internal_connections_allowed = parentElement() -> internalConnections();
-	// les deux bornes sont-elles deja liees ?
-	bool already_linked = isLinkedTo(other_terminal);
-	// la liaison des deux bornes est-elle interdite ?
-	bool link_forbidden = (same_element && !internal_connections_allowed) || already_linked;
-	
-	return(!link_forbidden);
+ * @brief Terminal::canBeLinkedTo
+ * @param other_terminal
+ * @return true if this terminal can be linked to @other_terminal,
+ * otherwise false
+ */
+bool Terminal::canBeLinkedTo(Terminal *other_terminal)
+{
+	if (other_terminal == this || isLinkedTo(other_terminal))
+		return false;
+
+	return true;
 }
 
 /**


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