[qet] [2897] Basic Shape: qgraphicsitem_cast<> instead of dynamic_cast |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 2897
Author: abhishekm71
Date: 2014-03-02 14:49:11 +0100 (Sun, 02 Mar 2014)
Log Message:
-----------
Basic Shape: qgraphicsitem_cast<> instead of dynamic_cast
Modified Paths:
--------------
trunk/sources/diagram.cpp
trunk/sources/diagramview.cpp
trunk/sources/exportdialog.cpp
trunk/sources/qetgraphicsitem/qetshapeitem.h
Modified: trunk/sources/diagram.cpp
===================================================================
--- trunk/sources/diagram.cpp 2014-03-02 11:15:59 UTC (rev 2896)
+++ trunk/sources/diagram.cpp 2014-03-02 13:49:11 UTC (rev 2897)
@@ -368,7 +368,7 @@
} else if (DiagramImageItem *dii = qgraphicsitem_cast<DiagramImageItem *>(qgi)) {
if (whole_content) list_images << dii;
else if (dii -> isSelected()) list_images << dii;
- } else if (QetShapeItem *dsi = dynamic_cast<QetShapeItem *>(qgi)) {
+ } else if (QetShapeItem *dsi = qgraphicsitem_cast<QetShapeItem *>(qgi)) {
if (whole_content) list_shapes << dsi;
else if (dsi -> isSelected()) list_shapes << dsi;
}
Modified: trunk/sources/diagramview.cpp
===================================================================
--- trunk/sources/diagramview.cpp 2014-03-02 11:15:59 UTC (rev 2896)
+++ trunk/sources/diagramview.cpp 2014-03-02 13:49:11 UTC (rev 2897)
@@ -717,7 +717,7 @@
if (
qgraphicsitem_cast<Element *>(qgi) ||
qgraphicsitem_cast<IndependentTextItem *>(qgi) ||
- dynamic_cast<QetShapeItem *>(qgi) ||
+ qgraphicsitem_cast<QetShapeItem *>(qgi) ||
qgraphicsitem_cast<DiagramImageItem *>(qgi)
) {
return(true);
@@ -736,7 +736,7 @@
qgraphicsitem_cast<Element *>(qgi) ||
qgraphicsitem_cast<Conductor *>(qgi) ||
qgraphicsitem_cast<IndependentTextItem *>(qgi) ||
- dynamic_cast<QetShapeItem *>(qgi) ||
+ qgraphicsitem_cast<QetShapeItem *>(qgi) ||
qgraphicsitem_cast<DiagramImageItem *>(qgi)
) {
return(true);
Modified: trunk/sources/exportdialog.cpp
===================================================================
--- trunk/sources/exportdialog.cpp 2014-03-02 11:15:59 UTC (rev 2896)
+++ trunk/sources/exportdialog.cpp 2014-03-02 13:49:11 UTC (rev 2897)
@@ -481,7 +481,7 @@
list_texts << iti;
} else if (DiagramImageItem *dii = qgraphicsitem_cast<DiagramImageItem *>(qgi)) {
list_images << dii;
- } else if (QetShapeItem *dii = dynamic_cast<QetShapeItem *>(qgi)) {
+ } else if (QetShapeItem *dii = qgraphicsitem_cast<QetShapeItem *>(qgi)) {
if (dii -> getType() == QetShapeItem::Line && dii -> getLine()) {
list_lines << dii -> getLine();
} else if (dii -> getType() == QetShapeItem::Rectangle && dii -> getRectangle()) {
Modified: trunk/sources/qetgraphicsitem/qetshapeitem.h
===================================================================
--- trunk/sources/qetgraphicsitem/qetshapeitem.h 2014-03-02 11:15:59 UTC (rev 2896)
+++ trunk/sources/qetgraphicsitem/qetshapeitem.h 2014-03-02 13:49:11 UTC (rev 2897)
@@ -16,6 +16,19 @@
QetShapeItem(QPointF, QPointF = QPointF(0,0), ShapeType = Line, bool lineAngle = false, QGraphicsItem *parent = 0);
virtual ~QetShapeItem();
+ // attributes
+ public:
+ enum { Type = UserType + 1008 };
+
+ // methods
+ public:
+ /**
+ Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a
+ QetShapeItem
+ @return the QGraphicsItem type
+ */
+ virtual int type() const { return Type; }
+
void setStyle(Qt::PenStyle);
Qt::PenStyle getStyle() const { return _shapeStyle; }
ShapeType getType() const { return _shapeType; }