[qet] qet/qet: [5765] Diagram text item : remove the function fontSize, and use instead font

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


Revision: 5765
Author:   blacksun
Date:     2019-03-08 12:53:27 +0100 (Fri, 08 Mar 2019)
Log Message:
-----------
Diagram text item : remove the function fontSize, and use instead font

Modified Paths:
--------------
    trunk/sources/qetgraphicsitem/conductor.cpp
    trunk/sources/qetgraphicsitem/diagramtextitem.cpp
    trunk/sources/qetgraphicsitem/diagramtextitem.h
    trunk/sources/qetgraphicsitem/element.cpp
    trunk/sources/qetgraphicsitem/elementtextitemgroup.cpp
    trunk/sources/ui/dynamicelementtextmodel.cpp
    trunk/sources/ui/inditextpropertieswidget.cpp

Modified: trunk/sources/qetgraphicsitem/conductor.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/conductor.cpp	2019-03-08 10:27:33 UTC (rev 5764)
+++ trunk/sources/qetgraphicsitem/conductor.cpp	2019-03-08 11:53:27 UTC (rev 5765)
@@ -1515,7 +1515,9 @@
 	}
 
 	m_text_item->setPlainText(m_properties.text);
-	m_text_item->setFontSize(m_properties.text_size);
+	QFont font = m_text_item->font();
+	font.setPointSize(m_properties.text_size);
+	m_text_item->setFont(font);
 
 	if (m_properties.type != ConductorProperties::Multi)
 		m_text_item->setVisible(false);

Modified: trunk/sources/qetgraphicsitem/diagramtextitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/diagramtextitem.cpp	2019-03-08 10:27:33 UTC (rev 5764)
+++ trunk/sources/qetgraphicsitem/diagramtextitem.cpp	2019-03-08 11:53:27 UTC (rev 5765)
@@ -150,21 +150,6 @@
 	return(local_movement_point - local_origin);
 }
 
-void DiagramTextItem::setFontSize(int s)
-{
-	prepareAlignment();
-	QFont font_ = font();
-	font_.setPointSize(s);
-    setFont(font_);
-	finishAlignment();
-	emit fontSizeChanged(s);
-}
-
-int DiagramTextItem::fontSize() const
-{
-	return font().pointSize();
-}
-
 void DiagramTextItem::setFont(const QFont &font)
 {
 	if (this->font() == font) {

Modified: trunk/sources/qetgraphicsitem/diagramtextitem.h
===================================================================
--- trunk/sources/qetgraphicsitem/diagramtextitem.h	2019-03-08 10:27:33 UTC (rev 5764)
+++ trunk/sources/qetgraphicsitem/diagramtextitem.h	2019-03-08 11:53:27 UTC (rev 5765)
@@ -34,7 +34,6 @@
 {
 	Q_OBJECT
     
-    Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
     Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
 	Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
 	Q_PROPERTY(QString plainText READ toPlainText WRITE setPlainText)
@@ -42,7 +41,6 @@
 	
 	
 	signals:
-		void fontSizeChanged(int size);
 		void colorChanged(QColor color);
 		void alignmentChanged(Qt::Alignment alignment);
 		void textEdited(const QString &old_str, const QString &new_str);
@@ -69,9 +67,6 @@
 		QPointF mapMovementToParent   (const QPointF &) const;
 		QPointF mapMovementFromParent (const QPointF &) const;
 
-		void setFontSize(int s);
-        int fontSize()const;
-
 		void setFont(const QFont &font);
         
         void setColor(const QColor& color);

Modified: trunk/sources/qetgraphicsitem/element.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/element.cpp	2019-03-08 10:27:33 UTC (rev 5764)
+++ trunk/sources/qetgraphicsitem/element.cpp	2019-03-08 11:53:27 UTC (rev 5765)
@@ -511,7 +511,9 @@
 	{
 		DynamicElementTextItem *deti = new DynamicElementTextItem(this);
 		deti->setText(dom_element.attribute("text", "_"));
-		deti->setFontSize(dom_element.attribute("size", QString::number(9)).toInt());
+		QFont font = deti->font();
+		font.setPointSize(dom_element.attribute("size", QString::number(9)).toInt());
+		deti->setFont(font);
 		deti->setRotation(dom_element.attribute("rotation", QString::number(0)).toDouble());
 
 		if(dom_element.attribute("tagg", "none") != "none")
@@ -903,7 +905,9 @@
 							comment_text = new DynamicElementTextItem(this);
 							comment_text->setTextFrom(DynamicElementTextItem::ElementInfo);
 							comment_text->setInfoName("comment");
-							comment_text->setFontSize(6);
+							QFont font = comment_text->font();
+							font.setPointSize(6);
+							comment_text->setFont(font);
 							comment_text->setFrame(true);
 							if(comment_text->toPlainText().count() > 17)
 								comment_text->setTextWidth(80);
@@ -922,7 +926,9 @@
 							location_text = new DynamicElementTextItem(this);
 							location_text->setTextFrom(DynamicElementTextItem::ElementInfo);
 							location_text->setInfoName("location");
-							location_text->setFontSize(6);
+							QFont font = location_text->font();
+							font.setPointSize(6);
+							location_text->setFont(font);
 							if(location_text->toPlainText().count() > 17)
 								location_text->setTextWidth(80);
 							location_text->setPos(deti->x(), deti->y()+20); //+20 is arbitrary, location_text must be below deti and comment
@@ -966,7 +972,9 @@
 					comment_text = new DynamicElementTextItem(this);
 					comment_text->setTextFrom(DynamicElementTextItem::ElementInfo);
 					comment_text->setInfoName("comment");
-					comment_text->setFontSize(6);
+					QFont font = comment_text->font();
+					font.setPointSize(6);
+					comment_text->setFont(font);
 					comment_text->setFrame(true);
 					comment_text->setTextWidth(80);
 					addDynamicTextItem(comment_text);
@@ -978,7 +986,9 @@
 					location_text = new DynamicElementTextItem(this);
 					location_text->setTextFrom(DynamicElementTextItem::ElementInfo);
 					location_text->setInfoName("location");
-					location_text->setFontSize(6);
+					QFont font = location_text->font();
+					font.setPointSize(6);
+					location_text->setFont(font);
 					location_text->setTextWidth(80);
 					if(comment_text)
 						location_text->setPos(comment_text->x(), comment_text->y()+10); //+10 is arbitrary, location_text must be below the comment

Modified: trunk/sources/qetgraphicsitem/elementtextitemgroup.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/elementtextitemgroup.cpp	2019-03-08 10:27:33 UTC (rev 5764)
+++ trunk/sources/qetgraphicsitem/elementtextitemgroup.cpp	2019-03-08 11:53:27 UTC (rev 5765)
@@ -67,7 +67,7 @@
 		updateAlignment();
 		
 		DynamicElementTextItem *deti = qgraphicsitem_cast<DynamicElementTextItem *>(item);
-		connect(deti, &DynamicElementTextItem::fontSizeChanged,      this, &ElementTextItemGroup::updateAlignment);
+		connect(deti, &DynamicElementTextItem::fontChanged,      this, &ElementTextItemGroup::updateAlignment);
 		connect(deti, &DynamicElementTextItem::textChanged,          this, &ElementTextItemGroup::updateAlignment);
 		connect(deti, &DynamicElementTextItem::textFromChanged,      this, &ElementTextItemGroup::updateAlignment);
 		connect(deti, &DynamicElementTextItem::infoNameChanged,      this, &ElementTextItemGroup::updateAlignment);
@@ -98,7 +98,7 @@
 	
 	if(DynamicElementTextItem *deti = qgraphicsitem_cast<DynamicElementTextItem *>(item))
 	{
-		disconnect(deti, &DynamicElementTextItem::fontSizeChanged,      this, &ElementTextItemGroup::updateAlignment);
+		disconnect(deti, &DynamicElementTextItem::fontChanged,      this, &ElementTextItemGroup::updateAlignment);
 		disconnect(deti, &DynamicElementTextItem::textChanged,          this, &ElementTextItemGroup::updateAlignment);
 		disconnect(deti, &DynamicElementTextItem::textFromChanged,      this, &ElementTextItemGroup::updateAlignment);
 		disconnect(deti, &DynamicElementTextItem::infoNameChanged,      this, &ElementTextItemGroup::updateAlignment);
@@ -453,11 +453,11 @@
 	}
 	if(m_frame)
 	{		
-		int font_size = 1;
+		qreal font_size = 1;
 		QRectF rect;
 		for(DynamicElementTextItem *deti : this->texts())
 		{
-			font_size = std::max(font_size, deti->fontSize());
+			font_size = std::max(font_size, deti->font().pointSizeF());
 			rect = rect.united(mapFromItem(deti, deti->frameRect()).boundingRect());
 		}
 		
@@ -465,7 +465,7 @@
 		qreal w=0.3;
 		if (font_size >= 5)
 		{
-			w = (qreal)font_size*0.1;
+			w = font_size*0.1;
 			if(w > 2.5)
 				w = 2.5;
 		}
@@ -477,7 +477,7 @@
 		painter->setRenderHint(QPainter::Antialiasing);
 		
 			//Adjust the rounding of the rectangle according to the size of the font
-		qreal ro = (qreal)font_size/3;
+		qreal ro = font_size/3;
 		painter->drawRoundedRect(rect, ro, ro);
 		painter->restore();
 	}

Modified: trunk/sources/ui/dynamicelementtextmodel.cpp
===================================================================
--- trunk/sources/ui/dynamicelementtextmodel.cpp	2019-03-08 10:27:33 UTC (rev 5764)
+++ trunk/sources/ui/dynamicelementtextmodel.cpp	2019-03-08 11:53:27 UTC (rev 5765)
@@ -488,8 +488,9 @@
 	int fs = text_qsi->child(size_txt_row,1)->data(Qt::EditRole).toInt();
 	if (fs != deti->font().pointSize())
 	{
-		QPropertyUndoCommand *quc = new QPropertyUndoCommand(deti, "fontSize", QVariant(deti->font().pointSize()), QVariant(fs), undo);
-		quc->setAnimated(true, false);
+		QFont font = deti->font();
+		font.setPointSize(fs);
+		QPropertyUndoCommand *quc = new QPropertyUndoCommand(deti, "font", QVariant(deti->font()), QVariant(font), undo);
 		quc->setText(tr("Modifier la taille d'un texte d'élément"));
 	}
 

Modified: trunk/sources/ui/inditextpropertieswidget.cpp
===================================================================
--- trunk/sources/ui/inditextpropertieswidget.cpp	2019-03-08 10:27:33 UTC (rev 5764)
+++ trunk/sources/ui/inditextpropertieswidget.cpp	2019-03-08 11:53:27 UTC (rev 5765)
@@ -76,7 +76,7 @@
 	m_connect_list << connect(m_text.data(), &IndependentTextItem::xChanged, this, &IndiTextPropertiesWidget::updateUi);
 	m_connect_list << connect(m_text.data(), &IndependentTextItem::yChanged, this, &IndiTextPropertiesWidget::updateUi);
 	m_connect_list << connect(m_text.data(), &IndependentTextItem::rotationChanged, this, &IndiTextPropertiesWidget::updateUi);
-	m_connect_list << connect(m_text.data(), &IndependentTextItem::fontSizeChanged, this, &IndiTextPropertiesWidget::updateUi);
+	m_connect_list << connect(m_text.data(), &IndependentTextItem::fontChanged, this, &IndiTextPropertiesWidget::updateUi);
 	m_connect_list << connect(m_text.data(), &IndependentTextItem::textEdited, this, &IndiTextPropertiesWidget::updateUi);
 
 	updateUi();
@@ -192,9 +192,10 @@
 				undo = new QPropertyUndoCommand(m_text.data(), "plainText", m_text->toPlainText(), ui->m_line_edit->text());
 				undo->setText(tr("Modifier un champ texte"));
 			}
-			if (ui->m_size_sb->value() != m_text->fontSize()) {
-				undo = new QPropertyUndoCommand(m_text.data(), "fontSize", m_text->fontSize(), ui->m_size_sb->value());
-				undo->setAnimated(true, false);
+			if (ui->m_size_sb->value() != m_text->font().pointSize()) {
+				QFont font = m_text->font();
+				font.setPointSize(ui->m_size_sb->value());
+				undo = new QPropertyUndoCommand(m_text.data(), "font", m_text->font(), font);
 				undo->setText(tr("Modifier la taille d'un champ texte"));
 			}
 			
@@ -206,13 +207,13 @@
 			bool size_equal = true;
 			bool angle_equal = true;
 			qreal rotation_ = m_text_list.first()->rotation();
-			int size_ = m_text_list.first()->fontSize();
+			int size_ = m_text_list.first()->font().pointSize();
 			for (QPointer<IndependentTextItem> piti : m_text_list)
 			{
 				if (piti->rotation() != rotation_) {
 					angle_equal = false;
 				}
-				if (piti->fontSize() != size_) {
+				if (piti->font().pointSize() != size_) {
 					size_equal = false;
 				}
 			}
@@ -242,7 +243,9 @@
 						if (!parent_undo) {
 							parent_undo = new QUndoCommand(tr("Modifier la taille de plusieurs champs texte"));
 						}
-						QPropertyUndoCommand *qpuc = new QPropertyUndoCommand(piti.data(), "fontSize", QVariant(piti->fontSize()), QVariant(ui->m_size_sb->value()), parent_undo);
+						QFont font = piti->font();
+						font.setPointSize(ui->m_size_sb->value());
+						QPropertyUndoCommand *qpuc = new QPropertyUndoCommand(piti.data(), "font", QVariant(piti->font()), QVariant(font), parent_undo);
 						qpuc->setAnimated(true, false);
 					}
 				}
@@ -266,8 +269,11 @@
 		if (ui->m_line_edit->text() != m_text->toPlainText()) {
 			new ChangeDiagramTextCommand(m_text.data(), m_text->toHtml(), ui->m_line_edit->text(), undo);
 		}
-		if (ui->m_size_sb->value() != m_text->fontSize()) {
-			new QPropertyUndoCommand(m_text.data(), "fontSize", m_text->fontSize(), ui->m_size_sb->value(), undo);
+		if (ui->m_size_sb->value() != m_text->font().pointSize())
+		{
+			QFont font = m_text->font();
+			font.setPointSize(ui->m_size_sb->value());
+			new QPropertyUndoCommand(m_text.data(), "font", m_text->font(), font, undo);
 		}
 		
 		if (undo->childCount()) {
@@ -329,7 +335,7 @@
 		ui->m_y_sb->setValue(m_text->pos().y());
 		ui->m_line_edit->setText(m_text->toPlainText());
 		ui->m_angle_sb->setValue(m_text->rotation());
-		ui->m_size_sb->setValue(m_text->fontSize());
+		ui->m_size_sb->setValue(m_text->font().pointSize());
 		
 		ui->m_line_edit->setDisabled(m_text->isHtml() ? true : false);
 		ui->m_size_sb->setDisabled(m_text->isHtml() ? true : false);
@@ -341,13 +347,13 @@
 		bool size_equal = true;
 		bool angle_equal = true;
 		qreal rotation_ = m_text_list.first()->rotation();
-		int size_ = m_text_list.first()->fontSize();
+		int size_ = m_text_list.first()->font().pointSize();
 		for (QPointer<IndependentTextItem> piti : m_text_list)
 		{
 			if (piti->rotation() != rotation_) {
 				angle_equal = false;
 			}
-			if (piti->fontSize() != size_) {
+			if (piti->font().pointSize() != size_) {
 				size_equal = false;
 			}
 		}


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