cross ref item: bugfix

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3035 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2014-04-28 19:00:49 +00:00
parent f9aaff37a2
commit 1cd9c4b28c
4 changed files with 33 additions and 60 deletions

View File

@@ -40,7 +40,7 @@ CrossRefItem::CrossRefItem(Element *elmt, QGraphicsItem *parent) :
connect(elmt, SIGNAL(positionChange(QPointF)), this, SLOT(autoPos())); connect(elmt, SIGNAL(positionChange(QPointF)), this, SLOT(autoPos()));
connect(elmt, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel())); connect(elmt, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
connect(elmt->diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel())); connect(elmt->diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
connect(elmt->diagram(), SIGNAL(XRefPropertiesChanged(XRefProperties)), this, SLOT(updateLabel())); connect(elmt->diagram(), SIGNAL(XRefPropertiesChanged(XRefProperties)), this, SLOT(setProperties(XRefProperties)));
updateLabel(); updateLabel();
} }
@@ -52,6 +52,7 @@ CrossRefItem::~CrossRefItem() {
disconnect(m_element, SIGNAL(positionChange(QPointF)), this, SLOT(autoPos())); disconnect(m_element, SIGNAL(positionChange(QPointF)), this, SLOT(autoPos()));
disconnect(m_element, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel())); disconnect(m_element, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
disconnect(m_element->diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel())); disconnect(m_element->diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
disconnect(m_element->diagram(), SIGNAL(XRefPropertiesChanged(XRefProperties)), this, SLOT(setProperties(XRefProperties)));
} }
/** /**
@@ -70,6 +71,13 @@ QPainterPath CrossRefItem::shape() const{
return m_shape_path; return m_shape_path;
} }
void CrossRefItem::setProperties(XRefProperties xrp) {
if (m_properties != xrp) {
m_properties = xrp;
updateLabel();
}
}
/** /**
* @brief CrossRefItem::updateLabel * @brief CrossRefItem::updateLabel
* Update the content of the item * Update the content of the item

View File

@@ -56,6 +56,7 @@ class CrossRefItem : public QGraphicsObject
signals: signals:
public slots: public slots:
void setProperties (XRefProperties xrp);
void updateLabel(); void updateLabel();
void autoPos(); void autoPos();

View File

@@ -88,6 +88,8 @@ void MasterElement::unlinkElement(Element *elmt) {
if (connected_elements.contains(elmt)) { if (connected_elements.contains(elmt)) {
connected_elements.removeOne(elmt); connected_elements.removeOne(elmt);
elmt->unlinkElement(this); elmt->unlinkElement(this);
if (cri_) {
//update the graphics cross ref //update the graphics cross ref
disconnect(elmt, SIGNAL(positionChange(QPointF)), cri_, SLOT(updateLabel())); disconnect(elmt, SIGNAL(positionChange(QPointF)), cri_, SLOT(updateLabel()));
@@ -114,25 +116,7 @@ void MasterElement::unlinkElement(Element *elmt) {
} }
} }
} }
/**
* @brief MasterElement::itemChange
* Réimplemente the protected method item change
* This is used to make connection/disconnection when this item is added/removed from a diagram
* @return
*/
QVariant MasterElement::itemChange(GraphicsItemChange change, const QVariant &value) {
if (change == QGraphicsItem::ItemSceneChange) {
if (diagram())
disconnect(diagram(), SIGNAL(XRefPropertiesChanged(XRefProperties)), this, SLOT(reLink()));
} }
else if (change == QGraphicsItem::ItemSceneHasChanged) {
if (diagram())
connect(diagram(), SIGNAL(XRefPropertiesChanged(XRefProperties)), this, SLOT(reLink()));
}
return QetGraphicsItem::itemChange(change, value);
}
/** /**
* @brief MasterElement::updateLabel * @brief MasterElement::updateLabel
@@ -147,17 +131,3 @@ void MasterElement::updateLabel() {
setTaggedText("label", "_", false): setTaggedText("label", "_", false):
setTaggedText("label", label, true); setTaggedText("label", label, true);
} }
/**
* @brief MasterElement::reLink
* Relink all linked element.
* this method is notably used when xref properties changes
* for update the content of th e XRef
*/
void MasterElement::reLink() {
QList <Element *> elmt_list = linkedElements();
unlinkAllElements();
foreach (Element *elmt, elmt_list) {
linkToElement(elmt);
}
}

View File

@@ -32,17 +32,11 @@ class MasterElement : public CustomElement
virtual void unlinkAllElements(); virtual void unlinkAllElements();
virtual void unlinkElement(Element *elmt); virtual void unlinkElement(Element *elmt);
protected:
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
signals: signals:
public slots: public slots:
void updateLabel(); void updateLabel();
private slots:
void reLink();
private: private:
CrossRefItem *cri_; CrossRefItem *cri_;
}; };