bug fix: cross ref item have wrong behavior when rotate is master. (thanks mmiacca)

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2984 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2014-04-12 01:26:19 +00:00
parent c7aaf5b509
commit c7fe3f583b
3 changed files with 14 additions and 11 deletions

View File

@@ -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(Element *elmt, QetGraphicsItem *parent) :
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::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
*/
void CrossRefItem::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
element_->setHighlighted(true);
QetGraphicsItem::mouseMoveEvent(e);
QGraphicsObject::mouseMoveEvent(e);
}
/**
@@ -199,7 +198,7 @@ void CrossRefItem::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
*/
void CrossRefItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
element_->setHighlighted(false);
QetGraphicsItem::mouseReleaseEvent(e);
QGraphicsObject::mouseReleaseEvent(e);
}
/**

View File

@@ -29,13 +29,13 @@ class element;
* 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;

View File

@@ -55,7 +55,10 @@ void MasterElement::linkToElement(Element *elmt) {
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 @@ void MasterElement::unlinkElement(Element *elmt) {
if (elmt->kindInformations()["type"].toString() != "power") delete_cri = false;
if (delete_cri) {
diagram()->removeItem(cri_);
delete cri_;
cri_ = 0;
}