[qet] [2647] add widget for change size of conductor text item

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


Revision: 2647
Author:   blacksun
Date:     2013-12-03 11:17:49 +0100 (Tue, 03 Dec 2013)
Log Message:
-----------
add widget for change size of conductor text item

Modified Paths:
--------------
    trunk/sources/conductorproperties.cpp
    trunk/sources/conductorproperties.h
    trunk/sources/conductorpropertieswidget.cpp
    trunk/sources/conductorpropertieswidget.h
    trunk/sources/qetgraphicsitem/conductor.cpp
    trunk/sources/qetgraphicsitem/diagramtextitem.cpp
    trunk/sources/qetgraphicsitem/diagramtextitem.h

Modified: trunk/sources/conductorproperties.cpp
===================================================================
--- trunk/sources/conductorproperties.cpp	2013-11-29 14:42:03 UTC (rev 2646)
+++ trunk/sources/conductorproperties.cpp	2013-12-03 10:17:49 UTC (rev 2647)
@@ -220,6 +220,7 @@
 	type(Multi),
 	color(Qt::black),
 	text("_"),
+	text_size(9),
 	verti_rotate_text(270),
 	horiz_rotate_text(0),
 	style(Qt::SolidLine)
@@ -248,6 +249,7 @@
 		singleLineProperties.toXml(e);
 	} else if (type == Multi) {
 		e.setAttribute("num", text);
+		e.setAttribute("numsize", text_size);
 		e.setAttribute("vertirotatetext", verti_rotate_text);
 		e.setAttribute("horizrotatetext", horiz_rotate_text);
 	}
@@ -284,6 +286,7 @@
 	} else {
 		// recupere le champ de texte
 		text = e.attribute("num");
+		text_size = e.attribute("numsize", QString::number(9)).toInt();
 		verti_rotate_text = e.attribute("vertirotatetext").toDouble();
 		horiz_rotate_text = e.attribute("horizrotatetext").toDouble();
 		type = Multi;
@@ -299,6 +302,7 @@
 	settings.setValue(prefix + "style", writeStyle());
 	settings.setValue(prefix + "type", typeToString(type));
 	settings.setValue(prefix + "text", text);
+	settings.setValue(prefix + "textsize", QString::number(text_size));
 	settings.setValue(prefix + "vertirotatetext", QString::number(verti_rotate_text));
 	settings.setValue(prefix + "horizrotatetext", QString::number(horiz_rotate_text));
 	singleLineProperties.toSettings(settings, prefix);
@@ -327,6 +331,7 @@
 	}
 	singleLineProperties.fromSettings(settings, prefix);
 	text = settings.value(prefix + "text", "_").toString();
+	text_size = settings.value(prefix + "textsize", "7").toInt();
 	verti_rotate_text = settings.value((prefix + "vertirotatetext"), "270").toDouble();
 	horiz_rotate_text = settings.value((prefix + "horizrotatetext"), "0").toDouble();
 
@@ -350,12 +355,13 @@
 	@param other l'autre ensemble de proprietes avec lequel il faut effectuer la comparaison
 	@return true si les deux ensembles de proprietes sont identiques, false sinon
 */
-int ConductorProperties::operator==(const ConductorProperties &other) {
+bool ConductorProperties::operator==(const ConductorProperties &other) const{
 	return(
 		other.type == type &&\
 		other.color == color &&\
 		other.style == style &&\
 		other.text == text &&\
+		other.text_size == text_size &&\
 		other.verti_rotate_text == verti_rotate_text &&\
 		other.horiz_rotate_text == horiz_rotate_text &&\
 		other.singleLineProperties == singleLineProperties
@@ -366,12 +372,13 @@
 	@param other l'autre ensemble de proprietes avec lequel il faut effectuer la comparaison
 	@return true si les deux ensembles de proprietes sont differents, false sinon
 */
-int ConductorProperties::operator!=(const ConductorProperties &other) {
+bool ConductorProperties::operator!=(const ConductorProperties &other) const{
 	return(
 		other.type != type ||\
 		other.color != color ||\
 		other.style != style ||\
 		other.text != text ||\
+		other.text_size != text_size ||\
 		other.verti_rotate_text != verti_rotate_text ||\
 		other.horiz_rotate_text != horiz_rotate_text ||\
 		other.singleLineProperties != singleLineProperties

Modified: trunk/sources/conductorproperties.h
===================================================================
--- trunk/sources/conductorproperties.h	2013-11-29 14:42:03 UTC (rev 2646)
+++ trunk/sources/conductorproperties.h	2013-12-03 10:17:49 UTC (rev 2647)
@@ -79,6 +79,8 @@
 	QColor color;
 	/// Texte displayed for multiline conductors
 	QString text;
+	/// size of text
+	int text_size;
 	/// rotation angle texte
 	double verti_rotate_text;
 	double horiz_rotate_text;
@@ -96,8 +98,8 @@
 	static QString typeToString(ConductorType);
 	
 	// operators
-	int operator==(const ConductorProperties &);
-	int operator!=(const ConductorProperties &);
+	bool operator==(const ConductorProperties &) const;
+	bool operator!=(const ConductorProperties &) const;
 	
 	private:
 	void readStyle(const QString &);

Modified: trunk/sources/conductorpropertieswidget.cpp
===================================================================
--- trunk/sources/conductorpropertieswidget.cpp	2013-11-29 14:42:03 UTC (rev 2646)
+++ trunk/sources/conductorpropertieswidget.cpp	2013-12-03 10:17:49 UTC (rev 2647)
@@ -63,8 +63,13 @@
 	QHBoxLayout *multiline_layout = new QHBoxLayout();
 	QLabel *text = new QLabel(tr("Texte :"));
 	text_field = new QLineEdit();
+	QLabel *size_text = new QLabel(tr("Taille"), this);
+	text_size_sb = new QSpinBox(this);
+	text_size_sb->setRange(5,9);
 	multiline_layout -> addWidget(text);
 	multiline_layout -> addWidget(text_field);
+	multiline_layout -> addWidget(size_text);
+	multiline_layout -> addWidget(text_size_sb);
 
 	QGridLayout *rotate_text_layout = new QGridLayout;
 	QLabel *rotate_label = new QLabel(tr("Rotation du texte sur conducteur :"));
@@ -179,6 +184,7 @@
 	connect(color_button,      SIGNAL(clicked()),                    this,          SLOT(chooseColor()));
 	connect(verti_select,      SIGNAL(editingFinished(double)),      this,          SLOT(updateConfig()));
 	connect(horiz_select,      SIGNAL(editingFinished(double)),      this,          SLOT(updateConfig()));
+	connect(text_size_sb,	   SIGNAL(valueChanged(int)),			 this,			SLOT(updateConfig()));
 }
 
 /**
@@ -225,6 +231,7 @@
 	disconnect(line_style,        SIGNAL(currentIndexChanged(int)),     this,          SLOT(updateConfig()));
 	disconnect(verti_select,      SIGNAL(editingFinished(double)),      this,          SLOT(updateConfig()));
 	disconnect(horiz_select,      SIGNAL(editingFinished(double)),      this,          SLOT(updateConfig()));
+	disconnect(text_size_sb,	  SIGNAL(valueChanged(int)),			this,		   SLOT(updateConfig()));
 }
 
 /// Destructeur
@@ -239,6 +246,7 @@
 	properties_.color = colorButton();
 	properties_.style = static_cast<Qt::PenStyle>(line_style -> itemData(line_style -> currentIndex()).toInt());
 	properties_.text = text_field -> text();
+	properties_.text_size = text_size_sb->value();
 	properties_.verti_rotate_text = verti_select -> value();
 	properties_.horiz_rotate_text = horiz_select -> value();
 	properties_.singleLineProperties.hasGround = ground_checkbox -> isChecked();
@@ -258,6 +266,7 @@
 	int index = line_style -> findData(properties_.style);
 	if (index != -1) line_style -> setCurrentIndex(index);
 	text_field -> setText(properties_.text);
+	text_size_sb -> setValue(properties_.text_size);
 	ground_checkbox -> setChecked(properties_.singleLineProperties.hasGround);
 	neutral_checkbox -> setChecked(properties_.singleLineProperties.hasNeutral);
 	merge_checkbox -> setChecked(properties_.singleLineProperties.is_pen);
@@ -338,6 +347,7 @@
 	multiline -> setDisabled(ro);
 	singleline -> setDisabled(ro);
 	text_field -> setReadOnly(ro);
+	text_size_sb -> setReadOnly(ro);
 	phase_checkbox -> setDisabled(ro);
 	phase_spinbox -> setReadOnly(ro);
 	ground_checkbox -> setDisabled(ro);

Modified: trunk/sources/conductorpropertieswidget.h
===================================================================
--- trunk/sources/conductorpropertieswidget.h	2013-11-29 14:42:03 UTC (rev 2646)
+++ trunk/sources/conductorpropertieswidget.h	2013-12-03 10:17:49 UTC (rev 2647)
@@ -75,6 +75,7 @@
 	QPushButton *color_button;
 	QComboBox *line_style;
 	QCheckBox *merge_checkbox;
+	QSpinBox *text_size_sb;
 	
 	ConductorProperties properties_;
 	

Modified: trunk/sources/qetgraphicsitem/conductor.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/conductor.cpp	2013-11-29 14:42:03 UTC (rev 2646)
+++ trunk/sources/qetgraphicsitem/conductor.cpp	2013-12-03 10:17:49 UTC (rev 2647)
@@ -1213,7 +1213,9 @@
 	@param t Nouveau texte du conducteur
 */
 void Conductor::setText(const QString &t) {
+	text_item -> setFontSize(properties_.text_size);
 	text_item -> setPlainText(t);
+
 }
 
 /// @param p les proprietes de ce conducteur

Modified: trunk/sources/qetgraphicsitem/diagramtextitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/diagramtextitem.cpp	2013-11-29 14:42:03 UTC (rev 2646)
+++ trunk/sources/qetgraphicsitem/diagramtextitem.cpp	2013-12-03 10:17:49 UTC (rev 2647)
@@ -184,6 +184,10 @@
 	return(local_movement_point - local_origin);
 }
 
+void DiagramTextItem::setFontSize(int &s) {
+	setFont(QETApp::diagramTextsFont(s));
+}
+
 /**
 	Dessine le champ de texte.
 	Cette methode delegue simplement le travail a QGraphicsTextItem::paint apres

Modified: trunk/sources/qetgraphicsitem/diagramtextitem.h
===================================================================
--- trunk/sources/qetgraphicsitem/diagramtextitem.h	2013-11-29 14:42:03 UTC (rev 2646)
+++ trunk/sources/qetgraphicsitem/diagramtextitem.h	2013-12-03 10:17:49 UTC (rev 2647)
@@ -58,6 +58,7 @@
 	QPointF mapMovementFromScene(const QPointF &) const;
 	QPointF mapMovementToParent(const QPointF &) const;
 	QPointF mapMovementFromParent(const QPointF &) const;
+	void setFontSize(int &s);
 	
 	protected:
 	virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);


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