[qet] [4077] Minor change

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


Revision: 4077
Author:   blacksun
Date:     2015-07-27 23:47:41 +0200 (Mon, 27 Jul 2015)
Log Message:
-----------
Minor change

Modified Paths:
--------------
    trunk/sources/dvevent/dveventaddshape.cpp
    trunk/sources/qetdiagrameditor.cpp
    trunk/sources/qetgraphicsitem/qetshapeitem.cpp
    trunk/sources/qetgraphicsitem/qetshapeitem.h

Modified: trunk/sources/dvevent/dveventaddshape.cpp
===================================================================
--- trunk/sources/dvevent/dveventaddshape.cpp	2015-07-27 19:25:54 UTC (rev 4076)
+++ trunk/sources/dvevent/dveventaddshape.cpp	2015-07-27 21:47:41 UTC (rev 4077)
@@ -80,7 +80,7 @@
 		}
 
 			//If current item isn't a polyline, add it with an undo command
-		if (m_shape_type != QetShapeItem::Polyline)
+		if (m_shape_type != QetShapeItem::Polygon)
 		{
 			m_shape_item -> setP2 (pos);
 			m_diagram -> undoStack().push (new AddItemCommand<QetShapeItem *> (m_shape_item, m_diagram));
@@ -139,7 +139,7 @@
 		if (m_shape_item)
 		{
 				//Shape is a polyline and have three points or more we just remove the last point
-			if (m_shape_type == QetShapeItem::Polyline && (m_shape_item -> pointsCount() >= 3) )
+			if (m_shape_type == QetShapeItem::Polygon && (m_shape_item -> pointsCount() >= 3) )
 			{
 				m_shape_item -> removePoints();
 
@@ -175,7 +175,7 @@
 bool DVEventAddShape::mouseDoubleClickEvent(QMouseEvent *event)
 {
 		//If current item is a polyline, add it with an undo command
-	if (m_shape_item && m_shape_type == QetShapeItem::Polyline && event -> button() == Qt::LeftButton)
+	if (m_shape_item && m_shape_type == QetShapeItem::Polygon && event -> button() == Qt::LeftButton)
 	{
 			//<double clic is used to finish polyline, but they also add two points at the same pos
 			//<(double clic is a double press event), so we remove the last point of polyline

Modified: trunk/sources/qetdiagrameditor.cpp
===================================================================
--- trunk/sources/qetdiagrameditor.cpp	2015-07-27 19:25:54 UTC (rev 4076)
+++ trunk/sources/qetdiagrameditor.cpp	2015-07-27 21:47:41 UTC (rev 4077)
@@ -1636,7 +1636,7 @@
  * add polyline to current diagram
  */
 void QETDiagramEditor::slot_addPolyline() {
-	if (DiagramView *dv = currentDiagram()) dv -> setEventInterface(new DVEventAddShape(dv, QetShapeItem::Polyline));
+	if (DiagramView *dv = currentDiagram()) dv -> setEventInterface(new DVEventAddShape(dv, QetShapeItem::Polygon));
 }
 
 /**

Modified: trunk/sources/qetgraphicsitem/qetshapeitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/qetshapeitem.cpp	2015-07-27 19:25:54 UTC (rev 4076)
+++ trunk/sources/qetgraphicsitem/qetshapeitem.cpp	2015-07-27 21:47:41 UTC (rev 4077)
@@ -41,7 +41,7 @@
 	m_mouse_grab_handler(false),
 	m_handler(10)
 {
-	if (type == Polyline) m_polygon << m_P1 << m_P2;
+	if (type == Polygon) m_polygon << m_P1 << m_P2;
 	setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
 	setAcceptHoverEvents(true);
 }
@@ -69,7 +69,7 @@
  */
 void QetShapeItem::setP2(const QPointF &P2)
 {
-	if (m_shapeType == Polyline && m_polygon.last() != P2)
+	if (m_shapeType == Polygon && m_polygon.last() != P2)
 	{
 		prepareGeometryChange();
 		m_polygon.replace(m_polygon.size()-1, P2);
@@ -123,7 +123,7 @@
  */
 bool QetShapeItem::setPolygon(const QPolygonF &polygon)
 {
-	if (Q_UNLIKELY(m_shapeType != Polyline)) return false;
+	if (Q_UNLIKELY(m_shapeType != Polygon)) return false;
 	prepareGeometryChange();
 	m_polygon = polygon;
 	return true;
@@ -193,7 +193,7 @@
 						path.lineTo(m_P2);                   break;
 		case Rectangle: path.addRect(QRectF(m_P1, m_P2));    break;
 		case Ellipse:   path.addEllipse(QRectF(m_P1, m_P2)); break;
-		case Polyline:  path.addPolygon(m_polygon);          break;
+		case Polygon:  path.addPolygon(m_polygon);          break;
 		default:        Q_ASSERT(false);                     break;
 	}
 
@@ -275,8 +275,8 @@
 				m_handler.drawHandler(painter, m_handler.pointsForRect(QRectF(m_P1, m_P2)));
 			break;
 
-		case Polyline:
-			painter->drawPolyline(m_polygon);
+		case Polygon:
+			painter->drawPolygon(m_polygon);
 			if (isSelected())
 				m_handler.drawHandler(painter, m_polygon);
 			break;
@@ -319,7 +319,7 @@
 			case Line:      vector << m_P1 << m_P2;                               break;
 			case Rectangle: vector = m_handler.pointsForRect(QRectF(m_P1, m_P2)); break;
 			case Ellipse:   vector = m_handler.pointsForRect(QRectF(m_P1, m_P2)); break;
-			case Polyline:  vector = m_polygon;                                   break;
+			case Polygon:  vector = m_polygon;                                   break;
 		}
 
 		m_vector_index = m_handler.pointIsHoverHandler(event->pos(), vector);
@@ -360,7 +360,7 @@
 			case Rectangle: setRect(m_handler.rectForPosAtIndex(QRectF(m_P1, m_P2), new_pos, m_vector_index)); break;
 			case Ellipse:   setRect(m_handler.rectForPosAtIndex(QRectF(m_P1, m_P2), new_pos, m_vector_index)); break;
 
-			case Polyline:
+			case Polygon:
 				prepareGeometryChange();
 				m_polygon.replace(m_vector_index, new_pos);
 				break;
@@ -391,11 +391,11 @@
 					case Line:      undo = new QPropertyUndoCommand(this, "line",QLineF(m_old_P1, m_old_P2), QLineF(m_P1, m_P2)); break;
 					case Rectangle: undo = new QPropertyUndoCommand(this, "rect",QRectF(m_old_P1, m_old_P2), QRectF(m_P1, m_P2)); break;
 					case Ellipse:   undo = new QPropertyUndoCommand(this, "rect",QRectF(m_old_P1, m_old_P2), QRectF(m_P1, m_P2)); break;
-					case Polyline: break;
+					case Polygon: break;
 				}
 				if (undo) undo->enableAnimation();
 			}
-			else if (m_shapeType == Polyline && (m_polygon != m_old_polygon))
+			else if (m_shapeType == Polygon && (m_polygon != m_old_polygon))
 				undo = new QPropertyUndoCommand(this, "polygon", m_old_polygon, m_polygon);
 
 			if(undo)
@@ -431,19 +431,17 @@
 			case 0: m_shapeType = Line;      break;
 			case 1: m_shapeType = Rectangle; break;
 			case 2: m_shapeType = Ellipse;   break;
-			case 3: m_shapeType = Polyline;  break;
+			case 3: m_shapeType = Polygon;  break;
 		}
 	}
 		//For version after N°4075, shape is stored with a string
 	else
 	{
-		if      (type == "Line")      m_shapeType = Line;
-		else if (type == "Rectangle") m_shapeType = Rectangle;
-		else if (type == "Ellipse")   m_shapeType = Ellipse;
-		else if (type == "polygon")   m_shapeType = Polyline;
+		QMetaEnum me = metaObject()->enumerator(metaObject()->indexOfEnumerator("ShapeType"));
+		m_shapeType = QetShapeItem::ShapeType(me.keysToValue(type.toStdString().data()));
 	}
 
-	if (m_shapeType != Polyline)
+	if (m_shapeType != Polygon)
 	{
 		m_P1.setX(e.attribute("x1", 0).toDouble());
 		m_P1.setY(e.attribute("y1", 0).toDouble());
@@ -468,18 +466,11 @@
 	QDomElement result = document.createElement("shape");
 
 		//write some attribute
-	QString type;
-	switch(m_shapeType)
-	{
-		case Line:      type = "Line";      break;
-		case Rectangle: type = "Rectangle"; break;
-		case Ellipse:   type = "Ellipse";   break;
-		case Polyline:  type = "polygon";   break;
-	}
-	result.setAttribute("type", type);
+	QMetaEnum me = metaObject()->enumerator(metaObject()->indexOfEnumerator("ShapeType"));
+	result.setAttribute("type", me.valueToKey(m_shapeType));
 	result.setAttribute("style", QString::number(m_shapeStyle));
 	result.setAttribute("is_movable", bool(is_movable_));
-	if (m_shapeType != Polyline)
+	if (m_shapeType != Polygon)
 	{
 		result.setAttribute("x1", QString::number(mapToScene(m_P1).x()));
 		result.setAttribute("y1", QString::number(mapToScene(m_P1).y()));
@@ -541,7 +532,7 @@
 		case Line:	    return tr("une ligne");
 		case Rectangle:	return tr("un rectangle");
 		case Ellipse:	return tr("une éllipse");
-		case Polyline:	return tr("une polyligne");
+		case Polygon:	return tr("une polyligne");
 		default:	    return tr("une shape");
 	}
 }

Modified: trunk/sources/qetgraphicsitem/qetshapeitem.h
===================================================================
--- trunk/sources/qetgraphicsitem/qetshapeitem.h	2015-07-27 19:25:54 UTC (rev 4076)
+++ trunk/sources/qetgraphicsitem/qetshapeitem.h	2015-07-27 21:47:41 UTC (rev 4077)
@@ -45,7 +45,7 @@
 		enum ShapeType {Line	  =1,
 						Rectangle =2,
 						Ellipse	  =4,
-						Polyline  =8 };
+						Polygon  =8 };
 
 		enum { Type = UserType + 1008 };
 


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