[qet] [2609] Start work to add number for terminal

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


Revision: 2609
Author:   cfdev
Date:     2013-11-12 19:43:59 +0100 (Tue, 12 Nov 2013)
Log Message:
-----------
Start work to add number for terminal

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

Modified: trunk/sources/terminal.cpp
===================================================================
--- trunk/sources/terminal.cpp	2013-11-11 16:15:43 UTC (rev 2608)
+++ trunk/sources/terminal.cpp	2013-11-12 18:43:59 UTC (rev 2609)
@@ -33,7 +33,7 @@
 	@param pf  position du point d'amarrage pour un conducteur
 	@param o   orientation de la borne : Qt::Horizontal ou Qt::Vertical
 */
-void Terminal::init(QPointF pf, QET::Orientation o) {
+void Terminal::init(QPointF pf, QET::Orientation o, QString number) {
 	// definition du pount d'amarrage pour un conducteur
 	dock_conductor_  = pf;
 	
@@ -50,7 +50,8 @@
 		case QET::South:
 		default        : dock_elmt_ += QPointF(0, -Terminal::terminalSize);
 	}
-	
+	// Number of terminal
+	number_terminal_ = number;
 	// par defaut : pas de conducteur
 	
 	// QRectF null
@@ -70,12 +71,12 @@
 	@param e   Element auquel cette borne appartient
 	@param s   Scene sur laquelle figure cette borne
 */
-Terminal::Terminal(QPointF pf, QET::Orientation o, Element *e, Diagram *s) :
+Terminal::Terminal(QPointF pf, QET::Orientation o, QString num, Element *e, Diagram *s) :
 	QGraphicsItem(e, s),
 	parent_element_(e),
 	hovered_color_(Terminal::neutralColor)
 {
-	init(pf, o);
+	init(pf, o, num);
 }
 
 /**
@@ -86,12 +87,12 @@
 	@param e    Element auquel cette borne appartient
 	@param s    Scene sur laquelle figure cette borne
 */
-Terminal::Terminal(qreal pf_x, qreal pf_y, QET::Orientation o, Element *e, Diagram *s) :
+Terminal::Terminal(qreal pf_x, qreal pf_y, QET::Orientation o, QString num, Element *e, Diagram *s) :
 	QGraphicsItem(e, s),
 	parent_element_(e),
 	hovered_color_(Terminal::neutralColor)
 {
-	init(QPointF(pf_x, pf_y), o);
+	init(QPointF(pf_x, pf_y), o, num);
 }
 
 /**
@@ -437,6 +438,7 @@
 	qdo.setAttribute("x", QString("%1").arg(dock_elmt_.x()));
 	qdo.setAttribute("y",  QString("%1").arg(dock_elmt_.y()));
 	qdo.setAttribute("orientation", ori_);
+	qdo.setAttribute("number", number_terminal_);
 	return(qdo);
 }
 
@@ -453,6 +455,7 @@
 	if (!terminal.hasAttribute("x")) return(false);
 	if (!terminal.hasAttribute("y")) return(false);
 	if (!terminal.hasAttribute("orientation")) return(false);
+	if (!terminal.hasAttribute("number")) return(false);
 	
 	bool conv_ok;
 	// parse l'abscisse
@@ -485,7 +488,8 @@
 	return (
 		qFuzzyCompare(terminal.attribute("x").toDouble(), dock_elmt_.x()) &&
 		qFuzzyCompare(terminal.attribute("y").toDouble(), dock_elmt_.y()) &&
-		terminal.attribute("orientation").toInt() == ori_
+		terminal.attribute("orientation").toInt() == ori_ &&
+		terminal.attribute("number").toInt() == number_terminal_
 	);
 }
 

Modified: trunk/sources/terminal.h
===================================================================
--- trunk/sources/terminal.h	2013-11-11 16:15:43 UTC (rev 2608)
+++ trunk/sources/terminal.h	2013-11-12 18:43:59 UTC (rev 2609)
@@ -31,8 +31,8 @@
 	
 	// constructors, destructor
 	public:
-	Terminal(QPointF,      QET::Orientation, Element * = 0, Diagram * = 0);
-	Terminal(qreal, qreal, QET::Orientation, Element * = 0, Diagram * = 0);
+	Terminal(QPointF,      QET::Orientation, QString number, Element * = 0, Diagram * = 0);
+	Terminal(qreal, qreal, QET::Orientation, QString number, Element * = 0, Diagram * = 0);
 	virtual ~Terminal();
 	
 	private:
@@ -61,6 +61,7 @@
 	QList<Conductor *> conductors() const;
 	QET::Orientation orientation() const;
 	QPointF dockConductor() const;
+	QString number() const;
 	void updateConductor();
 	bool isLinkedTo(Terminal *);
 	bool canBeLinkedTo(Terminal *);
@@ -116,9 +117,11 @@
 	bool hovered_;
 	/// Color used for the hover effect
 	QColor hovered_color_;
+	/// Number of Terminal
+	QString number_terminal_;
 	
 	private:
-	void init(QPointF, QET::Orientation);
+	void init(QPointF, QET::Orientation, QString number);
 };
 
 /**
@@ -136,4 +139,11 @@
 	return(mapToScene(dock_conductor_));
 }
 
+/**
+	@return the number of terminal.
+*/
+inline QString Terminal::number() const {
+	return(number_terminal_);
+}
+
 #endif


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