[qet] [2984] bug fix: cross ref item have wrong behavior when rotate is master. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 2984
Author: blacksun
Date: 2014-04-12 03:26:19 +0200 (Sat, 12 Apr 2014)
Log Message:
-----------
bug fix: cross ref item have wrong behavior when rotate is master. (thanks mmiacca)
Modified Paths:
--------------
trunk/sources/qetgraphicsitem/crossrefitem.cpp
trunk/sources/qetgraphicsitem/crossrefitem.h
trunk/sources/qetgraphicsitem/masterelement.cpp
Modified: trunk/sources/qetgraphicsitem/crossrefitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/crossrefitem.cpp 2014-04-11 09:51:21 UTC (rev 2983)
+++ trunk/sources/qetgraphicsitem/crossrefitem.cpp 2014-04-12 01:26:19 UTC (rev 2984)
@@ -31,15 +31,14 @@
* @param elmt element to dispaly the cross ref
* @param parent parent QetGraphicsItem
*/
-CrossRefItem::CrossRefItem(Element *elmt, QetGraphicsItem *parent) :
- QetGraphicsItem(parent),
+CrossRefItem::CrossRefItem(Element *elmt, QGraphicsItem *parent) :
+ QGraphicsObject(parent),
element_ (elmt)
{
- snap_to_grid_=false;
- setFlags(QGraphicsItem::ItemIsSelectable|QGraphicsItem::ItemIsMovable);
+ setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable);
connect(elmt, SIGNAL(positionChange(QPointF)), this, SLOT(autoPos()));
connect(elmt, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
- connect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
+ connect(elmt->diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
updateLabel();
}
@@ -50,7 +49,7 @@
CrossRefItem::~CrossRefItem() {
disconnect(element_, SIGNAL(positionChange(QPointF)), this, SLOT(autoPos()));
disconnect(element_, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
- disconnect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
+ disconnect(element_->diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
}
/**
@@ -189,7 +188,7 @@
*/
void CrossRefItem::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
element_->setHighlighted(true);
- QetGraphicsItem::mouseMoveEvent(e);
+ QGraphicsObject::mouseMoveEvent(e);
}
/**
@@ -199,7 +198,7 @@
*/
void CrossRefItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
element_->setHighlighted(false);
- QetGraphicsItem::mouseReleaseEvent(e);
+ QGraphicsObject::mouseReleaseEvent(e);
}
/**
Modified: trunk/sources/qetgraphicsitem/crossrefitem.h
===================================================================
--- trunk/sources/qetgraphicsitem/crossrefitem.h 2014-04-11 09:51:21 UTC (rev 2983)
+++ trunk/sources/qetgraphicsitem/crossrefitem.h 2014-04-12 01:26:19 UTC (rev 2984)
@@ -29,13 +29,13 @@
* It's the responsability of the parent to informe displayed slave are moved,
* by calling the slot @updateLabel
*/
-class CrossRefItem : public QetGraphicsItem
+class CrossRefItem : public QGraphicsObject
{
Q_OBJECT
//Methods
public:
- explicit CrossRefItem(Element *elmt, QetGraphicsItem *parent = 0);
+ explicit CrossRefItem(Element *elmt, QGraphicsItem *parent = 0);
~CrossRefItem();
QRectF boundingRect() const;
Modified: trunk/sources/qetgraphicsitem/masterelement.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/masterelement.cpp 2014-04-11 09:51:21 UTC (rev 2983)
+++ trunk/sources/qetgraphicsitem/masterelement.cpp 2014-04-12 01:26:19 UTC (rev 2984)
@@ -55,7 +55,10 @@
elmt->linkToElement(this);
if (elmt->kindInformations()["type"].toString() != "power") {
- if (!cri_) cri_ = new CrossRefItem(this, this); //create cross ref item if not yet
+ if (!cri_) {
+ cri_ = new CrossRefItem(this); //create cross ref item if not yet
+ diagram()->addItem(cri_);
+ }
connect(elmt, SIGNAL(positionChange(QPointF)), cri_, SLOT(updateLabel()));
cri_->updateLabel();
}
@@ -93,6 +96,7 @@
if (elmt->kindInformations()["type"].toString() != "power") delete_cri = false;
if (delete_cri) {
+ diagram()->removeItem(cri_);
delete cri_;
cri_ = 0;
}