Improve signal of position changed, between linked elements

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3394 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2014-10-23 08:48:30 +00:00
parent 2a4d013994
commit e3cc8d449d
6 changed files with 24 additions and 20 deletions

View File

@@ -37,13 +37,14 @@ CrossRefItem::CrossRefItem(Element *elmt) :
m_element (elmt) m_element (elmt)
{ {
m_properties = elmt->diagram()->defaultXRefProperties(elmt->kindInformations()["type"].toString()); m_properties = elmt->diagram()->defaultXRefProperties(elmt->kindInformations()["type"].toString());
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()), this, SLOT(updateProperties())); connect(elmt -> diagram(), SIGNAL(XRefPropertiesChanged()), this, SLOT(updateProperties()));
//set specific behavior related to the parent item. //set specific behavior related to the parent item.
if(m_properties.snapTo() == XRefProperties::Bottom) { if(m_properties.snapTo() == XRefProperties::Bottom) {
connect(elmt, SIGNAL(positionChange(QPointF)), this, SLOT(autoPos())); connect(elmt, SIGNAL(yChanged()), this, SLOT(autoPos()));
connect(elmt, SIGNAL(rotationChanged()), this, SLOT(autoPos())); connect(elmt, SIGNAL(rotationChanged()), this, SLOT(autoPos()));
} else { } else {
setTextParent(); setTextParent();
@@ -57,7 +58,7 @@ CrossRefItem::CrossRefItem(Element *elmt) :
*/ */
CrossRefItem::~CrossRefItem() { CrossRefItem::~CrossRefItem() {
if(m_properties.snapTo() == XRefProperties::Bottom) { if(m_properties.snapTo() == XRefProperties::Bottom) {
disconnect(m_element, SIGNAL(positionChange(QPointF)), this, SLOT(autoPos())); disconnect(m_element, SIGNAL(yChanged()), this, SLOT(autoPos()));
disconnect(m_element, SIGNAL(rotationChanged()), this, SLOT(autoPos())); disconnect(m_element, SIGNAL(rotationChanged()), this, SLOT(autoPos()));
} }
disconnect(m_element, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel())); disconnect(m_element, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));

View File

@@ -56,7 +56,8 @@ void MasterElement::linkToElement(Element *elmt) {
elmt->linkToElement(this); elmt->linkToElement(this);
if (!cri_) cri_ = new CrossRefItem(this); //create cross ref item if not yet if (!cri_) cri_ = new CrossRefItem(this); //create cross ref item if not yet
connect(elmt, SIGNAL(positionChange(QPointF)), cri_, SLOT(updateLabel())); connect(elmt, SIGNAL(xChanged()), cri_, SLOT(updateLabel()));
connect(elmt, SIGNAL(yChanged()), cri_, SLOT(updateLabel()));
cri_->updateLabel(); cri_->updateLabel();
} }
} }
@@ -86,7 +87,8 @@ void MasterElement::unlinkElement(Element *elmt) {
elmt->unlinkElement(this); elmt->unlinkElement(this);
//update the graphics cross ref //update the graphics cross ref
disconnect(elmt, SIGNAL(positionChange(QPointF)), cri_, SLOT(updateLabel())); disconnect(elmt, SIGNAL(xChanged()), cri_, SLOT(updateLabel()));
disconnect(elmt, SIGNAL(yChanged()), cri_, SLOT(updateLabel()));
if (linkedElements().isEmpty()) { if (linkedElements().isEmpty()) {
delete cri_; delete cri_;

View File

@@ -29,8 +29,7 @@ QetGraphicsItem::QetGraphicsItem(QGraphicsItem *parent):
is_movable_(true), is_movable_(true),
first_move_(true), first_move_(true),
snap_to_grid_(true) snap_to_grid_(true)
{ {}
}
QetGraphicsItem::~QetGraphicsItem() QetGraphicsItem::~QetGraphicsItem()
{} {}
@@ -53,7 +52,6 @@ void QetGraphicsItem::setPos(const QPointF &p) {
if (pp == pos() || !is_movable_) return; if (pp == pos() || !is_movable_) return;
if (scene() && snap_to_grid_) { if (scene() && snap_to_grid_) {
QGraphicsItem::setPos(pp); QGraphicsItem::setPos(pp);
emit positionChange(pos());
} else QGraphicsItem::setPos(pp); } else QGraphicsItem::setPos(pp);
} }

View File

@@ -40,7 +40,6 @@ class QetGraphicsItem : public QGraphicsObject {
virtual QString name()const {return QString("");} virtual QString name()const {return QString("");}
signals: signals:
void positionChange(QPointF);
public slots: public slots:

View File

@@ -55,7 +55,8 @@ void ReportElement::linkToElement(Element * elmt) {
if ((elmt->linkType() == inverse_report) && i) { if ((elmt->linkType() == inverse_report) && i) {
unlinkAllElements(); unlinkAllElements();
connected_elements << elmt; connected_elements << elmt;
connect(elmt, SIGNAL(positionChange(QPointF)), this, SLOT(updateLabel())); connect(elmt, SIGNAL(xChanged()), this, SLOT(updateLabel()));
connect(elmt, SIGNAL(yChanged()), this, SLOT(updateLabel()));
connect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel())); connect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
updateLabel(); updateLabel();
elmt->linkToElement(this); elmt->linkToElement(this);
@@ -71,7 +72,8 @@ void ReportElement::unlinkAllElements(){
QList <Element *> tmp_elmt = connected_elements; QList <Element *> tmp_elmt = connected_elements;
foreach(Element *elmt, connected_elements) { foreach(Element *elmt, connected_elements) {
disconnect(elmt, SIGNAL(positionChange(QPointF)), this, SLOT(updateLabel())); disconnect(elmt, SIGNAL(xChanged()), this, SLOT(updateLabel()));
disconnect(elmt, SIGNAL(yChanged()), this, SLOT(updateLabel()));
disconnect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel())); disconnect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
} }
connected_elements.clear(); connected_elements.clear();

View File

@@ -56,7 +56,8 @@ void SlaveElement::linkToElement(Element *elmt) {
if(!isFree()) unlinkAllElements(); if(!isFree()) unlinkAllElements();
connected_elements << elmt; connected_elements << elmt;
updateLabel(); updateLabel();
connect(elmt, SIGNAL(positionChange(QPointF)), this, SLOT(updateLabel())); connect(elmt, SIGNAL(xChanged()), this, SLOT(updateLabel()));
connect(elmt, SIGNAL(yChanged()), this, SLOT(updateLabel()));
connect(elmt, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel())); connect(elmt, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
elmt->linkToElement(this); elmt->linkToElement(this);
} }
@@ -84,7 +85,8 @@ void SlaveElement::unlinkElement(Element *elmt) {
//Ensure elmt is linked to this element //Ensure elmt is linked to this element
if (connected_elements.contains(elmt)) { if (connected_elements.contains(elmt)) {
connected_elements.removeOne(elmt); connected_elements.removeOne(elmt);
disconnect(elmt, SIGNAL(positionChange(QPointF)), this, SLOT(updateLabel())); disconnect(elmt, SIGNAL(xChanged()), this, SLOT(updateLabel()));
disconnect(elmt, SIGNAL(yChanged()), this, SLOT(updateLabel()));
disconnect(elmt, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel())); disconnect(elmt, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
delete Xref_item; Xref_item = NULL; delete Xref_item; Xref_item = NULL;
updateLabel(); updateLabel();