[qet] [2618] EditorElement: try to add number and name GUI... so hard! why is it so complicated?!

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


Revision: 2618
Author:   cfdev
Date:     2013-11-16 20:20:15 +0100 (Sat, 16 Nov 2013)
Log Message:
-----------
EditorElement: try to add number and name GUI...so hard! why is it so complicated?!

Modified Paths:
--------------
    trunk/sources/editor/partterminal.cpp
    trunk/sources/editor/partterminal.h
    trunk/sources/editor/terminaleditor.cpp
    trunk/sources/editor/terminaleditor.h

Modified: trunk/sources/editor/partterminal.cpp
===================================================================
--- trunk/sources/editor/partterminal.cpp	2013-11-16 16:53:46 UTC (rev 2617)
+++ trunk/sources/editor/partterminal.cpp	2013-11-16 19:20:15 UTC (rev 2618)
@@ -54,6 +54,11 @@
 	
 	// lit l'orientation de la borne
 	_orientation = QET::orientationFromString(xml_elmt.attribute("orientation"));
+	
+	// Read number and name of terminal from XML
+	number_ = xml_elmt.attribute("number");
+	name_ = xml_elmt.attribute("name");
+	
 	updateSecondPoint();
 }
 
@@ -71,6 +76,9 @@
 	
 	// ecrit l'orientation de la borne
 	xml_element.setAttribute("orientation", orientationToString(_orientation));
+	// Write name and number to XML
+	xml_element.setAttribute("number", number_);
+	xml_element.setAttribute("name", name_);
 	
 	return(xml_element);
 }
@@ -143,6 +151,36 @@
 }
 
 /**
+	@return Number of terminal
+*/
+QString PartTerminal::number() const {
+	return(number_);
+}
+
+/**
+	set Number of Terminal
+	@param num number of terminal
+*/
+void PartTerminal::setNumber(const QString &num) {
+	number_ = num;
+}
+
+/**
+	@return Name of terminal
+*/
+QString PartTerminal::nameOfTerminal() const {
+	return(name_);
+}
+
+/**
+	set Name of Terminal
+	@param na Name of terminal
+*/
+void PartTerminal::setName(const QString &na) {
+	name_ = na;
+}
+
+/**
 	Specifie la valeur d'une propriete donnee de la borne
 	@param property propriete a modifier. Valeurs acceptees :
 		* x : abscisse de la borne
@@ -160,6 +198,12 @@
 	} else if (property == "orientation") {
 		if (!value.canConvert(QVariant::Int)) return;
 		setOrientation(static_cast<QET::Orientation>(value.toInt()));
+	} else if (property == "number") {
+		if (!value.canConvert(QVariant::String)) return;
+		setNumber(value.toString());
+	} else if (property == "name") {
+		if (!value.canConvert(QVariant::String)) return;
+		setName(value.toString());
 	}
 }
 
@@ -178,6 +222,10 @@
 		return(scenePos().y());
 	} else if (property == "orientation") {
 		return(_orientation);
+	} else if (property == "number") {
+		return(number_);
+	} else if (property == "name") {
+		return(name_);
 	}
 	return(QVariant());
 }

Modified: trunk/sources/editor/partterminal.h
===================================================================
--- trunk/sources/editor/partterminal.h	2013-11-16 16:53:46 UTC (rev 2617)
+++ trunk/sources/editor/partterminal.h	2013-11-16 19:20:15 UTC (rev 2618)
@@ -36,6 +36,7 @@
 	private:
 	QET::Orientation _orientation;
 	QPointF second_point;
+	QString number_, name_;
 	
 	// methods
 	public:
@@ -54,6 +55,11 @@
 	virtual QRectF boundingRect() const;
 	QET::Orientation orientation() const;
 	void setOrientation(QET::Orientation);
+	QString number() const;
+	void setNumber(const QString &);
+	QString nameOfTerminal() const;
+	void setName(const QString &);
+	
 	virtual void setProperty(const QString &, const QVariant &);
 	virtual QVariant property(const QString &);
 	virtual bool isUseless() const;

Modified: trunk/sources/editor/terminaleditor.cpp
===================================================================
--- trunk/sources/editor/terminaleditor.cpp	2013-11-16 16:53:46 UTC (rev 2617)
+++ trunk/sources/editor/terminaleditor.cpp	2013-11-16 19:20:15 UTC (rev 2618)
@@ -41,6 +41,9 @@
 	orientation -> addItem(QET::Icons::South, tr("Sud"),   QET::South);
 	orientation -> addItem(QET::Icons::West,  tr("Ouest"), QET::West);
 	
+	qle_number = new QLineEdit();
+	qle_name   = new QLineEdit();
+	
 	QVBoxLayout *main_layout = new QVBoxLayout();
 	main_layout -> addWidget(new QLabel(tr("Position : ")));
 	
@@ -55,6 +58,14 @@
 	ori -> addWidget(new QLabel(tr("Orientation : ")));
 	ori -> addWidget(orientation                     );
 	main_layout -> addLayout(ori);
+	
+	QHBoxLayout *num = new QHBoxLayout();
+	num -> addWidget(new QLabel(tr("Num\351ro : ")));
+	num -> addWidget(qle_number                     );
+	num -> addWidget(new QLabel(tr("Nom : ")));
+	num -> addWidget(qle_name                     );
+	main_layout -> addLayout(num);
+	
 	main_layout -> addStretch();
 	setLayout(main_layout);
 	
@@ -108,6 +119,8 @@
 			).toInt()
 		)
 	);
+	part -> setNumber( qle_number->text() );
+	part -> setName  ( qle_name->text() );
 }
 
 /// Met a jour l'abscisse de la position de la borne et cree un objet d'annulation
@@ -116,6 +129,9 @@
 void TerminalEditor::updateTerminalY() { addChangePartCommand(tr("ordonn\351e"), part, "y",           qle_y -> text().toDouble()); updateForm(); }
 /// Met a jour l'orientation de la borne et cree un objet d'annulation
 void TerminalEditor::updateTerminalO() { addChangePartCommand(tr("orientation"), part, "orientation", orientation -> itemData(orientation -> currentIndex()).toInt()); }
+/// update Number and name, create cancel object
+void TerminalEditor::updateTerminalNum() { addChangePartCommand(tr("num\351ro: ")+qle_number -> text(), part, "num\351ro:", qle_number -> text()); updateForm(); }
+void TerminalEditor::updateTerminalName() { addChangePartCommand(tr("nom: ")+qle_name -> text(), part, "nom", qle_name -> text()); updateForm(); }
 
 /**
 	Met a jour le formulaire d'edition
@@ -126,6 +142,8 @@
 	qle_x -> setText(part -> property("x").toString());
 	qle_y -> setText(part -> property("y").toString());
 	orientation -> setCurrentIndex(static_cast<int>(part -> orientation()));
+	qle_number -> setText(part -> number() );
+	qle_name -> setText(part -> nameOfTerminal() );
 	activeConnections(true);
 }
 
@@ -138,9 +156,13 @@
 		connect(qle_x,       SIGNAL(editingFinished()), this, SLOT(updateTerminalX()));
 		connect(qle_y,       SIGNAL(editingFinished()), this, SLOT(updateTerminalY()));
 		connect(orientation, SIGNAL(activated(int)),    this, SLOT(updateTerminalO()));
+		connect(qle_number,  SIGNAL(editingFinished()), this, SLOT(updateTerminalNum()));
+		connect(qle_name,    SIGNAL(editingFinished()), this, SLOT(updateTerminalName()));
 	} else {
 		disconnect(qle_x,       SIGNAL(editingFinished()), this, SLOT(updateTerminalX()));
 		disconnect(qle_y,       SIGNAL(editingFinished()), this, SLOT(updateTerminalY()));
 		disconnect(orientation, SIGNAL(activated(int)),    this, SLOT(updateTerminalO()));
+		disconnect(qle_number,  SIGNAL(editingFinished()), this, SLOT(updateTerminalNum()));
+		disconnect(qle_name,    SIGNAL(editingFinished()), this, SLOT(updateTerminalName()));
 	}
 }

Modified: trunk/sources/editor/terminaleditor.h
===================================================================
--- trunk/sources/editor/terminaleditor.h	2013-11-16 16:53:46 UTC (rev 2617)
+++ trunk/sources/editor/terminaleditor.h	2013-11-16 19:20:15 UTC (rev 2618)
@@ -37,6 +37,7 @@
 	PartTerminal *part;
 	QLineEdit *qle_x, *qle_y;
 	QComboBox *orientation;
+	QLineEdit *qle_number, *qle_name;
 	
 	// methods
 	public:
@@ -48,6 +49,8 @@
 	void updateTerminalX();
 	void updateTerminalY();
 	void updateTerminalO();
+	void updateTerminalNum();
+	void updateTerminalName();
 	void updateForm();
 	
 	private:


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