From 1ce608e7dfe553257b7fcb2ee6ed760f9df0dc3c Mon Sep 17 00:00:00 2001 From: blacksun Date: Wed, 2 Apr 2014 17:36:40 +0000 Subject: [PATCH] cross ref item: don't show postion of element 'power'. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2959 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/qetgraphicsitem/crossrefitem.cpp | 5 +++-- sources/qetgraphicsitem/masterelement.cpp | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/sources/qetgraphicsitem/crossrefitem.cpp b/sources/qetgraphicsitem/crossrefitem.cpp index cc3667aa7..a17ad2c22 100644 --- a/sources/qetgraphicsitem/crossrefitem.cpp +++ b/sources/qetgraphicsitem/crossrefitem.cpp @@ -88,8 +88,8 @@ void CrossRefItem::updateLabel() { //draw the cross QRectF br = boundingRect(); - qp.drawLine(br.width()/2, 0, br.width()/2, br.height() - text_rect_.height()); //vertical line - qp.drawLine(br.width()/2-25, header, br.width()/2+25, header); //horizontal line + qp.drawLine(br.width()/2, 0, br.width()/2, br.height() - text_rect_.height()); //vertical line + qp.drawLine(br.width()/2-(crossWidth/2), header, br.width()/2+(crossWidth/2), header); //horizontal line //draw the symbolic NO qreal xoffset = br.width()/2 - 25; @@ -277,6 +277,7 @@ void CrossRefItem::fillCrossRef(QPainter &painter) { //find each no and nc of connected element to element_ foreach (Element *elmt, element_->linkedElements()) { + if (elmt->kindInformations()["type"].toString() == "power") continue; QString state = elmt->kindInformations()["state"].toString(); if (state == "NO") NO_list << elmt; else if (state == "NC") NC_list << elmt; diff --git a/sources/qetgraphicsitem/masterelement.cpp b/sources/qetgraphicsitem/masterelement.cpp index 71aa72558..3eebe7c20 100644 --- a/sources/qetgraphicsitem/masterelement.cpp +++ b/sources/qetgraphicsitem/masterelement.cpp @@ -53,10 +53,12 @@ void MasterElement::linkToElement(Element *elmt) { if (elmt->linkType() == Slave && !connected_elements.contains(elmt)) { connected_elements << elmt; elmt->linkToElement(this); - //create cross ref item if not yet - if (!cri_) cri_ = new CrossRefItem(this, this); - connect(elmt, SIGNAL(positionChange(QPointF)), cri_, SLOT(updateLabel())); - cri_->updateLabel(); + + if (elmt->kindInformations()["type"].toString() != "power") { + if (!cri_) cri_ = new CrossRefItem(this, this); //create cross ref item if not yet + connect(elmt, SIGNAL(positionChange(QPointF)), cri_, SLOT(updateLabel())); + cri_->updateLabel(); + } } } @@ -85,7 +87,12 @@ void MasterElement::unlinkElement(Element *elmt) { elmt->unlinkElement(this); //update the graphics cross ref disconnect(elmt, SIGNAL(positionChange(QPointF)), cri_, SLOT(updateLabel())); - if (isFree()) { + + bool delete_cri = true; + foreach(Element *elmt, linkedElements()) + if (elmt->kindInformations()["type"].toString() != "power") delete_cri = false; + + if (delete_cri) { delete cri_; cri_ = 0; }