[qet] qet/qet: [5279] clean some code

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


Revision: 5279
Author:   blacksun
Date:     2018-03-25 20:42:18 +0200 (Sun, 25 Mar 2018)
Log Message:
-----------
clean some code

Modified Paths:
--------------
    trunk/sources/exportdialog.cpp
    trunk/sources/qetgraphicsitem/conductor.cpp
    trunk/sources/qetgraphicsitem/diagramtextitem.cpp
    trunk/sources/qetgraphicsitem/diagramtextitem.h
    trunk/sources/qetgraphicsitem/independenttextitem.cpp
    trunk/sources/undocommand/rotateselectioncommand.cpp

Modified: trunk/sources/exportdialog.cpp
===================================================================
--- trunk/sources/exportdialog.cpp	2018-03-25 18:20:54 UTC (rev 5278)
+++ trunk/sources/exportdialog.cpp	2018-03-25 18:42:18 UTC (rev 5279)
@@ -599,7 +599,7 @@
 			qreal y = Createdxf::sheetHeight - (textItem -> pos().y() * Createdxf::yScale) - fontSize;
 			QStringList lines = textItem->toPlainText().split('\n');
 			foreach (QString line, lines) {
-				qreal angle = 360 - (textItem -> rotationAngle());
+				qreal angle = 360 - (textItem -> rotation());
 				if (line.size() > 0 && line != "_" )
 					Createdxf::drawText(file_path, line, x, y, fontSize, angle, 0 );
 
@@ -628,7 +628,7 @@
 		qreal y = Createdxf::sheetHeight - (dti -> pos().y() * Createdxf::yScale) - fontSize*1.05;
 		QStringList lines = dti -> toPlainText().split('\n');
 		foreach (QString line, lines) {
-			qreal angle = 360 - (dti -> rotationAngle());
+			qreal angle = 360 - (dti -> rotation());
 			if (line.size() > 0 && line != "_" )
 				Createdxf::drawText(file_path, line, x, y, fontSize, angle, 0);
 

Modified: trunk/sources/qetgraphicsitem/conductor.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/conductor.cpp	2018-03-25 18:20:54 UTC (rev 5278)
+++ trunk/sources/qetgraphicsitem/conductor.cpp	2018-03-25 18:42:18 UTC (rev 5279)
@@ -1278,8 +1278,8 @@
 		QPointF text_pos = posForText(rotation);
 
 		if (!m_text_item -> wasRotateByUser()) {
-			rotation == Qt::Vertical ? m_text_item -> setRotationAngle(m_properties.verti_rotate_text):
-									   m_text_item -> setRotationAngle(m_properties.horiz_rotate_text);
+			rotation == Qt::Vertical ? m_text_item -> setRotation(m_properties.verti_rotate_text):
+									   m_text_item -> setRotation(m_properties.horiz_rotate_text);
 		}
 
 		//Adjust the position of text if his rotation

Modified: trunk/sources/qetgraphicsitem/diagramtextitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/diagramtextitem.cpp	2018-03-25 18:20:54 UTC (rev 5278)
+++ trunk/sources/qetgraphicsitem/diagramtextitem.cpp	2018-03-25 18:42:18 UTC (rev 5279)
@@ -26,8 +26,7 @@
  * @param parent : parent item
  */
 DiagramTextItem::DiagramTextItem(QGraphicsItem *parent) :
-	QGraphicsTextItem(parent),
-	m_rotation_angle(0.0)
+	QGraphicsTextItem(parent)
 { build(); }
 
 /**
@@ -38,8 +37,7 @@
 DiagramTextItem::DiagramTextItem(const QString &text, QGraphicsItem *parent) :
 	QGraphicsTextItem(text, parent),
 	m_mouse_hover(false),
-	m_previous_html_text(text),
-	m_rotation_angle(0.0)
+	m_previous_html_text(text)
 { build(); }
 
 /**
@@ -77,37 +75,6 @@
 }
 
 /**
-	@return l'angle de rotation actuel de ce texte
-*/
-qreal DiagramTextItem::rotationAngle() const {
-	return(m_rotation_angle);
-}
-
-/**
-	Permet de tourner le texte a un angle donne de maniere absolue.
-	Un angle de 0 degres correspond a un texte horizontal non retourne.
-	@param rotation Nouvel angle de rotation de ce texte
-	@see applyRotation
-*/
-void DiagramTextItem::setRotationAngle(const qreal &rotation) {
-	qreal applied_rotation = QET::correctAngle(rotation);
-	applyRotation(applied_rotation - m_rotation_angle);
-	m_rotation_angle = applied_rotation;
-}
-
-/**
-	Permet de tourner le texte de maniere relative.
-	L'angle added_rotation est ajoute a l'orientation actuelle du texte.
-	@param added_rotation Angle a ajouter a la rotation actuelle
-	@see applyRotation
-*/
-void DiagramTextItem::rotateBy(const qreal &added_rotation) {
-	qreal applied_added_rotation = QET::correctAngle(added_rotation);
-	m_rotation_angle = QET::correctAngle(m_rotation_angle + applied_added_rotation);
-	applyRotation(applied_added_rotation);
-}
-
-/**
 	Traduit en coordonnees de la scene un mouvement / vecteur initialement
 	exprime en coordonnees locales.
 	@param movement Vecteur exprime en coordonnees locales

Modified: trunk/sources/qetgraphicsitem/diagramtextitem.h
===================================================================
--- trunk/sources/qetgraphicsitem/diagramtextitem.h	2018-03-25 18:20:54 UTC (rev 5278)
+++ trunk/sources/qetgraphicsitem/diagramtextitem.h	2018-03-25 18:42:18 UTC (rev 5279)
@@ -54,9 +54,6 @@
 		Diagram *diagram() const;
 		virtual void fromXml(const QDomElement &) = 0;
 		virtual QDomElement toXml(QDomDocument &) const;
-		qreal rotationAngle() const;
-		void setRotationAngle(const qreal &);
-		void rotateBy(const qreal &);
 		void edit();
 
 		QPointF mapMovementToScene    (const QPointF &) const;
@@ -100,7 +97,6 @@
 		QString m_previous_html_text,
 				m_previous_text;
 		
-		qreal m_rotation_angle;
 		QPointF m_mouse_to_origin_movement;
 };
 #endif

Modified: trunk/sources/qetgraphicsitem/independenttextitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/independenttextitem.cpp	2018-03-25 18:20:54 UTC (rev 5278)
+++ trunk/sources/qetgraphicsitem/independenttextitem.cpp	2018-03-25 18:42:18 UTC (rev 5279)
@@ -49,7 +49,7 @@
 void IndependentTextItem::fromXml(const QDomElement &e) {
 	setPos(e.attribute("x").toDouble(), e.attribute("y").toDouble());
 	setHtml(e.attribute("text"));
-	setRotationAngle(e.attribute("rotation").toDouble());
+	setRotation(e.attribute("rotation").toDouble());
 }
 
 /**

Modified: trunk/sources/undocommand/rotateselectioncommand.cpp
===================================================================
--- trunk/sources/undocommand/rotateselectioncommand.cpp	2018-03-25 18:20:54 UTC (rev 5278)
+++ trunk/sources/undocommand/rotateselectioncommand.cpp	2018-03-25 18:42:18 UTC (rev 5279)
@@ -24,6 +24,7 @@
 #include "diagramimageitem.h"
 #include "diagram.h"
 #include "conductor.h"
+#include "qet.h"
 
 #include <QGraphicsItem>
 
@@ -87,12 +88,12 @@
 				ConductorTextItem *cti = static_cast<ConductorTextItem *>(text.data());
 				cti->forceRotateByUser(m_rotate_by_user.value(text.data()));
 				if(cti->wasRotateByUser())
-					cti->rotateBy(-m_angle);
+					cti->setRotation(cti->rotation() - m_angle);
 				else
 					cti->parentConductor()->calculateTextItemPosition();
 			}
 			else
-				text.data()->rotateBy(-m_angle);
+				text.data()->setRotation(text.data()->rotation() - m_angle);
 		}
 	}
 	for(QPointer<DiagramImageItem> image : m_image)
@@ -123,7 +124,7 @@
 				m_rotate_by_user.insert(text.data(), cti->wasRotateByUser());
 				cti->forceRotateByUser(true);
 			}
-			text.data()->rotateBy(m_angle);
+			text.data()->setRotation(text.data()->rotation() + m_angle);
 		}
 	}
 	for(QPointer<DiagramImageItem> image : m_image)


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